TemplateNameParser example

class PhpEngineTest extends TestCase
{
    protected ProjectTemplateEngineLoader $loader;

    protected function setUp(): void
    {
        $this->loader = new ProjectTemplateEngineLoader();
    }

    public function testConstructor()
    {
        $engine = new ProjectTemplateEngine(new TemplateNameParser()$this->loader);
        $this->assertEquals($this->loader, $engine->getLoader(), '__construct() takes a loader instance as its second first argument');
    }

    public function testOffsetGet()
    {
        $engine = new ProjectTemplateEngine(new TemplateNameParser()$this->loader);
        $engine->set($helper = new \Symfony\Component\Templating\Tests\Fixtures\SimpleHelper('bar'), 'foo');
        $this->assertEquals($helper$engine['foo'], '->offsetGet() returns the value of a helper');

        try {
            $engine['bar'];
            
use Symfony\Component\Templating\TemplateReference;

/** * @group legacy */
class TemplateNameParserTest extends TestCase
{
    protected TemplateNameParser $parser;

    protected function setUp(): void
    {
        $this->parser = new TemplateNameParser();
    }

    /** * @dataProvider getLogicalNameToTemplateProvider */
    public function testParse($name$ref)
    {
        $template = $this->parser->parse($name);

        $this->assertEquals($template->getLogicalName()$ref->getLogicalName());
        $this->assertEquals($template->getLogicalName()$name);
    }
Home | Imprint | This part of the site doesn't use cookies.