Skip to content

Commit

Permalink
Added test for nested optional tags
Browse files Browse the repository at this point in the history
  • Loading branch information
victorwelling committed Aug 28, 2018
1 parent d6939e4 commit d4b356d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Fixtures/Templates/optional_nested.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{##
# Nested 'optional' tags should not affect their parents.
#}
header
{% optional %}
{% optional %}
{% include 'runtime_exception.twig' %}
{% endoptional %}
not affected
{% endoptional %}
footer
13 changes: 13 additions & 0 deletions tests/TwigIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ public function testOptionalBlocksShouldNotSuppressUnknownVariables()
$this->renderTemplate('optional_unknown_variable.twig');
}

/**
* @return void
*/
public function testNestedOptionalBlocksShouldNotAffectedParents()
{
$output = $this->renderTemplate('optional_nested.twig');

$this->assertContains('header', $output);
$this->assertNotContains('should not be rendered', $output);
$this->assertContains('not affected', $output);
$this->assertContains('footer', $output);
}

/**
* @param string $template
*
Expand Down

0 comments on commit d4b356d

Please sign in to comment.