FilesLoaderTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace Symfony\Tests\Components\Validator\Mapping\Loader;
  3. require_once __DIR__.'/../../../../../../bootstrap.php';
  4. require_once __DIR__.'/../../Fixtures/FilesLoader.php';
  5. require_once __DIR__.'/../../Fixtures/Entity.php';
  6. use Symfony\Components\Validator\Mapping\Loader\LoaderInterface;
  7. use Symfony\Components\Validator\Mapping\ClassMetadata;
  8. class FilesLoaderTest extends \PHPUnit_Framework_TestCase
  9. {
  10. public function testCallsGetFileLoaderInstanceForeachPath()
  11. {
  12. $loader = $this->getFilesLoader($this->getFileLoader());
  13. $this->assertEquals(4, $loader->getTimesCalled());
  14. }
  15. public function testCallsActualFileLoaderForMetadata()
  16. {
  17. $fileLoader = $this->getFileLoader();
  18. $fileLoader->expects($this->exactly(4))
  19. ->method('loadClassMetadata');
  20. $loader = $this->getFilesLoader($fileLoader);
  21. $loader->loadClassMetadata(new ClassMetadata('Symfony\Tests\Components\Validator\Fixtures\Entity'));
  22. }
  23. public function getFilesLoader(LoaderInterface $loader)
  24. {
  25. return $this->getMockForAbstractClass('Symfony\Tests\Components\Validator\Fixtures\FilesLoader', array(array(
  26. __DIR__ . '/constraint-mapping.xml',
  27. __DIR__ . '/constraint-mapping.yaml',
  28. __DIR__ . '/constraint-mapping.test',
  29. __DIR__ . '/constraint-mapping.txt',
  30. ), $loader));
  31. }
  32. public function getFileLoader()
  33. {
  34. return $this->getMock('Symfony\Components\Validator\Mapping\Loader\LoaderInterface');
  35. }
  36. }