TYPO3 CMS  TYPO3_6-2
AliasViewHelperTest.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 
23  $viewHelper = new \TYPO3\CMS\Fluid\ViewHelpers\AliasViewHelper();
24 
25  $mockViewHelperNode = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', array('evaluateChildNodes'), array(), '', FALSE);
26  $mockViewHelperNode->expects($this->once())->method('evaluateChildNodes')->will($this->returnValue('foo'));
27 
28  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('someAlias', 'someValue');
29  $this->templateVariableContainer->expects($this->at(1))->method('remove')->with('someAlias');
30 
31  $this->injectDependenciesIntoViewHelper($viewHelper);
32  $viewHelper->setViewHelperNode($mockViewHelperNode);
33  $viewHelper->render(array('someAlias' => 'someValue'));
34  }
35 
40  $viewHelper = new \TYPO3\CMS\Fluid\ViewHelpers\AliasViewHelper();
41 
42  $mockViewHelperNode = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', array('evaluateChildNodes'), array(), '', FALSE);
43  $mockViewHelperNode->expects($this->once())->method('evaluateChildNodes')->will($this->returnValue('foo'));
44 
45  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('someAlias', 'someValue');
46  $this->templateVariableContainer->expects($this->at(1))->method('add')->with('someOtherAlias', 'someOtherValue');
47  $this->templateVariableContainer->expects($this->at(2))->method('remove')->with('someAlias');
48  $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('someOtherAlias');
49 
50  $this->injectDependenciesIntoViewHelper($viewHelper);
51  $viewHelper->setViewHelperNode($mockViewHelperNode);
52  $viewHelper->render(array('someAlias' => 'someValue', 'someOtherAlias' => 'someOtherValue'));
53  }
54 
59  $viewHelper = new \TYPO3\CMS\Fluid\ViewHelpers\AliasViewHelper();
60 
61  $mockViewHelperNode = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\Parser\\SyntaxTree\\ViewHelperNode', array('evaluateChildNodes'), array(), '', FALSE);
62  $mockViewHelperNode->expects($this->once())->method('evaluateChildNodes')->will($this->returnValue('foo'));
63 
64  $this->templateVariableContainer->expects($this->never())->method('add');
65  $this->templateVariableContainer->expects($this->never())->method('remove');
66 
67  $this->injectDependenciesIntoViewHelper($viewHelper);
68  $viewHelper->setViewHelperNode($mockViewHelperNode);
69 
70  $this->assertEquals('foo', $viewHelper->render(array()));
71  }
72 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)