[#1621] Failing tests for Filesystem loader

This commit is contained in:
Pavel Batanov
2015-02-03 13:39:32 +03:00
committed by Fabien Potencier
parent 74a8bddec4
commit f7a49f2687
9 changed files with 64 additions and 0 deletions
@@ -0,0 +1,12 @@
--TEST--
"extends" tag
--TEMPLATE--
{% extends ["", "bar.twig"] %}
--TEMPLATE(bar.twig)--
{% block content %}
foo
{% endblock %}
--DATA--
return array()
--EXPECT--
foo
@@ -0,0 +1,12 @@
--TEST--
"extends" tag
--TEMPLATE--
{% extends [null, "bar.twig"] %}
--TEMPLATE(bar.twig)--
{% block content %}
foo
{% endblock %}
--DATA--
return array()
--EXPECT--
foo
+26
View File
@@ -146,4 +146,30 @@ class Twig_Tests_Loader_FilesystemTest extends PHPUnit_Framework_TestCase
$template = $twig->loadTemplate('blocks.html.twig');
$this->assertSame('block from theme 2', $template->renderBlock('b2', array()));
}
public function getArrayInheritanceTests()
{
return array(
'valid array inheritance' => array('array_inheritance_valid_parent.html.twig'),
'array inheritance with null first template' => array('array_inheritance_null_parent.html.twig'),
'array inheritance with empty first template' => array('array_inheritance_empty_parent.html.twig'),
'array inheritance with non-existent first template' => array('array_inheritance_nonexistent_parent.html.twig'),
);
}
/**
* @dataProvider getArrayInheritanceTests
*
* @param $templateName string Template name with array inheritance
*/
public function testArrayInheritance($templateName)
{
$loader = new Twig_Loader_Filesystem(array());
$loader->addPath(dirname(__FILE__).'/Fixtures/inheritance');
$twig = new Twig_Environment($loader);
$template = $twig->loadTemplate($templateName);
$this->assertSame('VALID Child', $template->renderBlock('body', array()));
}
}
@@ -0,0 +1,3 @@
{% extends ['','parent.html.twig'] %}
{% block body %}{{ parent() }} Child{% endblock %}
@@ -0,0 +1,3 @@
{% extends ['nonexistent.html.twig','parent.html.twig'] %}
{% block body %}{{ parent() }} Child{% endblock %}
@@ -0,0 +1,3 @@
{% extends [null,'parent.html.twig'] %}
{% block body %}{{ parent() }} Child{% endblock %}
@@ -0,0 +1,3 @@
{% extends ['parent.html.twig','spare_parent.html.twig'] %}
{% block body %}{{ parent() }} Child{% endblock %}
@@ -0,0 +1 @@
{% block body %}VALID{% endblock %}
@@ -0,0 +1 @@
{% block body %}SPARE PARENT{% endblock %}