Skip to content

Commit

Permalink
[TASK] Add functional test of recursive section rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessCoder committed Feb 18, 2016
1 parent c0f7c0f commit c1ec9b0
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/Functional/BaseFunctionalTestCase.php
Expand Up @@ -102,7 +102,7 @@ public function testTemplateCodeFixture($source, array $variables, array $expect
$view->getRenderingContext()->getTemplatePaths()->setTemplateSource($source);
$view->getRenderingContext()->getViewHelperResolver()->addNamespace('test', 'TYPO3Fluid\\Fluid\\Tests\\Functional\\Fixtures\\ViewHelpers');
$view->assignMultiple($variables);
$output = $view->render();
$output = trim($view->render());
$this->assertNotEquals($view->getRenderingContext()->getTemplatePaths()->getTemplateSource(), $output, 'Input and output were the same');
if (empty($expected) && empty($notExpected)) {
$this->fail('Test performs no assertions!');
Expand Down
56 changes: 56 additions & 0 deletions tests/Functional/Cases/Rendering/RecursiveSectionRenderingTest.php
@@ -0,0 +1,56 @@
<?php
namespace TYPO3Fluid\Fluid\Tests\Functional\Cases\Escaping;

use TYPO3Fluid\Fluid\Tests\Functional\BaseFunctionalTestCase;

/**
* Class RecursiveSectionRendering
*/
class RecursiveSectionRenderingTest extends BaseFunctionalTestCase {

/**
* Variables array constructed to expect exactly three
* recursive renderings followed by a single rendering.
*
* @var array
*/
protected $variables = array(
'settings' => array(
'test' => '<strong>Bla</strong>'
),
'items' => array(
array(
'id' => 1,
'items' => array(
array(
'id' => 2,
'items' => array(
array(
'id' => 3,
'items' => array()
)
)
)
)
),
array(
'id' => 4
)
)
);

/**
* @return array
*/
public function getTemplateCodeFixturesAndExpectations() {
return array(
'Recursive section rendering clones variable storage and restores after loop ends' => array(
file_get_contents(__DIR__ . '/../../Fixtures/Templates/RecursiveSectionRendering.html'),
$this->variables,
array('Item: 1.', 'Item: 2.', 'Item: 3.', 'Item: 4.'),
array(),
),
);
}

}
12 changes: 12 additions & 0 deletions tests/Functional/Fixtures/Templates/RecursiveSectionRendering.html
@@ -0,0 +1,12 @@
<f:section name="Items">
<f:spaceless>
<f:for each="{items}" as="item">
Item: {item.id}.
<f:if condition="{item.items}">
<f:render section="Items" arguments="{items: item.items}" />
</f:if>
</f:for>
</f:spaceless>
</f:section>

<f:render section="Items" arguments="{items: items}" />

0 comments on commit c1ec9b0

Please sign in to comment.