TemplateNameParserTest.php 1.3KB

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\Templating;
  11. use Symfony\Component\Templating\TemplateNameParser;
  12. use Symfony\Component\Templating\TemplateReference;
  13. class TemplateNameParserTest extends \PHPUnit_Framework_TestCase
  14. {
  15. protected $parser;
  16. protected function setUp()
  17. {
  18. $this->parser = new TemplateNameParser();
  19. }
  20. protected function tearDown()
  21. {
  22. $this->parser = null;
  23. }
  24. /**
  25. * @dataProvider getLogicalNameToTemplateProvider
  26. */
  27. public function testParse($name, $ref)
  28. {
  29. $template = $this->parser->parse($name);
  30. $this->assertEquals($template->getLogicalName(), $ref->getLogicalName());
  31. $this->assertEquals($template->getLogicalName(), $name);
  32. }
  33. public function getLogicalNameToTemplateProvider()
  34. {
  35. return array(
  36. array('/path/to/section/name.engine', new TemplateReference('/path/to/section/name.engine', 'engine')),
  37. array('name.engine', new TemplateReference('name.engine', 'engine')),
  38. array('name', new TemplateReference('name')),
  39. );
  40. }
  41. }