This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php

59 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\FrameworkBundle\Tests\Templating;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
class TemplateNameParserTest extends TestCase
{
/**
* @dataProvider getParseTests
*/
public function testParse($name, $parameters)
{
$converter = new TemplateNameParser();
$this->assertEquals($parameters, $converter->parse($name));
}
public function getParseTests()
{
return array(
array('BlogBundle:Post:index.php', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => ''))),
array('BlogBundle:Post:index.twig', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'twig', 'format' => ''))),
array('BlogBundle:Post:index.xml.php', array('index', array('bundle' => 'BlogBundle', 'controller' => 'Post', 'renderer' => 'php', 'format' => '.xml'))),
);
}
/**
* @dataProvider getParseInvalidTests
* @expectedException \InvalidArgumentException
*/
public function testParseInvalid($name)
{
$converter = new TemplateNameParser();
$converter->parse($name);
}
public function getParseInvalidTests()
{
return array(
array('BlogBundle:Post:index'),
array('BlogBundle:Post'),
array('BlogBundle:Post:foo:bar'),
array('BlogBundle:Post:index.foo.bar.foobar'),
);
}
}