mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
[#1621] Failing tests for Filesystem loader
This commit is contained in:
committed by
Fabien Potencier
parent
74a8bddec4
commit
f7a49f2687
@@ -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
|
||||
@@ -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 %}
|
||||
+3
@@ -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 %}
|
||||
Reference in New Issue
Block a user