Raised Extbase and Fluid to version 1.3.0
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / ViewHelpers / RenderViewHelperTest.php
1 <?php
2
3 /* *
4 * This script belongs to the FLOW3 package "Fluid". *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 require_once(dirname(__FILE__) . '/ViewHelperBaseTestcase.php');
24
25 /**
26 * Testcase for RenderViewHelper
27 *
28 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
29 */
30 class Tx_Fluid_Tests_Unit_ViewHelpers_RenderViewHelperTest extends Tx_Fluid_ViewHelpers_ViewHelperBaseTestcase {
31
32 /**
33 * var Tx_Fluid_ViewHelpers_RenderViewHelper
34 */
35 protected $viewHelper;
36
37 /**
38 * var Tx_Fluid_Core_ViewHelper_Arguments
39 */
40 protected $mockArguments;
41
42 public function setUp() {
43 parent::setUp();
44 $this->templateVariableContainer = new Tx_Fluid_Core_ViewHelper_TemplateVariableContainer();
45 $this->viewHelper = $this->getAccessibleMock('Tx_Fluid_ViewHelpers_RenderViewHelper', array('dummy'));
46 $this->injectDependenciesIntoViewHelper($this->viewHelper);
47 }
48
49 /**
50 * @test
51 * @author Sebastian Kurfürst <sebastian@typo3.org>
52 */
53 public function loadSettingsIntoArgumentsSetsSettingsIfNoSettingsAreSpecified() {
54 $arguments = array(
55 'someArgument' => 'someValue'
56 );
57 $expected = array(
58 'someArgument' => 'someValue',
59 'settings' => 'theSettings'
60 );
61 $this->templateVariableContainer->add('settings', 'theSettings');
62
63 $actual = $this->viewHelper->_call('loadSettingsIntoArguments', $arguments);
64 $this->assertEquals($expected, $actual);
65 }
66
67 /**
68 * @test
69 * @author Sebastian Kurfürst <sebastian@typo3.org>
70 */
71 public function loadSettingsIntoArgumentsDoesNotOverrideGivenSettings() {
72 $arguments = array(
73 'someArgument' => 'someValue',
74 'settings' => 'specifiedSettings'
75 );
76 $expected = array(
77 'someArgument' => 'someValue',
78 'settings' => 'specifiedSettings'
79 );
80 $this->templateVariableContainer->add('settings', 'theSettings');
81
82 $actual = $this->viewHelper->_call('loadSettingsIntoArguments', $arguments);
83 $this->assertEquals($expected, $actual);
84 }
85
86 /**
87 * @test
88 * @author Sebastian Kurfürst <sebastian@typo3.org>
89 */
90 public function loadSettingsIntoArgumentsDoesNotThrowExceptionIfSettingsAreNotInTemplateVariableContainer() {
91 $arguments = array(
92 'someArgument' => 'someValue'
93 );
94 $expected = array(
95 'someArgument' => 'someValue'
96 );
97
98 $actual = $this->viewHelper->_call('loadSettingsIntoArguments', $arguments);
99 $this->assertEquals($expected, $actual);
100 }
101
102
103 }
104
105 ?>