Skip to content

Commit

Permalink
Merge pull request #3 from victorwelling/optional-nested
Browse files Browse the repository at this point in the history
Added test for nested optional tags
  • Loading branch information
Victor Welling committed Aug 28, 2018
2 parents d6939e4 + d4b356d commit 25b7818
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
@@ -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
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 25b7818

Please sign in to comment.