forked from doctrine/common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Tests for more drivers and the AbstractClassMetadataFactory
- Loading branch information
Showing
11 changed files
with
326 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
tests/Doctrine/Tests/Common/Persistence/Mapping/ChainDriverTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\Common\Persistence\Mapping; | ||
|
||
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain; | ||
use Doctrine\Tests\DoctrineTestCase; | ||
|
||
class DriverChainTest extends DoctrineTestCase | ||
{ | ||
public function testDelegateToMatchingNamespaceDriver() | ||
{ | ||
$className = 'Doctrine\Tests\Common\Persistence\Mapping\DriverChainEntity'; | ||
$classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); | ||
|
||
$chain = new MappingDriverChain(); | ||
|
||
$driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); | ||
$driver1->expects($this->never()) | ||
->method('loadMetadataForClass'); | ||
$driver1->expectS($this->never()) | ||
->method('isTransient'); | ||
|
||
$driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); | ||
$driver2->expects($this->at(0)) | ||
->method('loadMetadataForClass') | ||
->with($this->equalTo($className), $this->equalTo($classMetadata)); | ||
$driver2->expects($this->at(1)) | ||
->method('isTransient') | ||
->with($this->equalTo($className)) | ||
->will($this->returnValue( true )); | ||
|
||
$chain->addDriver($driver1, 'Doctrine\Tests\Models\Company'); | ||
$chain->addDriver($driver2, 'Doctrine\Tests\Common\Persistence\Mapping'); | ||
|
||
$chain->loadMetadataForClass($className, $classMetadata); | ||
|
||
$this->assertTrue( $chain->isTransient($className) ); | ||
} | ||
|
||
public function testLoadMetadata_NoDelegatorFound_ThrowsMappingException() | ||
{ | ||
$className = 'Doctrine\Tests\Common\Persistence\Mapping\DriverChainEntity'; | ||
$classMetadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata'); | ||
|
||
$chain = new MappingDriverChain(); | ||
|
||
$this->setExpectedException('Doctrine\Common\Persistence\Mapping\MappingException'); | ||
$chain->loadMetadataForClass($className, $classMetadata); | ||
} | ||
|
||
public function testGatherAllClassNames() | ||
{ | ||
$className = 'Doctrine\Tests\Common\Persistence\Mapping\DriverChainEntity'; | ||
$classMetadata = $this->getMock('Doctrine\Common\Peristence\ClassMetadata'); | ||
|
||
$chain = new MappingDriverChain(); | ||
|
||
$driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); | ||
$driver1->expects($this->once()) | ||
->method('getAllClassNames') | ||
->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo'))); | ||
|
||
$driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); | ||
$driver2->expects($this->once()) | ||
->method('getAllClassNames') | ||
->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( | ||
'Doctrine\Tests\Models\Company\Foo', | ||
'Doctrine\Tests\ORM\Mapping\Bar', | ||
'Doctrine\Tests\ORM\Mapping\Baz' | ||
), $chain->getAllClassNames()); | ||
} | ||
|
||
/** | ||
* @group DDC-706 | ||
*/ | ||
public function testIsTransient() | ||
{ | ||
$driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver\MappingDriver'); | ||
$chain = new MappingDriverChain(); | ||
$chain->addDriver($driver1, 'Doctrine\Tests\Models\CMS'); | ||
|
||
$this->assertTrue($chain->isTransient('stdClass'), "stdClass isTransient"); | ||
} | ||
} | ||
|
||
class DriverChainEntity | ||
{ | ||
|
||
} |
Oops, something went wrong.