[+BUGFIX] Extbase (Utility): Fixed TypoScript array conversion by now using _typoScri...
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Utility / TypoScript_testcase.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009 Christian M´┐Żller <christian@kitsunet.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 /**
27 * Testcase for class Tx_Extbase_Utility_TypoScript
28 *
29 * @package Extbase
30 * @subpackage extbase
31 */
32
33 class Tx_Extbase_Utility_TypoScript_testcase extends tx_phpunit_testcase {
34
35 /**
36 * @test
37 */
38 public function convertTypoScriptArrayToPlainArrayRemovesTrailingDots() {
39 $typoScriptSettings = array(
40 '10' => 'TEXT',
41 '10.' => array(
42 'value' => 'Hello World!',
43 'foo.' => array(
44 'bar' => 5,
45 ),
46 ),
47 );
48 $expectedSettings = array(
49 '10' => array(
50 'value' => 'Hello World!',
51 'foo' => array(
52 'bar' => 5,
53 ),
54 '_typoScriptNodeValue' => 'TEXT',
55 ),
56 );
57 $processedSettings = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($typoScriptSettings);
58
59 $this->assertEquals($expectedSettings, $processedSettings);
60 }
61
62 /**
63 * @test
64 */
65 public function convertTypoScriptArrayToPlainArrayRemovesTrailingDotsWithChangedOrderInTheTypoScriptArray() {
66 $typoScriptSettings = array(
67 '10.' => array(
68 'value' => 'Hello World!',
69 'foo.' => array(
70 'bar' => 5,
71 ),
72 ),
73 '10' => 'TEXT', // This line was moved down
74 );
75 $expectedSettings = array(
76 '10' => array(
77 'value' => 'Hello World!',
78 'foo' => array(
79 'bar' => 5,
80 ),
81 '_typoScriptNodeValue' => 'TEXT',
82 ),
83 );
84 $processedSettings = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($typoScriptSettings);
85
86 $this->assertEquals($expectedSettings, $processedSettings);
87 }
88
89 /**
90 * @test
91 */
92 public function convertPlainArrayToTypoScriptArrayAddsNodeValueAndTrailingDots() {
93 $extbaseTS = array(
94 '10' => array(
95 'value' => 'Hallo',
96 '_typoScriptNodeValue' => 'TEXT'
97 )
98 );
99
100 $classic = array(
101 '10' => 'TEXT',
102 '10.' => array(
103 'value' => 'Hallo'
104 )
105 );
106
107 $converted = Tx_Extbase_Utility_TypoScript::convertPlainArrayToTypoScriptArray($extbaseTS);
108
109 $this->assertEquals($converted, $classic);
110 }
111 }
112 ?>