Skip to content

Commit

Permalink
Merge branch '1.1.x' into 1.2.x
Browse files Browse the repository at this point in the history
* 1.1.x:
  Fix wrong return type hint for selectManager
  Remove dupes in FileDriver::getAllClassNames
  • Loading branch information
alcaeus committed Apr 23, 2019
2 parents 38dc039 + 3da7c9d commit 43526ae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public function resetManager($name = null)
return $this->getManager($name);
}

private function selectManager(string $persistentObjectName, ?string $persistentManagerName = null) : ?ObjectManager
private function selectManager(string $persistentObjectName, ?string $persistentManagerName = null) : ObjectManager
{
if ($persistentManagerName !== null) {
return $this->getManager($persistentManagerName);
Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Doctrine\Common\Persistence\Mapping\MappingException;
use function array_keys;
use function array_merge;
use function array_unique;
use function is_file;
use function str_replace;

Expand Down Expand Up @@ -126,10 +127,10 @@ public function getAllClassNames()
return (array) $this->locator->getAllClassNames($this->globalBasename);
}

return array_merge(
return array_unique(array_merge(
array_keys($this->classCache),
(array) $this->locator->getAllClassNames($this->globalBasename)
);
));
}

/**
Expand Down
16 changes: 16 additions & 0 deletions tests/Doctrine/Tests/Common/Persistence/Mapping/FileDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ public function testGetAllClassNamesBothSources()
self::assertSame(['stdGlobal', 'stdGlobal2', 'stdClass'], $classNames);
}

public function testGetAllClassNamesBothSourcesNoDupes() : void
{
$locator = $this->newLocator();
$locator->expects($this->once())
->method('getAllClassNames')
->with($this->equalTo('global'))
->willReturn(['stdClass']);
$driver = new TestFileDriver($locator);
$driver->setGlobalBasename('global');

$driver->getElement('stdClass');
$classNames = $driver->getAllClassNames();

self::assertSame(['stdGlobal', 'stdGlobal2', 'stdClass'], $classNames);
}

public function testIsNotTransient()
{
$locator = $this->newLocator();
Expand Down

0 comments on commit 43526ae

Please sign in to comment.