TemplateIteratorTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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\Bundle\TwigBundle\Tests;
  11. use Symfony\Bundle\TwigBundle\TemplateIterator;
  12. class TemplateIteratorTest extends TestCase
  13. {
  14. public function testGetIterator()
  15. {
  16. $bundle = $this->getMock('Symfony\Component\HttpKernel\Bundle\BundleInterface');
  17. $bundle->expects($this->any())->method('getName')->will($this->returnValue('BarBundle'));
  18. $bundle->expects($this->any())->method('getPath')->will($this->returnValue(__DIR__.'/Fixtures/templates/BarBundle'));
  19. $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Kernel')->disableOriginalConstructor()->getMock();
  20. $kernel->expects($this->any())->method('getBundles')->will($this->returnValue(array(
  21. $bundle,
  22. )));
  23. $iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo'));
  24. $sorted = iterator_to_array($iterator);
  25. sort($sorted);
  26. $this->assertEquals(
  27. array(
  28. '@Bar/index.html.twig',
  29. '@Foo/index.html.twig',
  30. 'layout.html.twig',
  31. 'sub/sub.html.twig',
  32. ),
  33. $sorted
  34. );
  35. }
  36. }