FilesLoaderTest.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Tests\Component\Validator\Mapping\Loader;
  11. require_once __DIR__.'/../../Fixtures/FilesLoader.php';
  12. require_once __DIR__.'/../../Fixtures/Entity.php';
  13. use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
  14. use Symfony\Component\Validator\Mapping\ClassMetadata;
  15. class FilesLoaderTest extends \PHPUnit_Framework_TestCase
  16. {
  17. public function testCallsGetFileLoaderInstanceForeachPath()
  18. {
  19. $loader = $this->getFilesLoader($this->getFileLoader());
  20. $this->assertEquals(4, $loader->getTimesCalled());
  21. }
  22. public function testCallsActualFileLoaderForMetadata()
  23. {
  24. $fileLoader = $this->getFileLoader();
  25. $fileLoader->expects($this->exactly(4))
  26. ->method('loadClassMetadata');
  27. $loader = $this->getFilesLoader($fileLoader);
  28. $loader->loadClassMetadata(new ClassMetadata('Symfony\Tests\Component\Validator\Fixtures\Entity'));
  29. }
  30. public function getFilesLoader(LoaderInterface $loader)
  31. {
  32. return $this->getMockForAbstractClass('Symfony\Tests\Component\Validator\Fixtures\FilesLoader', array(array(
  33. __DIR__ . '/constraint-mapping.xml',
  34. __DIR__ . '/constraint-mapping.yaml',
  35. __DIR__ . '/constraint-mapping.test',
  36. __DIR__ . '/constraint-mapping.txt',
  37. ), $loader));
  38. }
  39. public function getFileLoader()
  40. {
  41. return $this->getMock('Symfony\Component\Validator\Mapping\Loader\LoaderInterface');
  42. }
  43. }