|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009 Christian Müller <christian@kitsunet.de> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 00026 /** 00027 * Testcase for class Tx_Extbase_Utility_TypoScript 00028 * 00029 * @package Extbase 00030 * @subpackage extbase 00031 */ 00032 00033 class Tx_Extbase_Tests_Unit_Utility_TypoScriptTest extends tx_phpunit_testcase { 00034 00035 /** 00036 * @return array 00037 */ 00038 public function convertTypoScriptArrayToPlainArrayTestdata(){ 00039 $testdata = array(); 00040 //convert TypoScript Array To Plain Array Removes Trailing Dots 00041 $testdata[0] = array( 00042 'typoScriptSettings' => array( 00043 '10.' => array( 00044 'value' => 'Hello World!', 00045 'foo.' => array( 00046 'bar' => 5, 00047 ), 00048 ), 00049 '10' => 'TEXT', // This line was moved down 00050 ), 00051 'expectedSettings' => array( 00052 '10' => array( 00053 'value' => 'Hello World!', 00054 'foo' => array( 00055 'bar' => 5, 00056 ), 00057 '_typoScriptNodeValue' => 'TEXT', 00058 ), 00059 ) 00060 ); 00061 00062 //convert TypoScript Array To Plain Array Removes Trailing Dots With Changed Order In The TypoScript Array 00063 $testdata[1] = array( 00064 'typoScriptSettings' => array( 00065 '10' => 'TEXT', 00066 '10.' => array( 00067 'value' => 'Hello World!', 00068 'foo.' => array( 00069 'bar' => 5, 00070 ), 00071 ), 00072 ), 00073 'expectedSettings' => array( 00074 '10' => array( 00075 'value' => 'Hello World!', 00076 'foo' => array( 00077 'bar' => 5, 00078 ), 00079 '_typoScriptNodeValue' => 'TEXT', 00080 ), 00081 ) 00082 ); 00083 00084 $testdata[2] = array( 00085 'typoScriptSettings' => array( 00086 '10' => 'COA', 00087 '10.' => array( 00088 '10' => 'TEXT', 00089 '10.' => array( 00090 'value' => 'Hello World!', 00091 'foo.' => array( 00092 'bar' => 5, 00093 ) 00094 ), 00095 '20' => 'COA', 00096 '20.' => array( 00097 '10' => 'TEXT', 00098 '10.' => array( 00099 'value' => 'Test', 00100 'wrap' => '[|]' 00101 ), 00102 '20' => 'TEXT', 00103 '20.' => array( 00104 'value' => 'Test', 00105 'wrap' => '[|]' 00106 ) 00107 ), 00108 '30' => 'custom' 00109 ), 00110 ), 00111 'expectedSettings' => array( 00112 '10' => array( 00113 '10' => array( 00114 'value' => 'Hello World!', 00115 'foo' => array( 00116 'bar' => 5, 00117 ), 00118 '_typoScriptNodeValue' => 'TEXT' 00119 ), 00120 '20' => array( 00121 '10' => array( 00122 'value' => 'Test', 00123 'wrap' => '[|]', 00124 '_typoScriptNodeValue' => 'TEXT', 00125 ), 00126 '20' => array( 00127 'value' => 'Test', 00128 'wrap' => '[|]', 00129 '_typoScriptNodeValue' => 'TEXT', 00130 ), 00131 '_typoScriptNodeValue' => 'COA', 00132 ), 00133 '30' => 'custom', 00134 '_typoScriptNodeValue' => 'COA', 00135 ), 00136 ) 00137 ); 00138 00139 return $testdata; 00140 00141 } 00142 00143 /** 00144 * @test 00145 * @dataProvider convertTypoScriptArrayToPlainArrayTestdata 00146 */ 00147 public function convertTypoScriptArrayToPlainArrayRemovesTrailingDotsWithChangedOrderInTheTypoScriptArray($typoScriptSettings,$expectedSettings) { 00148 $processedSettings = Tx_Extbase_Utility_TypoScript::convertTypoScriptArrayToPlainArray($typoScriptSettings); 00149 $this->assertEquals($expectedSettings, $processedSettings); 00150 } 00151 00152 00153 /** 00154 * Dataprovider for testcase "convertPlainArrayToTypoScriptArray" 00155 * 00156 * @return array 00157 */ 00158 public function convertPlainArrayToTypoScriptArrayTestdata() { 00159 $testdata = array(); 00160 00161 $testdata[0] = array( 00162 'extbaseTS' => array( 00163 '10' => array( 00164 'value' => 'Hallo', 00165 '_typoScriptNodeValue' => 'TEXT' 00166 ) 00167 ), 00168 00169 'classic' => array( 00170 '10' => 'TEXT', 00171 '10.' => array( 00172 'value' => 'Hallo' 00173 ) 00174 ) 00175 ); 00176 00177 $testdata[1] = array( 00178 'extbaseTS' => array( 00179 '10' => array( 00180 '10' => array( 00181 'value' => 'Hello World!', 00182 'foo' => array( 00183 'bar' => 5, 00184 ), 00185 '_typoScriptNodeValue' => 'TEXT' 00186 ), 00187 '20' => array( 00188 '10' => array( 00189 'value' => 'Test', 00190 'wrap' => '[|]', 00191 '_typoScriptNodeValue' => 'TEXT', 00192 ), 00193 '20' => array( 00194 'value' => 'Test', 00195 'wrap' => '[|]', 00196 '_typoScriptNodeValue' => 'TEXT', 00197 ), 00198 '_typoScriptNodeValue' => 'COA', 00199 ), 00200 '_typoScriptNodeValue' => 'COA', 00201 ), 00202 ), 00203 00204 'classic' => array( 00205 '10' => 'COA', 00206 '10.' => array( 00207 '10' => 'TEXT', 00208 '10.' => array( 00209 'value' => 'Hello World!', 00210 'foo.' => array( 00211 'bar' => 5, 00212 ) 00213 ), 00214 '20' => 'COA', 00215 '20.' => array( 00216 '10' => 'TEXT', 00217 '10.' => array( 00218 'value' => 'Test', 00219 'wrap' => '[|]' 00220 ), 00221 '20' => 'TEXT', 00222 '20.' => array( 00223 'value' => 'Test', 00224 'wrap' => '[|]' 00225 ) 00226 ) 00227 ) 00228 ) 00229 ); 00230 00231 return $testdata; 00232 } 00233 00234 /** 00235 * @test 00236 * @dataProvider convertPlainArrayToTypoScriptArrayTestdata 00237 */ 00238 public function convertPlainArrayToTypoScriptArray($extbaseTS, $classic) { 00239 $converted = Tx_Extbase_Utility_TypoScript::convertPlainArrayToTypoScriptArray($extbaseTS); 00240 $this->assertEquals($converted, $classic); 00241 } 00242 } 00243 ?>
1.8.0