Skip to content

Commit

Permalink
[#1621] Failing tests for Filesystem loader
Browse files Browse the repository at this point in the history
  • Loading branch information
scaytrase authored and fabpot committed Feb 16, 2015
1 parent 74a8bdd commit f7a49f2
Show file tree
Hide file tree
Showing 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 changes: 26 additions & 0 deletions test/Twig/Tests/Loader/FilesystemTest.php
Expand Up @@ -146,4 +146,30 @@ public function testLoadTemplateAndRenderBlockWithCache()
$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 %}

0 comments on commit f7a49f2

Please sign in to comment.