-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Fixes doctrine#2561
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
use Documents\CmsProduct; | ||
use Documents\Comment; | ||
use Documents\File; | ||
use Documents\Project; | ||
use Documents\SchemaValidated; | ||
use Documents\Sharded\ShardedOne; | ||
use Documents\Sharded\ShardedOneWithDifferentKey; | ||
|
@@ -41,6 +42,7 @@ | |
use function array_map; | ||
use function assert; | ||
use function in_array; | ||
use function key; | ||
use function MongoDB\BSON\fromJSON; | ||
use function MongoDB\BSON\toPHP; | ||
|
||
|
@@ -60,6 +62,7 @@ class SchemaManagerTest extends BaseTestCase | |
SimpleReferenceUser::class, | ||
ShardedOne::class, | ||
ShardedOneWithDifferentKey::class, | ||
Project::class, | ||
]; | ||
|
||
/** @psalm-var list<class-string> */ | ||
|
@@ -285,7 +288,7 @@ public function testEnsureDocumentIndexesWithTwoLevelInheritance(array $expected | |
$collectionName = $this->dm->getClassMetadata(CmsProduct::class)->getCollection(); | ||
$collection = $this->documentCollections[$collectionName]; | ||
$collection | ||
->expects($this->once()) | ||
->expects($this->exactly(2)) | ||
->method('createIndex') | ||
->with($this->anything(), $this->writeOptions($expectedWriteOptions)); | ||
|
||
|
@@ -317,6 +320,52 @@ public function testUpdateDocumentIndexesShouldCreateMappedIndexes(array $expect | |
$this->schemaManager->updateDocumentIndexes(CmsArticle::class, $maxTimeMs, $writeConcern); | ||
} | ||
|
||
/** @psalm-param IndexOptions $expectedWriteOptions */ | ||
public function testUpdateDocumentIndexesShouldCreateIndexesFromMappedSuperclass(): void | ||
Check failure on line 324 in tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php GitHub Actions / Static Analysis with PHPStan (8.2)
|
||
{ | ||
$collectionName = $this->dm->getClassMetadata(CmsProduct::class)->getCollection(); | ||
$collection = $this->documentCollections[$collectionName]; | ||
$collection | ||
->expects($this->once()) | ||
->method('listIndexes') | ||
->willReturn(new IndexInfoIteratorIterator(new ArrayIterator([]))); | ||
Check failure on line 331 in tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php GitHub Actions / Static Analysis with Psalm (8.2)InternalClass
Check failure on line 331 in tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php GitHub Actions / Static Analysis with Psalm (8.2)InternalMethod
|
||
$collection | ||
->expects($this->exactly(2)) | ||
->method('createIndex') | ||
->with($this->anything(), $this->anything()); | ||
$collection | ||
->expects($this->never()) | ||
->method('dropIndex') | ||
->with($this->anything()); | ||
|
||
$this->schemaManager->updateDocumentIndexes(CmsProduct::class); | ||
} | ||
|
||
/** @psalm-param IndexOptions $expectedWriteOptions */ | ||
public function testUpdateDocumentIndexesShouldCreateIndexFromSubclasses(): void | ||
Check failure on line 345 in tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php GitHub Actions / Static Analysis with PHPStan (8.2)
|
||
{ | ||
$collectionName = $this->dm->getClassMetadata(Project::class)->getCollection(); | ||
$collection = $this->documentCollections[$collectionName]; | ||
$collection | ||
->expects($this->once()) | ||
->method('listIndexes') | ||
->willReturn(new IndexInfoIteratorIterator(new ArrayIterator([]))); | ||
Check failure on line 352 in tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php GitHub Actions / Static Analysis with Psalm (8.2)InternalClass
Check failure on line 352 in tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php GitHub Actions / Static Analysis with Psalm (8.2)InternalMethod
|
||
|
||
$matcher = $this->exactly(2); | ||
$collection | ||
->expects($matcher) | ||
->method('createIndex') | ||
->willReturnCallback(static function ($key, $value) use ($matcher) { | ||
self::assertSame(['name', 'externalId'][$matcher->numberOfInvocations() - 1], key($key)); | ||
Check failure on line 359 in tests/Doctrine/ODM/MongoDB/Tests/SchemaManagerTest.php GitHub Actions / Static Analysis with Psalm (8.2)InternalMethod
|
||
}); | ||
$collection | ||
->expects($this->never()) | ||
->method('dropIndex') | ||
->with($this->anything()); | ||
|
||
$this->schemaManager->updateDocumentIndexes(Project::class); | ||
} | ||
|
||
/** | ||
* @psalm-param IndexOptions $expectedWriteOptions | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ class Project | |
|
||
/** | ||
* @ODM\Field(type="string") | ||
* @ODM\UniqueIndex | ||
* | ||
* @var string|null | ||
*/ | ||
|