TYPO3 CMS  TYPO3_7-6
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 
15 
20 {
24  protected $subject;
25 
26  protected function setUp()
27  {
28  parent::setUp();
29  $this->subject = $this->getMock(AliasViewHelper::class, ['renderChildren']);
30  $this->injectDependenciesIntoViewHelper($this->subject);
31  }
32 
37  {
38  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('someAlias', 'someValue');
39  $this->templateVariableContainer->expects($this->at(1))->method('remove')->with('someAlias');
40  $this->subject->render(['someAlias' => 'someValue']);
41  }
42 
47  {
48  $this->templateVariableContainer->expects($this->at(0))->method('add')->with('someAlias', 'someValue');
49  $this->templateVariableContainer->expects($this->at(1))->method('add')->with('someOtherAlias', 'someOtherValue');
50  $this->templateVariableContainer->expects($this->at(2))->method('remove')->with('someAlias');
51  $this->templateVariableContainer->expects($this->at(3))->method('remove')->with('someOtherAlias');
52  $this->subject->render(['someAlias' => 'someValue', 'someOtherAlias' => 'someOtherValue']);
53  }
54 
59  {
60  $this->subject->expects($this->once())->method('renderChildren')->will($this->returnValue('foo'));
61  $this->templateVariableContainer->expects($this->never())->method('add');
62  $this->templateVariableContainer->expects($this->never())->method('remove');
63  $this->assertEquals('foo', $this->subject->render([]));
64  }
65 }
injectDependenciesIntoViewHelper(\TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper $viewHelper)