DDC-706 - Fix DriverChain::isTransient() to comply with interface of Driver
This commit is contained in:
parent
913e58e385
commit
6007084324
@ -96,8 +96,8 @@ class DriverChain implements Driver
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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;
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ class AllTests
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\ClassMetadataFactoryTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\ClassMetadataLoadEventTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\BasicInheritanceMappingTest');
|
||||
$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\DriverChainTest');
|
||||
|
||||
return $suite;
|
||||
}
|
||||
|
@ -50,17 +50,6 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase
|
||||
$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()
|
||||
{
|
||||
$className = 'Doctrine\Tests\ORM\Mapping\DriverChainEntity';
|
||||
@ -83,6 +72,21 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase
|
||||
|
||||
$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
|
||||
|
Loading…
Reference in New Issue
Block a user