DriverChainTest.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Metadata\Tests\Driver;
  3. use Metadata\ClassMetadata;
  4. use Metadata\Driver\DriverChain;
  5. class DriverChainTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testLoadMetadataForClass()
  8. {
  9. $driver = $this->getMock('Metadata\\Driver\\DriverInterface');
  10. $driver
  11. ->expects($this->once())
  12. ->method('loadMetadataForClass')
  13. ->will($this->returnValue($metadata = new ClassMetadata('\stdClass')))
  14. ;
  15. $chain = new DriverChain(array($driver));
  16. $this->assertSame($metadata, $chain->loadMetadataForClass(new \ReflectionClass('\stdClass')));
  17. }
  18. public function testLoadMetadataForClassReturnsNullWhenNoMetadataIsFound()
  19. {
  20. $driver = new DriverChain(array());
  21. $this->assertNull($driver->loadMetadataForClass(new \ReflectionClass('\stdClass')));
  22. $driver = $this->getMock('Metadata\\Driver\\DriverInterface');
  23. $driver
  24. ->expects($this->once())
  25. ->method('loadMetadataForClass')
  26. ->will($this->returnValue(null))
  27. ;
  28. $driverChain = new DriverChain(array($driver));
  29. $this->assertNull($driver->loadMetadataForClass(new \ReflectionClass('\stdClass')));
  30. }
  31. }