Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
… into 2.6
  • Loading branch information
alexander-schranz committed May 10, 2021
2 parents 0a9aec2 + 9682a64 commit adb99c9
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Run php-cs-fixer
if: ${{ matrix.php-cs-fixer }}
run: |
composer global require friendsofphp/php-cs-fixer --prefer-dist --no-interaction
composer global require friendsofphp/php-cs-fixer:^2.19 --prefer-dist --no-interaction
GLOBAL_BIN_DIR=$(composer global config bin-dir --absolute --quiet)
$GLOBAL_BIN_DIR/php-cs-fixer fix --dry-run --diff
Expand Down
3 changes: 3 additions & 0 deletions Search/Reindex/Provider/DoctrineOrmProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public function getClassFqns()
$classFqns = [];

foreach ($metadataFactory->getAllMetadata() as $classMetadata) {
if ($classMetadata->isMappedSuperclass) {
continue;
}
if (null === $this->searchMetadataFactory->getMetadataForClass($classMetadata->name)) {
continue;
}
Expand Down
23 changes: 23 additions & 0 deletions Tests/Unit/Search/ReIndex/Provider/DoctrineOrmProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,29 @@ public function testClassFqns()
$this->assertEquals(['stdClass'], $classFqns);
}

/**
* It should return all the class fqns without the mapped superclass.
*/
public function testClassFqnsMappedSuperClassNotReturned()
{
$this->ormMetadata->name = 'stdClass';
$mappedSuperClass = $this->prophesize(OrmClassMetadata::class);
$mappedSuperClass->name = 'stdClass2';
$mappedSuperClass->isMappedSuperclass = true;

$this->entityManager->getMetadataFactory()->willReturn($this->ormMetadataFactory->reveal());
$this->searchMetadataFactory->getMetadataForClass('stdClass')->willReturn($this->hierarchyMetadata->reveal());
$this->searchMetadataFactory->getMetadataForClass('stdClass2')->willReturn($mappedSuperClass->reveal());
$this->hierarchyMetadata->getOutsideClassMetadata()->willReturn($this->searchMetadata->reveal());
$this->ormMetadataFactory->getAllMetadata()->willReturn([
$this->ormMetadata->reveal(),
$mappedSuperClass->reveal(),
]);

$classFqns = $this->provider->getClassFqns();
$this->assertEquals(['stdClass'], $classFqns);
}

/**
* It should not return class FQNs NOT managed by the search manager.
*/
Expand Down

0 comments on commit adb99c9

Please sign in to comment.