From aa2501eb965eec7949af1cfd125389dc14693dbe Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Wed, 8 Dec 2010 23:29:21 +0100 Subject: [PATCH] DDC-917 - Bugfix with DriverChain::getAllClassNames() - It was not semantically correct and returning too many metadata. --- lib/Doctrine/ORM/Mapping/Driver/DriverChain.php | 11 ++++++++--- tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) 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()); } /**