FilesLoaderTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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\Component\Validator\Tests\Mapping\Loader;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Validator\Mapping\ClassMetadata;
  13. use Symfony\Component\Validator\Mapping\Loader\LoaderInterface;
  14. class FilesLoaderTest extends TestCase
  15. {
  16. public function testCallsGetFileLoaderInstanceForeachPath()
  17. {
  18. $loader = $this->getFilesLoader($this->getFileLoader());
  19. $this->assertEquals(4, $loader->getTimesCalled());
  20. }
  21. public function testCallsActualFileLoaderForMetadata()
  22. {
  23. $fileLoader = $this->getFileLoader();
  24. $fileLoader->expects($this->exactly(4))
  25. ->method('loadClassMetadata');
  26. $loader = $this->getFilesLoader($fileLoader);
  27. $loader->loadClassMetadata(new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity'));
  28. }
  29. public function getFilesLoader(LoaderInterface $loader)
  30. {
  31. return $this->getMockForAbstractClass('Symfony\Component\Validator\Tests\Fixtures\FilesLoader', array(array(
  32. __DIR__.'/constraint-mapping.xml',
  33. __DIR__.'/constraint-mapping.yaml',
  34. __DIR__.'/constraint-mapping.test',
  35. __DIR__.'/constraint-mapping.txt',
  36. ), $loader));
  37. }
  38. public function getFileLoader()
  39. {
  40. return $this->getMockBuilder('Symfony\Component\Validator\Mapping\Loader\LoaderInterface')->getMock();
  41. }
  42. }