forked from mongodb/mongo-php-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use is_document to reject PackedArrays mongodb#1117
- Loading branch information
Showing
8 changed files
with
69 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace MongoDB\Tests\Model; | ||
|
||
use MongoDB\BSON\Serializable; | ||
use MongoDB\Exception\InvalidArgumentException; | ||
use MongoDB\Model\SearchIndexInput; | ||
use MongoDB\Tests\TestCase; | ||
|
||
class SearchIndexInputTest extends TestCase | ||
{ | ||
public function testConstructorIndexDefinitionMustBeDefined(): void | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Required "definition" document is missing from search index specification'); | ||
new SearchIndexInput([]); | ||
} | ||
|
||
public function testConstructorIndexDefinitionMustBeADocument(): void | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Expected "definition" option to have type "document"'); | ||
new SearchIndexInput(['definition' => 'foo']); | ||
} | ||
|
||
public function testConstructorShouldRequireNameToBeString(): void | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
$this->expectExceptionMessage('Expected "name" option to have type "string"'); | ||
new SearchIndexInput(['definition' => ['mapping' => ['dynamid' => true]], 'name' => 1]); | ||
} | ||
|
||
public function testBsonSerialization(): void | ||
{ | ||
$expected = (object) [ | ||
'name' => 'my_search', | ||
'definition' => ['mapping' => ['dynamic' => true]], | ||
]; | ||
|
||
$indexInput = new SearchIndexInput([ | ||
'name' => 'my_search', | ||
'definition' => ['mapping' => ['dynamic' => true]], | ||
]); | ||
|
||
$this->assertInstanceOf(Serializable::class, $indexInput); | ||
$this->assertEquals($expected, $indexInput->bsonSerialize()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters