Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 695ae711e7f2d6892a8a411f4f09ae612335b90c 1 parent 0daa76d
Robert Curry authored April 12, 2012

Showing 1 changed file with 42 additions and 0 deletions. Show diff stats Hide diff stats

  1. 42  tests/view/SSViewerTest.php
42  tests/view/SSViewerTest.php
@@ -759,6 +759,48 @@ function testUpInLoop(){
759 759
 			)
760 760
 		);
761 761
 	}
  762
+	
  763
+	/**
  764
+	 * Test that nested loops restore the loop variables correctly when pushing and popping states
  765
+	 */
  766
+	function testNestedLoops(){
  767
+		
  768
+		// Data to run the loop tests on - one sequence of three items, one with child elements
  769
+		// (of a different size to the main sequence)
  770
+		$data = new ArrayData(array(
  771
+			'Foo' => new ArrayList(array(
  772
+				new ArrayData(array(
  773
+					'Name' => '1',
  774
+					'Children' => new ArrayList(array(
  775
+						new ArrayData(array(
  776
+							'Name' => 'a'
  777
+						)),
  778
+						new ArrayData(array(
  779
+							'Name' => 'b'
  780
+						)),
  781
+					)),
  782
+				)),
  783
+				new ArrayData(array(
  784
+					'Name' => '2',
  785
+					'Children' => new ArrayList(),
  786
+				)),
  787
+				new ArrayData(array(
  788
+					'Name' => '3',
  789
+					'Children' => new ArrayList(),
  790
+				)),
  791
+			)),
  792
+		));
  793
+
  794
+		// Make sure that including a loop inside a loop will not destroy the internal count of
  795
+		// items, checked by using "Last"
  796
+		$this->assertEqualIgnoringWhitespace(
  797
+			'1ab23last',
  798
+			$this->render(
  799
+				'<% loop $Foo %>$Name<% loop Children %>$Name<% end_loop %><% if Last %>last<% end_if %><% end_loop %>',
  800
+				$data
  801
+			)
  802
+		);
  803
+	}
762 804
 
763 805
 	/**
764 806
 	 * @covers SSViewer::get_themes()

0 notes on commit 695ae71

Please sign in to comment.
Something went wrong with that request. Please try again.