diff --git a/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php b/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php index d97a61e5b..77c258a18 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php @@ -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); } /** diff --git a/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php b/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php index 333b8638b..d218aaf8f 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php @@ -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()); } /**