f265158c13ded66524e83c902502763d6eb000a3
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Html / RteHtmlParserTest.php
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\Html;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2011 Stanislas Rolland <typo3@sjbr.ca>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Testcase for \TYPO3\CMS\Core\Html\RteHtmlParser
29 *
30 * @author Stanislas Rolland <typo3@sjbr.ca>
31 */
32 class RteHtmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
33
34 /**
35 * @var \TYPO3\CMS\Core\Html\RteHtmlParser
36 */
37 private $fixture = NULL;
38
39 public function setUp() {
40 $this->fixture = new \TYPO3\CMS\Core\Html\RteHtmlParser();
41 $this->fixture->procOptions = array(
42 'dontConvBRtoParagraph' => '1',
43 'preserveDIVSections' => '1',
44 'allowTagsOutside' => 'hr, address'
45 );
46 }
47
48 public function tearDown() {
49 unset($this->fixture);
50 }
51
52 /**
53 * Data provider for TS_transform_db
54 */
55 static public function hrTagCorrectlyTransformedOnWayToDataBaseDataProvider() {
56 return array(
57 'single hr' => array(
58 '<hr />',
59 '<hr />'
60 ),
61 'non-xhtml single hr' => array(
62 '<hr/>',
63 '<hr />'
64 ),
65 'double hr' => array(
66 '<hr /><hr />',
67 '<hr />' . LF . '<hr />'
68 ),
69 'linefeed followed by hr' => array(
70 LF . '<hr />',
71 '<hr />'
72 ),
73 'white space followed by hr' => array(
74 ' <hr />',
75 ' ' . LF . '<hr />'
76 ),
77 'white space followed linefeed and hr' => array(
78 ' ' . LF . '<hr />',
79 ' ' . LF . '<hr />'
80 ),
81 'br followed by hr' => array(
82 '<br /><hr />',
83 '<br />' . LF . '<hr />'
84 ),
85 'br followed by linefeed and hr' => array(
86 '<br />' . LF . '<hr />',
87 '<br />' . LF . '<hr />'
88 ),
89 'preserved div followed by hr' => array(
90 '<div>Some text</div><hr />',
91 '<div>Some text</div>' . LF . '<hr />'
92 ),
93 'preserved div followed by linefeed and hr' => array(
94 '<div>Some text</div>' . LF . '<hr />',
95 '<div>Some text</div>' . LF . '<hr />'
96 ),
97 'h1 followed by linefeed and hr' => array(
98 '<h1>Some text</h1>' . LF . '<hr />',
99 '<h1>Some text</h1>' . LF . '<hr />'
100 ),
101 'paragraph followed by linefeed and hr' => array(
102 '<p>Some text</p>' . LF . '<hr />',
103 'Some text' . LF . '<hr />'
104 ),
105 'some text followed by hr' => array(
106 'Some text<hr />',
107 'Some text' . LF . '<hr />'
108 ),
109 'some text followed by linefeed and hr' => array(
110 'Some text' . LF . '<hr />',
111 'Some text' . LF . '<hr />'
112 )
113 );
114 }
115
116 /**
117 * @test
118 * @dataProvider hrTagCorrectlyTransformedOnWayToDataBaseDataProvider
119 */
120 public function hrTagCorrectlyTransformedOnWayToDataBase($content, $expectedResult) {
121 // Assume the transformation is ts_css
122 $this->assertEquals($expectedResult, $this->fixture->TS_transform_db($content, TRUE));
123 }
124
125 }
126
127 ?>