1
0
mirror of synced 2025-03-04 20:03:21 +03:00

DDC-917 - Bugfix with DriverChain::getAllClassNames() - It was not semantically correct and returning too many metadata.

This commit is contained in:
Benjamin Eberlei 2010-12-08 23:29:21 +01:00
parent ef50d940de
commit aa2501eb96
2 changed files with 15 additions and 6 deletions

View File

@ -88,10 +88,15 @@ class DriverChain implements Driver
public function getAllClassNames() public function getAllClassNames()
{ {
$classNames = array(); $classNames = array();
foreach ($this->_drivers AS $driver) { foreach ($this->_drivers AS $namespace => $driver) {
$classNames = array_merge($classNames, $driver->getAllClassNames()); $driverClasses = $driver->getAllClassNames();
foreach ($driverClasses AS $className) {
if (strpos($className, $namespace) === 0) {
$classNames[] = $className;
} }
return $classNames; }
}
return array_unique($classNames);
} }
/** /**

View File

@ -60,17 +60,21 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase
$driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); $driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver');
$driver1->expects($this->once()) $driver1->expects($this->once())
->method('getAllClassNames') ->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 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver');
$driver2->expects($this->once()) $driver2->expects($this->once())
->method('getAllClassNames') ->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($driver1, 'Doctrine\Tests\Models\Company');
$chain->addDriver($driver2, 'Doctrine\Tests\ORM\Mapping'); $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());
} }
/** /**