Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MINOR: Issue #7113: Add test for nested loops.

  • Loading branch information...
commit 695ae711e7f2d6892a8a411f4f09ae612335b90c 1 parent 0daa76d
Robert Curry robert-h-curry authored
Showing with 42 additions and 0 deletions.
  1. +42 −0 tests/view/SSViewerTest.php
42 tests/view/SSViewerTest.php
View
@@ -759,6 +759,48 @@ function testUpInLoop(){
)
);
}
+
+ /**
+ * Test that nested loops restore the loop variables correctly when pushing and popping states
+ */
+ function testNestedLoops(){
+
+ // Data to run the loop tests on - one sequence of three items, one with child elements
+ // (of a different size to the main sequence)
+ $data = new ArrayData(array(
+ 'Foo' => new ArrayList(array(
+ new ArrayData(array(
+ 'Name' => '1',
+ 'Children' => new ArrayList(array(
+ new ArrayData(array(
+ 'Name' => 'a'
+ )),
+ new ArrayData(array(
+ 'Name' => 'b'
+ )),
+ )),
+ )),
+ new ArrayData(array(
+ 'Name' => '2',
+ 'Children' => new ArrayList(),
+ )),
+ new ArrayData(array(
+ 'Name' => '3',
+ 'Children' => new ArrayList(),
+ )),
+ )),
+ ));
+
+ // Make sure that including a loop inside a loop will not destroy the internal count of
+ // items, checked by using "Last"
+ $this->assertEqualIgnoringWhitespace(
+ '1ab23last',
+ $this->render(
+ '<% loop $Foo %>$Name<% loop Children %>$Name<% end_loop %><% if Last %>last<% end_if %><% end_loop %>',
+ $data
+ )
+ );
+ }
/**
* @covers SSViewer::get_themes()
Please sign in to comment.
Something went wrong with that request. Please try again.