/** * @group DDC-706 */ public function testIsTransient() { $chain = new DriverChain(); $chain->addDriver($this->createAnnotationDriver(), 'Doctrine\\Tests\\Models\\CMS'); $this->assertTrue($chain->isTransient('stdClass'), "stdClass isTransient"); $this->assertFalse($chain->isTransient('Doctrine\\Tests\\Models\\CMS\\CmsUser'), "CmsUser is not Transient"); }
/** * @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"); }
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); }
/** * @group DDC-1412 */ public function testDefaultDriver() { $companyDriver = $this->getMock('Doctrine\\ORM\\Mapping\\Driver\\Driver'); $dafaultDriver = $this->getMock('Doctrine\\ORM\\Mapping\\Driver\\Driver'); $entityClassName = 'Doctrine\\Tests\\ORM\\Mapping\\DriverChainEntity'; $managerClassName = 'Doctrine\\Tests\\Models\\Company\\CompanyManager'; $chain = new DriverChain(); $companyDriver->expects($this->never())->method('loadMetadataForClass'); $companyDriver->expects($this->once())->method('isTransient')->with($this->equalTo($managerClassName))->will($this->returnValue(false)); $dafaultDriver->expects($this->never())->method('loadMetadataForClass'); $dafaultDriver->expects($this->once())->method('isTransient')->with($this->equalTo($entityClassName))->will($this->returnValue(true)); $this->assertNull($chain->getDefaultDriver()); $chain->setDefaultDriver($dafaultDriver); $chain->addDriver($companyDriver, 'Doctrine\\Tests\\Models\\Company'); $this->assertSame($dafaultDriver, $chain->getDefaultDriver()); $this->assertTrue($chain->isTransient($entityClassName)); $this->assertFalse($chain->isTransient($managerClassName)); }