1
0
mirror of synced 2024-12-14 23:26:04 +03:00

DDC-706 - Fix DriverChain::isTransient() to comply with interface of Driver

This commit is contained in:
Benjamin Eberlei 2010-07-21 21:20:55 +02:00
parent 913e58e385
commit 6007084324
4 changed files with 21 additions and 15 deletions

View File

@ -96,8 +96,8 @@ class DriverChain implements Driver
/** /**
* Whether the class with the specified name should have its metadata loaded. * Whether the class with the specified name should have its metadata loaded.
* This is only the case if it is either mapped as an Entity or a *
* MappedSuperclass. * This is only the case for non-transient classes either mapped as an Entity or MappedSuperclass.
* *
* @param string $className * @param string $className
* @return boolean * @return boolean
@ -110,6 +110,7 @@ class DriverChain implements Driver
} }
} }
throw MappingException::classIsNotAValidEntityOrMappedSuperClass($className); // class isTransient, i.e. not an entity or mapped superclass
return true;
} }
} }

View File

@ -28,6 +28,7 @@ class AllTests
$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\ClassMetadataFactoryTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\ClassMetadataFactoryTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\ClassMetadataLoadEventTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\ClassMetadataLoadEventTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\BasicInheritanceMappingTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\BasicInheritanceMappingTest');
$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\DriverChainTest');
return $suite; return $suite;
} }

View File

@ -50,17 +50,6 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase
$chain->loadMetadataForClass($className, $classMetadata); $chain->loadMetadataForClass($className, $classMetadata);
} }
public function testIsTransient_NoDelegatorFound_ThrowsMappingException()
{
$className = 'Doctrine\Tests\ORM\Mapping\DriverChainEntity';
$classMetadata = new \Doctrine\ORM\Mapping\ClassMetadata($className);
$chain = new DriverChain();
$this->setExpectedException('Doctrine\ORM\Mapping\MappingException');
$chain->isTransient($className);
}
public function testGatherAllClassNames() public function testGatherAllClassNames()
{ {
$className = 'Doctrine\Tests\ORM\Mapping\DriverChainEntity'; $className = 'Doctrine\Tests\ORM\Mapping\DriverChainEntity';
@ -83,6 +72,21 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase
$this->assertEquals(array('Foo', 'Bar', 'Baz'), $chain->getAllClassNames()); $this->assertEquals(array('Foo', 'Bar', 'Baz'), $chain->getAllClassNames());
} }
/**
* @group DDC-706
*/
public function testIsTransient()
{
$reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache());
$reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
$chain = new DriverChain();
$chain->addDriver(new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array()), 'Doctrine\Tests\Models\CMS');
$this->assertTrue($chain->isTransient('stdClass'), "stdClass isTransient");
$this->assertFalse($chain->isTransient('Doctrine\Tests\Models\CMS\CmsUser'), "CmsUser is not Transient");
}
} }
class DriverChainEntity class DriverChainEntity