TYPO3 CMS  TYPO3_6-2
All Classes Namespaces Files Functions Variables Pages
CycleViewHelperTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the TYPO3 Flow package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * The TYPO3 project - inspiring people to share! *
12  * */
13 
18 
22  protected $viewHelper;
23 
24  public function setUp() {
25  parent::setUp();
26  $this->viewHelper = $this->getMock('TYPO3\\CMS\\Fluid\\ViewHelpers\\CycleViewHelper', array('renderChildren'));
27  $this->injectDependenciesIntoViewHelper($this->viewHelper);
28  $this->viewHelper->initializeArguments();
29  }
30 
35  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('innerVariable', 'bar');
36  $this->templateVariableContainer->expects($this->at(1))->method('remove')->with('innerVariable');
37 
38  $values = array('bar', 'Fluid');
39  $this->viewHelper->render($values, 'innerVariable');
40  }
41 
46  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('innerVariable', 'bar');
47  $this->templateVariableContainer->expects($this->at(1))->method('remove')->with('innerVariable');
48  $this->templateVariableContainer->expects($this->at(2))->method('add')->with('innerVariable', 'Fluid');
49  $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('innerVariable');
50  $this->templateVariableContainer->expects($this->at(4))->method('add')->with('innerVariable', 'bar');
51  $this->templateVariableContainer->expects($this->at(5))->method('remove')->with('innerVariable');
52 
53  $values = array('bar', 'Fluid');
54  $this->viewHelper->render($values, 'innerVariable');
55  $this->viewHelper->render($values, 'innerVariable');
56  $this->viewHelper->render($values, 'innerVariable');
57  }
58 
63  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('innerVariable', 'FLOW3');
64  $this->templateVariableContainer->expects($this->at(1))->method('remove')->with('innerVariable');
65  $this->templateVariableContainer->expects($this->at(2))->method('add')->with('innerVariable', 'Fluid');
66  $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('innerVariable');
67  $this->templateVariableContainer->expects($this->at(4))->method('add')->with('innerVariable', 'FLOW3');
68  $this->templateVariableContainer->expects($this->at(5))->method('remove')->with('innerVariable');
69 
70  $values = array('foo' => 'FLOW3', 'bar' => 'Fluid');
71  $this->viewHelper->render($values, 'innerVariable');
72  $this->viewHelper->render($values, 'innerVariable');
73  $this->viewHelper->render($values, 'innerVariable');
74  }
75 
81  $object = new \stdClass();
82 
83  $this->viewHelper->render($object, 'innerVariable');
84  }
85 
90  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('Child nodes'));
91 
92  $this->assertEquals('Child nodes', $this->viewHelper->render(NULL, 'foo'));
93  }
94 
99  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('foo', NULL);
100  $this->templateVariableContainer->expects($this->at(1))->method('remove')->with('foo');
101 
102  $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue('Child nodes'));
103 
104  $this->assertEquals('Child nodes', $this->viewHelper->render(array(), 'foo'));
105  }
106 
111  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('innerVariable', 'value1');
112  $this->templateVariableContainer->expects($this->at(1))->method('remove')->with('innerVariable');
113  $this->templateVariableContainer->expects($this->at(2))->method('add')->with('innerVariable', 'value2');
114  $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('innerVariable');
115  $this->templateVariableContainer->expects($this->at(4))->method('add')->with('innerVariable', 'value1');
116  $this->templateVariableContainer->expects($this->at(5))->method('remove')->with('innerVariable');
117 
118  $traversableObject = new \ArrayObject(array('key1' => 'value1', 'key2' => 'value2'));
119  $this->viewHelper->render($traversableObject, 'innerVariable');
120  $this->viewHelper->render($traversableObject, 'innerVariable');
121  $this->viewHelper->render($traversableObject, 'innerVariable');
122  }
123 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)