PageRenderTime 61ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/typo3/sysext/cms/tslib/tslib_contentTest.php

https://github.com/foxsoft/typo3v4core
PHP | 634 lines | 432 code | 63 blank | 139 comment | 0 complexity | 434e20c0d33590289c3b862595e48644 MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php
  2. /***************************************************************
  3. * Copyright notice
  4. *
  5. * (c) 2009-2010 Oliver Hader <oliver@typo3.org>
  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. * Testcase for the "tslib_cObj" class in the TYPO3 Core.
  26. *
  27. * @package TYPO3
  28. * @subpackage tslib
  29. *
  30. * @author Oliver Hader <oliver@typo3.org>
  31. * @author Oliver Klee <typo3-coding@oliverklee.de>
  32. */
  33. class tslib_contentTest extends tx_phpunit_testcase {
  34. /**
  35. * @var array
  36. */
  37. private $backupGlobalVariables;
  38. /**
  39. * @var tslib_cObj
  40. */
  41. private $cObj;
  42. /**
  43. * @var tslib_fe
  44. */
  45. private $tsfe;
  46. /**
  47. * @var t3lib_TStemplate
  48. */
  49. private $template;
  50. /**
  51. * @var array
  52. */
  53. private $typoScriptImage;
  54. public function setUp() {
  55. $this->backupGlobalVariables = array(
  56. '_GET' => $_GET,
  57. '_POST' => $_POST,
  58. '_SERVER' => $_SERVER,
  59. 'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS'],
  60. );
  61. $this->template = $this->getMock(
  62. 't3lib_TStemplate', array('getFileName', 'linkData')
  63. );
  64. $this->tsfe = $this->getMock('tslib_fe', array(), array(), '', false);
  65. $this->tsfe->tmpl = $this->template;
  66. $this->tsfe->config = array();
  67. $GLOBALS['TSFE'] = $this->tsfe;
  68. $GLOBALS['TSFE']->csConvObj = new t3lib_cs();
  69. $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'mbstring';
  70. $className = 'tslib_cObj_' . uniqid('test');
  71. eval('
  72. class ' . $className . ' extends tslib_cObj {
  73. public $stdWrapHookObjects = array();
  74. public $getImgResourceHookObjects;
  75. }
  76. ');
  77. $this->cObj = new $className();
  78. $this->cObj->start(array(), 'tt_content');
  79. $this->typoScriptImage = array(
  80. 'file' => 'typo3/clear.gif',
  81. );
  82. }
  83. public function tearDown() {
  84. foreach ($this->backupGlobalVariables as $key => $data) {
  85. $GLOBALS[$key] = $data;
  86. }
  87. $GLOBALS['TSFE'] = null;
  88. unset($this->cObj, $this->tsfe, $this->template, $this->typoScriptImage);
  89. }
  90. ////////////////////////
  91. // Utitility functions
  92. ////////////////////////
  93. /**
  94. * Converts the subject and the expected result into the target charset.
  95. *
  96. * @param string $charset the target charset
  97. * @param string $subject the subject, will be modified
  98. * @param string $expected the expected result, will be modified
  99. */
  100. protected function handleCharset($charset, &$subject, &$expected) {
  101. $GLOBALS['TSFE']->renderCharset = $charset;
  102. $subject = $GLOBALS['TSFE']->csConvObj->conv($subject, 'iso-8859-1', $charset);
  103. $expected = $GLOBALS['TSFE']->csConvObj->conv($expected, 'iso-8859-1', $charset);
  104. }
  105. /////////////////////////////////////////////
  106. // Tests concerning the getImgResource hook
  107. /////////////////////////////////////////////
  108. /**
  109. * @test
  110. */
  111. public function getImgResourceHookGetsCalled() {
  112. $this->template->expects($this->atLeastOnce())->method('getFileName')
  113. ->with('typo3/clear.gif')->will($this->returnValue('typo3/clear.gif'));
  114. $className = uniqid('tx_coretest');
  115. $getImgResourceHookMock = $this->getMock(
  116. 'tslib_cObj_getImgResourceHook',
  117. array('getImgResourcePostProcess'),
  118. array(),
  119. $className
  120. );
  121. $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess')
  122. ->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
  123. $this->cObj->getImgResourceHookObjects = array($getImgResourceHookMock);
  124. $this->cObj->IMAGE($this->typoScriptImage);
  125. }
  126. /**
  127. * Handles the arguments that have been sent to the getImgResource hook.
  128. *
  129. * @return array
  130. *
  131. * @see getImgResourceHookGetsCalled
  132. */
  133. public function isGetImgResourceHookCalledCallback() {
  134. list($file, $fileArray, $imageResource, $parent) = func_get_args();
  135. $this->assertEquals('typo3/clear.gif', $file);
  136. $this->assertEquals('typo3/clear.gif', $imageResource['origFile']);
  137. $this->assertTrue(is_array($fileArray));
  138. $this->assertTrue($parent instanceof tslib_cObj);
  139. return $imageResource;
  140. }
  141. //////////////////////////
  142. // Tests concerning FORM
  143. //////////////////////////
  144. /**
  145. * @test
  146. */
  147. public function formWithSecureFormMailEnabledDoesNotContainRecipientField() {
  148. $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'] = TRUE;
  149. $this->assertNotContains(
  150. 'name="recipient',
  151. $this->cObj->FORM(
  152. array('recipient' => 'foo@bar.com', 'recipient.' => array()),
  153. array()
  154. )
  155. );
  156. }
  157. /**
  158. * @test
  159. */
  160. public function formWithSecureFormMailDisabledDoesNotContainRecipientField() {
  161. $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'] = FALSE;
  162. $this->assertContains(
  163. 'name="recipient',
  164. $this->cObj->FORM(
  165. array('recipient' => 'foo@bar.com', 'recipient.' => array()),
  166. array()
  167. )
  168. );
  169. }
  170. /////////////////////////////////////////
  171. // Tests concerning getQueryArguments()
  172. /////////////////////////////////////////
  173. /**
  174. * @test
  175. */
  176. public function getQueryArgumentsExcludesParameters() {
  177. $_SERVER['QUERY_STRING'] =
  178. 'key1=value1' .
  179. '&key2=value2' .
  180. '&key3[key31]=value31' .
  181. '&key3[key32][key321]=value321' .
  182. '&key3[key32][key322]=value322';
  183. $getQueryArgumentsConfiguration = array();
  184. $getQueryArgumentsConfiguration['exclude'] = array();
  185. $getQueryArgumentsConfiguration['exclude'][] = 'key1';
  186. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
  187. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
  188. $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
  189. $expectedResult = '&key2=value2&key3[key32][key322]=value322';
  190. $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
  191. $this->assertEquals($expectedResult, $actualResult);
  192. }
  193. /**
  194. * @test
  195. */
  196. public function getQueryArgumentsExcludesGetParameters() {
  197. $_GET = array(
  198. 'key1' => 'value1',
  199. 'key2' => 'value2',
  200. 'key3' => array(
  201. 'key31' => 'value31',
  202. 'key32' => array(
  203. 'key321' => 'value321',
  204. 'key322' => 'value322',
  205. ),
  206. ),
  207. );
  208. $getQueryArgumentsConfiguration = array();
  209. $getQueryArgumentsConfiguration['method'] = 'GET';
  210. $getQueryArgumentsConfiguration['exclude'] = array();
  211. $getQueryArgumentsConfiguration['exclude'][] = 'key1';
  212. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
  213. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
  214. $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
  215. $expectedResult = '&key2=value2&key3[key32][key322]=value322';
  216. $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration);
  217. $this->assertEquals($expectedResult, $actualResult);
  218. }
  219. /**
  220. * @test
  221. */
  222. public function getQueryArgumentsOverrulesSingleParameter() {
  223. $_SERVER['QUERY_STRING'] = 'key1=value1';
  224. $getQueryArgumentsConfiguration = array();
  225. $overruleArguments = array(
  226. // Should be overriden
  227. 'key1' => 'value1Overruled',
  228. // Shouldn't be set: Parameter doesn't exist in source array and is not forced
  229. 'key2' => 'value2Overruled',
  230. );
  231. $expectedResult = '&key1=value1Overruled';
  232. $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
  233. $this->assertEquals($expectedResult, $actualResult);
  234. }
  235. /**
  236. * @test
  237. */
  238. public function getQueryArgumentsOverrulesMultiDimensionalParameters() {
  239. $_POST = array(
  240. 'key1' => 'value1',
  241. 'key2' => 'value2',
  242. 'key3' => array(
  243. 'key31' => 'value31',
  244. 'key32' => array(
  245. 'key321' => 'value321',
  246. 'key322' => 'value322',
  247. ),
  248. ),
  249. );
  250. $getQueryArgumentsConfiguration = array();
  251. $getQueryArgumentsConfiguration['method'] = 'POST';
  252. $getQueryArgumentsConfiguration['exclude'] = array();
  253. $getQueryArgumentsConfiguration['exclude'][] = 'key1';
  254. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
  255. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
  256. $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
  257. $overruleArguments = array(
  258. // Should be overriden
  259. 'key2' => 'value2Overruled',
  260. 'key3' => array(
  261. 'key32' => array(
  262. // Shouldn't be set: Parameter is excluded and not forced
  263. 'key321' => 'value321Overruled',
  264. // Should be overriden: Parameter is not excluded
  265. 'key322' => 'value322Overruled',
  266. // Shouldn't be set: Parameter doesn't exist in source array and is not forced
  267. 'key323' => 'value323Overruled',
  268. ),
  269. ),
  270. );
  271. $expectedResult = '&key2=value2Overruled&key3[key32][key322]=value322Overruled';
  272. $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments);
  273. $this->assertEquals($expectedResult, $actualResult);
  274. }
  275. /**
  276. * @test
  277. */
  278. public function getQueryArgumentsOverrulesMultiDimensionalForcedParameters() {
  279. $_SERVER['QUERY_STRING'] =
  280. 'key1=value1' .
  281. '&key2=value2' .
  282. '&key3[key31]=value31' .
  283. '&key3[key32][key321]=value321' .
  284. '&key3[key32][key322]=value322';
  285. $_POST = array(
  286. 'key1' => 'value1',
  287. 'key2' => 'value2',
  288. 'key3' => array(
  289. 'key31' => 'value31',
  290. 'key32' => array(
  291. 'key321' => 'value321',
  292. 'key322' => 'value322',
  293. ),
  294. ),
  295. );
  296. $getQueryArgumentsConfiguration = array();
  297. $getQueryArgumentsConfiguration['exclude'] = array();
  298. $getQueryArgumentsConfiguration['exclude'][] = 'key1';
  299. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key31]';
  300. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key321]';
  301. $getQueryArgumentsConfiguration['exclude'][] = 'key3[key32][key322]';
  302. $getQueryArgumentsConfiguration['exclude'] = implode(',', $getQueryArgumentsConfiguration['exclude']);
  303. $overruleArguments = array(
  304. // Should be overriden
  305. 'key2' => 'value2Overruled',
  306. 'key3' => array(
  307. 'key32' => array(
  308. // Should be set: Parameter is excluded but forced
  309. 'key321' => 'value321Overruled',
  310. // Should be set: Parameter doesn't exist in source array but is forced
  311. 'key323' => 'value323Overruled',
  312. ),
  313. ),
  314. );
  315. $expectedResult = '&key2=value2Overruled&key3[key32][key321]=value321Overruled&key3[key32][key323]=value323Overruled';
  316. $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
  317. $this->assertEquals($expectedResult, $actualResult);
  318. $getQueryArgumentsConfiguration['method'] = 'POST';
  319. $actualResult = $this->cObj->getQueryArguments($getQueryArgumentsConfiguration, $overruleArguments, TRUE);
  320. $this->assertEquals($expectedResult, $actualResult);
  321. }
  322. //////////////////////////////
  323. // Tests concerning cropHTML
  324. //////////////////////////////
  325. /**
  326. * This is the data provider for the tests of crop and cropHTML below. It provides all combinations
  327. * of charset, text type, and configuration options to be tested.
  328. *
  329. * @return array two-dimensional array with the second level like this:
  330. * 0 => the settings for the crop function, for example "-58|..."
  331. * 1 => the string to crop
  332. * 2 => the expected cropped result
  333. * 3 => the charset that will be set as renderCharset
  334. *
  335. * @see cropHtmlWithDataProvider
  336. */
  337. public function cropHtmlDataProvider() {
  338. $plainText = 'Kasper Sk' . chr(229) . 'rh' . chr(248) .
  339. 'j implemented the original version of the crop function.';
  340. $textWithMarkup = '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' .
  341. chr(229) . 'rh' . chr(248) . 'j</a>' .
  342. ' implemented</strong> the original version of the crop function.';
  343. $textWithEntities = 'Kasper Sk&aring;rh&oslash;j implemented the; original ' .
  344. 'version of the crop function.';
  345. $charsets = array('iso-8859-1', 'utf-8', 'ascii', 'big5');
  346. $data = array();
  347. foreach ($charsets as $charset) {
  348. $data = array_merge($data, array(
  349. $charset . ' plain text; 11|...' => array(
  350. '11|...', $plainText, 'Kasper Sk' . chr(229) . 'r...', $charset
  351. ),
  352. $charset . ' plain text; -58|...' => array(
  353. '-58|...', $plainText, '...h' . chr(248) . 'j implemented the original version of the crop function.', $charset
  354. ),
  355. $charset . ' plain text; 20|...|1' => array(
  356. '20|...|1', $plainText, 'Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j...', $charset
  357. ),
  358. $charset . ' plain text; -49|...|1' => array(
  359. '-49|...|1', $plainText, '...the original version of the crop function.', $charset
  360. ),
  361. $charset . ' text with markup; 11|...' => array(
  362. '11|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'r...</a></strong>', $charset
  363. ),
  364. $charset . ' text with markup; 13|...' => array(
  365. '13|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . '...</a></strong>', $charset
  366. ),
  367. $charset . ' text with markup; 14|...' => array(
  368. '14|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
  369. ),
  370. $charset . ' text with markup; 15|...' => array(
  371. '15|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> ...</strong>', $charset
  372. ),
  373. $charset . ' text with markup; 29|...' => array(
  374. '29|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong> th...', $charset
  375. ),
  376. $charset . ' text with markup; -58|...' => array(
  377. '-58|...', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">...h' . chr(248) . 'j</a> implemented</strong> the original version of the crop function.', $charset
  378. ),
  379. $charset . ' text with markup; 11|...|1' => array(
  380. '11|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>', $charset
  381. ),
  382. $charset . ' text with markup; 13|...|1' => array(
  383. '13|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper...</a></strong>', $charset
  384. ),
  385. $charset . ' text with markup; 14|...|1' => array(
  386. '14|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
  387. ),
  388. $charset . ' text with markup; 15|...|1' => array(
  389. '15|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a>...</strong>', $charset
  390. ),
  391. $charset . ' text with markup; 29|...|1' => array(
  392. '29|...|1', $textWithMarkup, '<strong><a href="mailto:kasper@typo3.org">Kasper Sk' . chr(229) . 'rh' . chr(248) . 'j</a> implemented</strong>...', $charset
  393. ),
  394. $charset . ' text with markup; -66|...|1' => array(
  395. '-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
  396. ),
  397. $charset . ' text with entities 9|...' => array(
  398. '9|...', $textWithEntities, 'Kasper Sk...', $charset
  399. ),
  400. $charset . ' text with entities 10|...' => array(
  401. '10|...', $textWithEntities, 'Kasper Sk&aring;...', $charset
  402. ),
  403. $charset . ' text with entities 11|...' => array(
  404. '11|...', $textWithEntities, 'Kasper Sk&aring;r...', $charset
  405. ),
  406. $charset . ' text with entities 13|...' => array(
  407. '13|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;...', $charset
  408. ),
  409. $charset . ' text with entities 14|...' => array(
  410. '14|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
  411. ),
  412. $charset . ' text with entities 15|...' => array(
  413. '15|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j ...', $charset
  414. ),
  415. $charset . ' text with entities 16|...' => array(
  416. '16|...', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j i...', $charset
  417. ),
  418. $charset . ' text with entities -57|...' => array(
  419. '-57|...', $textWithEntities, '...j implemented the; original version of the crop function.', $charset
  420. ),
  421. $charset . ' text with entities -58|...' => array(
  422. '-58|...', $textWithEntities, '...&oslash;j implemented the; original version of the crop function.', $charset
  423. ),
  424. $charset . ' text with entities -59|...' => array(
  425. '-59|...', $textWithEntities, '...h&oslash;j implemented the; original version of the crop function.', $charset
  426. ),
  427. $charset . ' text with entities 9|...|1' => array(
  428. '9|...|1', $textWithEntities, 'Kasper...', $charset
  429. ),
  430. $charset . ' text with entities 10|...|1' => array(
  431. '10|...|1', $textWithEntities, 'Kasper...', $charset
  432. ),
  433. $charset . ' text with entities 11|...|1' => array(
  434. '11|...|1', $textWithEntities, 'Kasper...', $charset
  435. ),
  436. $charset . ' text with entities 13|...|1' => array(
  437. '13|...|1', $textWithEntities, 'Kasper...', $charset
  438. ),
  439. $charset . ' text with entities 14|...|1' => array(
  440. '14|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
  441. ),
  442. $charset . ' text with entities 15|...|1' => array(
  443. '15|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
  444. ),
  445. $charset . ' text with entities 16|...|1' => array(
  446. '16|...|1', $textWithEntities, 'Kasper Sk&aring;rh&oslash;j...', $charset
  447. ),
  448. $charset . ' text with entities -57|...|1' => array(
  449. '-57|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
  450. ),
  451. $charset . ' text with entities -58|...|1' => array(
  452. '-58|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
  453. ),
  454. $charset . ' text with entities -59|...|1' => array(
  455. '-59|...|1', $textWithEntities, '...implemented the; original version of the crop function.', $charset
  456. ),
  457. ));
  458. }
  459. return $data;
  460. }
  461. /**
  462. * Checks if stdWrap.cropHTML works with plain text cropping from left
  463. *
  464. * @test
  465. *
  466. * @dataProvider cropHtmlDataProvider
  467. *
  468. * @param string $settings
  469. * the settings for the crop function, for example "-58|..."
  470. * @param string $subject the string to crop
  471. * @param string $expected the expected cropped result
  472. * @param string $charset the charset that will be set as renderCharset
  473. */
  474. public function cropHtmlWithDataProvider($settings, $subject, $expected, $charset) {
  475. $this->handleCharset($charset, $subject, $expected);
  476. $this->assertEquals(
  477. $expected,
  478. $this->cObj->cropHTML($subject, $settings),
  479. 'cropHTML failed with settings: "' . $settings . '" and charset "' . $charset . '"'
  480. );
  481. }
  482. /**
  483. * Checks if stdWrap.cropHTML works with a complex content with many tags. Currently cropHTML
  484. * counts multiple invisible characters not as one (as the browser will output the content).
  485. *
  486. * @test
  487. */
  488. public function cropHtmlWorksWithComplexContent() {
  489. $GLOBALS['TSFE']->renderCharset = 'iso-8859-1';
  490. $subject = '
  491. <h1>Blog Example</h1>
  492. <hr>
  493. <div class="csc-header csc-header-n1">
  494. <h2 class="csc-firstHeader">Welcome to Blog #1</h2>
  495. </div>
  496. <p class="bodytext">
  497. 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>.
  498. </p>
  499. <div class="tx-blogexample-list-container">
  500. <p class="bodytext">
  501. Below are the most recent posts:
  502. </p>
  503. <ul>
  504. <li>
  505. <h3>
  506. <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog]=&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=003b0131ed">The Post #1</a>
  507. </h3>
  508. <p class="bodytext">
  509. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut...
  510. </p>
  511. <p class="metadata">
  512. Published on 26.08.2009 by Jochen Rau
  513. </p>
  514. <p>
  515. Tags: [MVC]&nbsp;[Domain Driven Design]&nbsp;<br>
  516. <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=f982643bc3">read more &gt;&gt;</a><br>
  517. <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=edit&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=5b481bc8f0">Edit</a>&nbsp;<a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=delete&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=4e52879656">Delete</a>
  518. </p>
  519. </li>
  520. </ul>
  521. <p>
  522. <a href="index.php?id=99&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=new&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=2718a4b1a0">Create a new Post</a>
  523. </p>
  524. </div>
  525. <hr>
  526. <p>
  527. ? TYPO3 Association
  528. </p>
  529. ';
  530. $result = $this->cObj->cropHTML($subject, '300');
  531. $expected = '
  532. <h1>Blog Example</h1>
  533. <hr>
  534. <div class="csc-header csc-header-n1">
  535. <h2 class="csc-firstHeader">Welcome to Blog #1</h2>
  536. </div>
  537. <p class="bodytext">
  538. 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>.
  539. </p>
  540. <div class="tx-blogexample-list-container">
  541. <p class="bodytext">
  542. Below are the most recent posts:
  543. </p>
  544. <ul>
  545. <li>
  546. <h3>
  547. <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog]=&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=003b0131ed">The Pos</a></h3></li></ul></div>';
  548. $this->assertEquals($expected, $result);
  549. $result = $this->cObj->cropHTML($subject, '-100');
  550. $expected = '<div class="tx-blogexample-list-container"><ul><li><p>Design]&nbsp;<br>
  551. <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[action]=show&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=f982643bc3">read more &gt;&gt;</a><br>
  552. <a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=edit&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=5b481bc8f0">Edit</a>&nbsp;<a href="index.php?id=99&amp;tx_blogexample_pi1[post][uid]=211&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=delete&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=4e52879656">Delete</a>
  553. </p>
  554. </li>
  555. </ul>
  556. <p>
  557. <a href="index.php?id=99&amp;tx_blogexample_pi1[blog][uid]=70&amp;tx_blogexample_pi1[action]=new&amp;tx_blogexample_pi1[controller]=Post&amp;cHash=2718a4b1a0">Create a new Post</a>
  558. </p>
  559. </div>
  560. <hr>
  561. <p>
  562. ? TYPO3 Association
  563. </p>
  564. ';
  565. $this->assertEquals(
  566. $expected,
  567. $result
  568. );
  569. }
  570. }
  571. ?>