forked from TYPO3/Fluid
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TASK] Add functional test of recursive section rendering
- Loading branch information
1 parent
c0f7c0f
commit c1ec9b0
Showing
3 changed files
with
69 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
tests/Functional/Cases/Rendering/RecursiveSectionRenderingTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
12
tests/Functional/Fixtures/Templates/RecursiveSectionRendering.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}" /> |