|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009-2011 Oliver Hader <oliver@typo3.org> 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 * Testcase for the "tslib_cObj" class in the TYPO3 Core. 00027 * 00028 * @package TYPO3 00029 * @subpackage tslib 00030 * 00031 * @author Oliver Hader <oliver@typo3.org> 00032 * @author Oliver Klee <typo3-coding@oliverklee.de> 00033 */ 00034 class tslib_contentTest extends tx_phpunit_testcase { 00035 /** 00036 * @var array 00037 */ 00038 private $backupGlobalVariables; 00039 00040 /** 00041 * @var tslib_cObj 00042 */ 00043 private $cObj; 00044 00045 /** 00046 * @var tslib_fe 00047 */ 00048 private $tsfe; 00049 00050 /** 00051 * @var t3lib_TStemplate 00052 */ 00053 private $template; 00054 00055 /** 00056 * @var array 00057 */ 00058 private $typoScriptImage; 00059 00060 public function setUp() { 00061 $this->backupGlobalVariables = array( 00062 '_GET' => $_GET, 00063 '_POST' => $_POST, 00064 '_SERVER' => $_SERVER, 00065 'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS'], 00066 ); 00067 00068 $this->template = $this->getMock( 00069 't3lib_TStemplate', array('getFileName', 'linkData') 00070 ); 00071 $this->tsfe = $this->getMock('tslib_fe', array(), array(), '', false); 00072 $this->tsfe->tmpl = $this->template; 00073 $this->tsfe->config = array(); 00074 $GLOBALS['TSFE'] = $this->tsfe; 00075 $GLOBALS['TSFE']->csConvObj = new t3lib_cs(); 00076 $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'mbstring'; 00077 00078 $className = 'tslib_cObj_' . uniqid('test'); 00079 eval(' 00080 class ' . $className . ' extends tslib_cObj { 00081 public $stdWrapHookObjects = array(); 00082 public $getImgResourceHookObjects; 00083 } 00084 '); 00085 00086 $this->cObj = new $className(); 00087 $this->cObj->start(array(), 'tt_content'); 00088 00089 $this->typoScriptImage = array( 00090 'file' => 'typo3/clear.gif', 00091 ); 00092 } 00093 00094 public function tearDown() { 00095 foreach ($this->backupGlobalVariables as $key => $data) { 00096 $GLOBALS[$key] = $data; 00097 } 00098 00099 $GLOBALS['TSFE'] = null; 00100 00101 unset($this->cObj, $this->tsfe, $this->template, $this->typoScriptImage); 00102 } 00103 00104 00105 //////////////////////// 00106 // Utitility functions 00107 //////////////////////// 00108 00109 /** 00110 * Converts the subject and the expected result into the target charset. 00111 * 00112 * @param string $charset the target charset 00113 * @param string $subject the subject, will be modified 00114 * @param string $expected the expected result, will be modified 00115 */ 00116 protected function handleCharset($charset, &$subject, &$expected) { 00117 $GLOBALS['TSFE']->renderCharset = $charset; 00118 $subject = $GLOBALS['TSFE']->csConvObj->conv($subject, 'iso-8859-1', $charset); 00119 $expected = $GLOBALS['TSFE']->csConvObj->conv($expected, 'iso-8859-1', $charset); 00120 } 00121 00122 00123 ///////////////////////////////////////////// 00124 // Tests concerning the getImgResource hook 00125 ///////////////////////////////////////////// 00126 00127 /** 00128 * @test 00129 */ 00130 public function getImgResourceHookGetsCalled() { 00131 $this->template->expects($this->atLeastOnce())->method('getFileName') 00132 ->with('typo3/clear.gif')->will($this->returnValue('typo3/clear.gif')); 00133 00134 $className = uniqid('tx_coretest'); 00135 $getImgResourceHookMock = $this->getMock( 00136 'tslib_cObj_getImgResourceHook', 00137 array('getImgResourcePostProcess'), 00138 array(), 00139 $className 00140 ); 00141 00142 $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess') 00143 ->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback'))); 00144 $this->cObj->getImgResourceHookObjects = array($getImgResourceHookMock); 00145 00146 $this->cObj->IMAGE($this->typoScriptImage); 00147 } 00148 00149 /** 00150 * Handles the arguments that have been sent to the getImgResource hook. 00151 * 00152 * @return array 00153 * 00154 * @see getImgResourceHookGetsCalled 00155 */ 00156 public function isGetImgResourceHookCalledCallback() { 00157 list($file, $fileArray, $imageResource, $parent) = func_get_args(); 00158 00159 $this->assertEquals('typo3/clear.gif', $file); 00160 $this->assertEquals('typo3/clear.gif', $imageResource['origFile']); 00161 $this->assertTrue(is_array($fileArray)); 00162 $this->assertTrue($parent instanceof tslib_cObj); 00163 00164 return $imageResource; 00165 } 00166 00167 00168 ////////////////////////// 00169 // Tests concerning FORM 00170 ////////////////////////// 00171 00172 /** 00173 * @test 00174 */ 00175 public function formWithSecureFormMailEnabledDoesNotContainRecipientField() { 00176 $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'] = TRUE; 00177 00178 $this->assertNotContains( 00179 'name="recipient', 00180 $this->cObj->FORM( 00181 array('recipient' => 'foo@bar.com', 'recipient.' => array()), 00182 array() 00183 ) 00184 ); 00185 } 00186 00187 /** 00188 * @test 00189 */ 00190 public function formWithSecureFormMailDisabledDoesNotContainRecipientField() { 00191 $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'] = FALSE; 00192 00193 $this->assertContains( 00194 'name="recipient', 00195 $this->cObj->FORM( 00196 array('recipient' => 'foo@bar.com', 'recipient.' => array()), 00197 array() 00198 ) 00199 ); 00200 } 00201 00202 00203 ///////////////////////////////////////// 00204 // Tests concerning getQueryArguments() 00205 ///////////////////////////////////////// 00206 00207 /** 00208 * @test 00209 */ 00210 public function getQueryArgumentsExcludesParameters() { 00211 $_SERVER['QUERY_STRING'] = 00212 'key1=value1' . 00213 '&key2=value2' . 00214 '&key3[key31]=value31' . 00215 '&key3[key32][key321]=value321' . 00216 '&key3[key32][key322]=value322'; 00217 00218 $getQueryArgumentsConfiguration = array(); 00219 $getQueryArgumentsConfiguration['exclude'] = array(); 00220 $getQueryArgumentsConfiguration['exclude'][] = 'key1'; 00221 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]'; 00222 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]'; 00223 $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']); 00224 00225 $expectedResult = '&key2=value2&key3[key32][key322]=value322'; 00226 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration); 00227 $this->assertEquals($expectedResult, $actualResult); 00228 } 00229 00230 /** 00231 * @test 00232 */ 00233 public function getQueryArgumentsExcludesGetParameters() { 00234 $_GET = array( 00235 'key1' => 'value1', 00236 'key2' => 'value2', 00237 'key3' => array( 00238 'key31' => 'value31', 00239 'key32' => array( 00240 'key321' => 'value321', 00241 'key322' => 'value322', 00242 ), 00243 ), 00244 ); 00245 00246 $getQueryArgumentsConfiguration = array(); 00247 $getQueryArgumentsConfiguration['method'] = 'GET'; 00248 $getQueryArgumentsConfiguration['exclude'] = array(); 00249 $getQueryArgumentsConfiguration['exclude'][] = 'key1'; 00250 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]'; 00251 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]'; 00252 $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']); 00253 00254 $expectedResult = '&key2=value2&key3[key32][key322]=value322'; 00255 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration); 00256 $this->assertEquals($expectedResult, $actualResult); 00257 } 00258 00259 /** 00260 * @test 00261 */ 00262 public function getQueryArgumentsOverrulesSingleParameter() { 00263 $_SERVER['QUERY_STRING'] = 'key1=value1'; 00264 00265 $getQueryArgumentsConfiguration = array(); 00266 00267 $overruleArguments = array( 00268 // Should be overriden 00269 'key1' => 'value1Overruled', 00270 // Shouldn't be set: Parameter doesn't exist in source array and is not forced 00271 'key2' => 'value2Overruled', 00272 ); 00273 00274 $expectedResult = '&key1=value1Overruled'; 00275 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments); 00276 $this->assertEquals($expectedResult, $actualResult); 00277 } 00278 00279 /** 00280 * @test 00281 */ 00282 public function getQueryArgumentsOverrulesMultiDimensionalParameters() { 00283 $_POST = array( 00284 'key1' => 'value1', 00285 'key2' => 'value2', 00286 'key3' => array( 00287 'key31' => 'value31', 00288 'key32' => array( 00289 'key321' => 'value321', 00290 'key322' => 'value322', 00291 ), 00292 ), 00293 ); 00294 00295 $getQueryArgumentsConfiguration = array(); 00296 $getQueryArgumentsConfiguration['method'] = 'POST'; 00297 $getQueryArgumentsConfiguration['exclude'] = array(); 00298 $getQueryArgumentsConfiguration['exclude'][] = 'key1'; 00299 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]'; 00300 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]'; 00301 $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']); 00302 00303 $overruleArguments = array( 00304 // Should be overriden 00305 'key2' => 'value2Overruled', 00306 'key3' => array( 00307 'key32' => array( 00308 // Shouldn't be set: Parameter is excluded and not forced 00309 'key321' => 'value321Overruled', 00310 // Should be overriden: Parameter is not excluded 00311 'key322' => 'value322Overruled', 00312 // Shouldn't be set: Parameter doesn't exist in source array and is not forced 00313 'key323' => 'value323Overruled', 00314 ), 00315 ), 00316 ); 00317 00318 $expectedResult = '&key2=value2Overruled&key3[key32][key322]=value322Overruled'; 00319 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments); 00320 $this->assertEquals($expectedResult, $actualResult); 00321 } 00322 00323 /** 00324 * @test 00325 */ 00326 public function getQueryArgumentsOverrulesMultiDimensionalForcedParameters() { 00327 $_SERVER['QUERY_STRING'] = 00328 'key1=value1' . 00329 '&key2=value2' . 00330 '&key3[key31]=value31' . 00331 '&key3[key32][key321]=value321' . 00332 '&key3[key32][key322]=value322'; 00333 00334 $_POST = array( 00335 'key1' => 'value1', 00336 'key2' => 'value2', 00337 'key3' => array( 00338 'key31' => 'value31', 00339 'key32' => array( 00340 'key321' => 'value321', 00341 'key322' => 'value322', 00342 ), 00343 ), 00344 ); 00345 00346 $getQueryArgumentsConfiguration = array(); 00347 $getQueryArgumentsConfiguration['exclude'] = array(); 00348 $getQueryArgumentsConfiguration['exclude'][] = 'key1'; 00349 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]'; 00350 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]'; 00351 $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key322]'; 00352 $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']); 00353 00354 $overruleArguments = array( 00355 // Should be overriden 00356 'key2' => 'value2Overruled', 00357 'key3' => array( 00358 'key32' => array( 00359 // Should be set: Parameter is excluded but forced 00360 'key321' => 'value321Overruled', 00361 // Should be set: Parameter doesn't exist in source array but is forced 00362 'key323' => 'value323Overruled', 00363 ), 00364 ), 00365 ); 00366 00367 $expectedResult = '&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled'; 00368 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE); 00369 $this->assertEquals($expectedResult, $actualResult); 00370 00371 $getQueryArgumentsConfiguration['method'] = 'POST'; 00372 $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE); 00373 $this->assertEquals($expectedResult, $actualResult); 00374 } 00375 00376 00377 ////////////////////////////// 00378 // Tests concerning crop 00379 ////////////////////////////// 00380 00381 /** 00382 * @test 00383 */ 00384 public function cropIsMultibyteSafe() { 00385 $this->assertEquals('бла', $this->cObj->crop('бла', '3|...')); 00386 } 00387 00388 ////////////////////////////// 00389 // Tests concerning cropHTML 00390 ////////////////////////////// 00391 00392 /** 00393 * This is the data provider for the tests of crop and cropHTML below. It provides all combinations 00394 * of charset, text type, and configuration options to be tested. 00395 * 00396 * @return array two-dimensional array with the second level like this: 00397 * 0 => the settings for the crop function, for example "-58|..." 00398 * 1 => the string to crop 00399 * 2 => the expected cropped result 00400 * 3 => the charset that will be set as renderCharset 00401 * 00402 * @see cropHtmlWithDataProvider 00403 */ 00404 public function cropHtmlDataProvider() { 00405 $plainText = 'Kasper Sk' . chr(229) . 'rh' . chr(248) . 00406 'j implemented the original version of the crop function.'; 00407 $textWithMarkup = '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . 00408 chr(229) . 'rh' . chr(248) . 'j</a>' . 00409 ' implemented</strong> the original version of the crop function.'; 00410 $textWithEntities = 'Kasper Skårhøj implemented the; original ' . 00411 'version of the crop function.'; 00412 00413 $charsets = array('iso-8859-1', 'utf-8', 'ascii', 'big5'); 00414 00415 $data = array(); 00416 foreach ($charsets as $charset) { 00417 $data = array_merge($data, array( 00418 $charset . ' plain text; 11|...' => array( 00419 '11|...', $plainText, 'Kasper Sk' . chr(229) . 'r...', $charset 00420 ), 00421 $charset . ' plain text; -58|...' => array( 00422 '-58|...', $plainText, '...h' . chr(248) . 'j implemented the original version of the crop function.', $charset 00423 ), 00424 $charset . ' plain text; 20|...|1' => array( 00425 '20|...|1', $plainText, 'Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j...', $charset 00426 ), 00427 $charset . ' plain text; -49|...|1' => array( 00428 '-49|...|1', $plainText, '...the original version of the crop function.', $charset 00429 ), 00430 $charset . ' text with markup; 11|...' => array( 00431 '11|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'r...</a></strong>', $charset 00432 ), 00433 $charset . ' text with markup; 13|...' => array( 00434 '13|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . '...</a></strong>', $charset 00435 ), 00436 $charset . ' text with markup; 14|...' => array( 00437 '14|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset 00438 ), 00439 $charset . ' text with markup; 15|...' => array( 00440 '15|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> ...</strong>', $charset 00441 ), 00442 $charset . ' text with markup; 29|...' => array( 00443 '29|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong> th...', $charset 00444 ), 00445 $charset . ' text with markup; -58|...' => array( 00446 '-58|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">...h' . chr(248) . 'j</a> implemented</strong> the original version of the crop function.', $charset 00447 ), 00448 $charset . ' text with markup; 11|...|1' => array( 00449 '11|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>', $charset 00450 ), 00451 $charset . ' text with markup; 13|...|1' => array( 00452 '13|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>', $charset 00453 ), 00454 $charset . ' text with markup; 14|...|1' => array( 00455 '14|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset 00456 ), 00457 $charset . ' text with markup; 15|...|1' => array( 00458 '15|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset 00459 ), 00460 $charset . ' text with markup; 29|...|1' => array( 00461 '29|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong>...', $charset 00462 ), 00463 $charset . ' text with markup; -66|...|1' => array( 00464 '-66|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">...Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong> the original version of the crop function.', $charset 00465 ), 00466 $charset . ' text with entities 9|...' => array( 00467 '9|...', $textWithEntities, 'Kasper Sk...', $charset 00468 ), 00469 $charset . ' text with entities 10|...' => array( 00470 '10|...', $textWithEntities, 'Kasper Skå...', $charset 00471 ), 00472 $charset . ' text with entities 11|...' => array( 00473 '11|...', $textWithEntities, 'Kasper Skår...', $charset 00474 ), 00475 $charset . ' text with entities 13|...' => array( 00476 '13|...', $textWithEntities, 'Kasper Skårhø...', $charset 00477 ), 00478 $charset . ' text with entities 14|...' => array( 00479 '14|...', $textWithEntities, 'Kasper Skårhøj...', $charset 00480 ), 00481 $charset . ' text with entities 15|...' => array( 00482 '15|...', $textWithEntities, 'Kasper Skårhøj ...', $charset 00483 ), 00484 $charset . ' text with entities 16|...' => array( 00485 '16|...', $textWithEntities, 'Kasper Skårhøj i...', $charset 00486 ), 00487 $charset . ' text with entities -57|...' => array( 00488 '-57|...', $textWithEntities, '...j implemented the; original version of the crop function.', $charset 00489 ), 00490 $charset . ' text with entities -58|...' => array( 00491 '-58|...', $textWithEntities, '...øj implemented the; original version of the crop function.', $charset 00492 ), 00493 $charset . ' text with entities -59|...' => array( 00494 '-59|...', $textWithEntities, '...høj implemented the; original version of the crop function.', $charset 00495 ), 00496 $charset . ' text with entities 9|...|1' => array( 00497 '9|...|1', $textWithEntities, 'Kasper...', $charset 00498 ), 00499 $charset . ' text with entities 10|...|1' => array( 00500 '10|...|1', $textWithEntities, 'Kasper...', $charset 00501 ), 00502 $charset . ' text with entities 11|...|1' => array( 00503 '11|...|1', $textWithEntities, 'Kasper...', $charset 00504 ), 00505 $charset . ' text with entities 13|...|1' => array( 00506 '13|...|1', $textWithEntities, 'Kasper...', $charset 00507 ), 00508 $charset . ' text with entities 14|...|1' => array( 00509 '14|...|1', $textWithEntities, 'Kasper Skårhøj...', $charset 00510 ), 00511 $charset . ' text with entities 15|...|1' => array( 00512 '15|...|1', $textWithEntities, 'Kasper Skårhøj...', $charset 00513 ), 00514 $charset . ' text with entities 16|...|1' => array( 00515 '16|...|1', $textWithEntities, 'Kasper Skårhøj...', $charset 00516 ), 00517 $charset . ' text with entities -57|...|1' => array( 00518 '-57|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset 00519 ), 00520 $charset . ' text with entities -58|...|1' => array( 00521 '-58|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset 00522 ), 00523 $charset . ' text with entities -59|...|1' => array( 00524 '-59|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset 00525 ), 00526 )); 00527 } 00528 return $data; 00529 } 00530 00531 /** 00532 * Checks if stdWrap.cropHTML works with plain text cropping from left 00533 * 00534 * @test 00535 * 00536 * @dataProvider cropHtmlDataProvider 00537 * 00538 * @param string $settings 00539 * the settings for the crop function, for example "-58|..." 00540 * @param string $subject the string to crop 00541 * @param string $expected the expected cropped result 00542 * @param string $charset the charset that will be set as renderCharset 00543 */ 00544 public function cropHtmlWithDataProvider($settings, $subject, $expected, $charset) { 00545 $this->handleCharset($charset, $subject, $expected); 00546 00547 $this->assertEquals( 00548 $expected, 00549 $this->cObj->cropHTML($subject, $settings), 00550 'cropHTML failed with settings: "' . $settings . '" and charset "' . $charset . '"' 00551 ); 00552 } 00553 00554 /** 00555 * Checks if stdWrap.cropHTML works with a complex content with many tags. Currently cropHTML 00556 * counts multiple invisible characters not as one (as the browser will output the content). 00557 * 00558 * @test 00559 */ 00560 public function cropHtmlWorksWithComplexContent() { 00561 $GLOBALS['TSFE']->renderCharset = 'iso-8859-1'; 00562 $subject = ' 00563 <h1>Blog Example</h1> 00564 <hr> 00565 <div class="csc-header csc-header-n1"> 00566 <h2 class="csc-firstHeader">Welcome to Blog #1</h2> 00567 </div> 00568 <p class="bodytext"> 00569 A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>. 00570 </p> 00571 <div class="tx-blogexample-list-container"> 00572 <p class="bodytext"> 00573 Below are the most recent posts: 00574 </p> 00575 <ul> 00576 <li> 00577 <h3> 00578 <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog]=&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=003b0131ed">The Post #1</a> 00579 </h3> 00580 <p class="bodytext"> 00581 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut... 00582 </p> 00583 <p class="metadata"> 00584 Published on 26.08.2009 by Jochen Rau 00585 </p> 00586 <p> 00587 Tags: [MVC] [Domain Driven Design] <br> 00588 <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=f982643bc3">read more >></a><br> 00589 <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=edit&tx_blogexample_pi1[controller]=Post&cHash=5b481bc8f0">Edit</a> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=delete&tx_blogexample_pi1[controller]=Post&cHash=4e52879656">Delete</a> 00590 </p> 00591 </li> 00592 </ul> 00593 <p> 00594 <a href="index.php?id=99&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=new&tx_blogexample_pi1[controller]=Post&cHash=2718a4b1a0">Create a new Post</a> 00595 </p> 00596 </div> 00597 <hr> 00598 <p> 00599 ? TYPO3 Association 00600 </p> 00601 '; 00602 00603 $result = $this->cObj->cropHTML($subject, '300'); 00604 $expected = ' 00605 <h1>Blog Example</h1> 00606 <hr> 00607 <div class="csc-header csc-header-n1"> 00608 <h2 class="csc-firstHeader">Welcome to Blog #1</h2> 00609 </div> 00610 <p class="bodytext"> 00611 A blog about TYPO3 extension development. In order to start blogging, read the <a href="#">Help section</a>. If you have any further questions, feel free to contact the administrator John Doe (<a href="mailto:john.doe@example.com">john.doe@example.com)</a>. 00612 </p> 00613 <div class="tx-blogexample-list-container"> 00614 <p class="bodytext"> 00615 Below are the most recent posts: 00616 </p> 00617 <ul> 00618 <li> 00619 <h3> 00620 <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog]=&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=003b0131ed">The Pos</a></h3></li></ul></div>'; 00621 $this->assertEquals($expected, $result); 00622 00623 $result = $this->cObj->cropHTML($subject, '-100'); 00624 $expected = '<div class="tx-blogexample-list-container"><ul><li><p>Design] <br> 00625 <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[action]=show&tx_blogexample_pi1[controller]=Post&cHash=f982643bc3">read more >></a><br> 00626 <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=edit&tx_blogexample_pi1[controller]=Post&cHash=5b481bc8f0">Edit</a> <a href="index.php?id=99&tx_blogexample_pi1[post][uid]=211&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=delete&tx_blogexample_pi1[controller]=Post&cHash=4e52879656">Delete</a> 00627 </p> 00628 </li> 00629 </ul> 00630 <p> 00631 <a href="index.php?id=99&tx_blogexample_pi1[blog][uid]=70&tx_blogexample_pi1[action]=new&tx_blogexample_pi1[controller]=Post&cHash=2718a4b1a0">Create a new Post</a> 00632 </p> 00633 </div> 00634 <hr> 00635 <p> 00636 ? TYPO3 Association 00637 </p> 00638 '; 00639 $this->assertEquals( 00640 $expected, 00641 $result 00642 ); 00643 } 00644 00645 /** 00646 * Data provider for the numberFormat test 00647 * 00648 * @return array multi-dimensional array with the second level like this: 00649 * 0 => the input float number 00650 * 1 => the conf array for the numberFormat stdWrap function 00651 * 2 => the expected result 00652 * 00653 * @see numberFormat 00654 */ 00655 public function numberFormatDataProvider() { 00656 $data = array( 00657 'testing decimals' => array( 00658 0.8, 00659 array( 00660 'decimals' => 2 00661 ), 00662 '0.80' 00663 ), 00664 'testing dec_point' => array( 00665 0.8, 00666 array( 00667 'decimals' => 1, 00668 'dec_point' => ',' 00669 ), 00670 '0,8' 00671 ), 00672 'testing thousands_sep' => array( 00673 999.99, 00674 array( 00675 'decimals' => 0, 00676 'thousands_sep.' => array( 00677 'char' => 46 00678 ) 00679 ), 00680 '1.000' 00681 ), 00682 'testing mixture' => array( 00683 1281731.45, 00684 array( 00685 'decimals' => 1, 00686 'dec_point.' => array( 00687 'char' => 44 00688 ), 00689 'thousands_sep.' => array( 00690 'char' => 46 00691 ) 00692 ), 00693 '1.281.731,5' 00694 ) 00695 ); 00696 return $data; 00697 } 00698 00699 /** 00700 * Check if stdWrap.numberFormat and all of its properties work properly 00701 * 00702 * @dataProvider numberFormatDataProvider 00703 * 00704 * @test 00705 */ 00706 public function numberFormat($float, $formatConf, $expected) { 00707 $result = $this->cObj->numberFormat($float, $formatConf); 00708 $this->assertEquals($expected, $result); 00709 } 00710 } 00711 ?>
1.8.0