DDC-917 - Bugfix with DriverChain::getAllClassNames() - It was not semantically correct and returning too many metadata.
This commit is contained in:
parent
ef50d940de
commit
aa2501eb96
@ -88,10 +88,15 @@ class DriverChain implements Driver
|
||||
public function getAllClassNames()
|
||||
{
|
||||
$classNames = array();
|
||||
foreach ($this->_drivers AS $driver) {
|
||||
$classNames = array_merge($classNames, $driver->getAllClassNames());
|
||||
foreach ($this->_drivers AS $namespace => $driver) {
|
||||
$driverClasses = $driver->getAllClassNames();
|
||||
foreach ($driverClasses AS $className) {
|
||||
if (strpos($className, $namespace) === 0) {
|
||||
$classNames[] = $className;
|
||||
}
|
||||
return $classNames;
|
||||
}
|
||||
}
|
||||
return array_unique($classNames);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,17 +60,21 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase
|
||||
$driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver');
|
||||
$driver1->expects($this->once())
|
||||
->method('getAllClassNames')
|
||||
->will($this->returnValue(array('Foo')));
|
||||
->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo')));
|
||||
|
||||
$driver2 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver');
|
||||
$driver2->expects($this->once())
|
||||
->method('getAllClassNames')
|
||||
->will($this->returnValue(array('Bar', 'Baz')));
|
||||
->will($this->returnValue(array('Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz')));
|
||||
|
||||
$chain->addDriver($driver1, 'Doctrine\Tests\Models\Company');
|
||||
$chain->addDriver($driver2, 'Doctrine\Tests\ORM\Mapping');
|
||||
|
||||
$this->assertEquals(array('Foo', 'Bar', 'Baz'), $chain->getAllClassNames());
|
||||
$this->assertEquals(array(
|
||||
'Doctrine\Tests\Models\Company\Foo',
|
||||
'Doctrine\Tests\ORM\Mapping\Bar',
|
||||
'Doctrine\Tests\ORM\Mapping\Baz'
|
||||
), $chain->getAllClassNames());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user