cc08c16f903d416f8f5c38dc545d20ac7e803444
[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 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Testcase for \TYPO3\CMS\Core\Html\RteHtmlParser
19 *
20 * @author Stanislas Rolland <typo3@sjbr.ca>
21 */
22 class RteHtmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
23
24 /**
25 * @var \TYPO3\CMS\Core\Html\RteHtmlParser
26 */
27 protected $fixture = NULL;
28
29 protected function setUp() {
30 $this->fixture = new \TYPO3\CMS\Core\Html\RteHtmlParser();
31 $this->fixture->procOptions = array(
32 'dontConvBRtoParagraph' => '1',
33 'preserveDIVSections' => '1',
34 'allowTagsOutside' => 'hr, address',
35 'disableUnifyLineBreaks' => '0',
36 'overruleMode' => 'ts_css'
37 );
38 }
39
40 /**
41 * Data provider for hrTagCorrectlyTransformedOnWayToDataBase
42 */
43 public static function hrTagCorrectlyTransformedOnWayToDataBaseDataProvider() {
44 return array(
45 'Single hr' => array(
46 '<hr />',
47 '<hr />',
48 ),
49 'Non-xhtml single hr' => array(
50 '<hr/>',
51 '<hr />',
52 ),
53 'Double hr' => array(
54 '<hr /><hr />',
55 '<hr />' . CRLF . '<hr />',
56 ),
57 'Linebreak followed by hr' => array(
58 CRLF . '<hr />',
59 '<hr />',
60 ),
61 'White space followed by hr' => array(
62 ' <hr />',
63 ' ' . CRLF . '<hr />',
64 ),
65 'White space followed linebreak and hr' => array(
66 ' ' . CRLF . '<hr />',
67 ' ' . CRLF . '<hr />',
68 ),
69 'br followed by hr' => array(
70 '<br /><hr />',
71 '<br />' . CRLF . '<hr />',
72 ),
73 'br followed by linebreak and hr' => array(
74 '<br />' . CRLF . '<hr />',
75 '<br />' . CRLF . '<hr />',
76 ),
77 'Preserved div followed by hr' => array(
78 '<div>Some text</div><hr />',
79 '<div>Some text</div>' . CRLF . '<hr />',
80 ),
81 'Preserved div followed by linebreak and hr' => array(
82 '<div>Some text</div>' . CRLF . '<hr />',
83 '<div>Some text</div>' . CRLF . '<hr />',
84 ),
85 'h1 followed by linebreak and hr' => array(
86 '<h1>Some text</h1>' . CRLF . '<hr />',
87 '<h1>Some text</h1>' . CRLF . '<hr />',
88 ),
89 'Paragraph followed by linebreak and hr' => array(
90 '<p>Some text</p>' . CRLF . '<hr />',
91 'Some text' . CRLF . '<hr />',
92 ),
93 'Some text followed by hr' => array(
94 'Some text<hr />',
95 'Some text' . CRLF . '<hr />',
96 ),
97 'Some text followed by linebreak and hr' => array(
98 'Some text' . CRLF . '<hr />',
99 'Some text' . CRLF . '<hr />',
100 ),
101 );
102 }
103
104 /**
105 * @test
106 * @dataProvider hrTagCorrectlyTransformedOnWayToDataBaseDataProvider
107 */
108 public function hrTagCorrectlyTransformedOnWayToDataBase($content, $expectedResult) {
109 $thisConfig = array('proc.' => $this->fixture->procOptions);
110 $this->assertEquals($expectedResult, $this->fixture->RTE_transform($content, array(), 'db', $thisConfig));
111 }
112
113 /**
114 * Data provider for hrTagCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider
115 */
116 public static function hrTagCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider() {
117 return array(
118 'Single hr' => array(
119 '<hr />',
120 '<hr />',
121 ),
122 'Non-xhtml single hr' => array(
123 '<hr/>',
124 '<hr />',
125 ),
126 'Double hr' => array(
127 '<hr /><hr />',
128 '<hr />' . CRLF . '<hr />',
129 ),
130 'Linebreak followed by hr' => array(
131 CRLF . '<hr />',
132 '<hr />',
133 ),
134 'White space followed by hr' => array(
135 ' <hr />',
136 '<p>&nbsp;</p>' . CRLF . '<hr />',
137 ),
138 'White space followed by linebreak and hr' => array(
139 ' ' . CRLF . '<hr />',
140 '<p>&nbsp;</p>' . CRLF . '<hr />',
141 ),
142 'br followed by hr' => array(
143 '<br /><hr />',
144 '<p><br /></p>' . CRLF . '<hr />',
145 ),
146 'br followed by linebreak and hr' => array(
147 '<br />' . CRLF . '<hr />',
148 '<p><br /></p>' . CRLF . '<hr />',
149 ),
150 'Preserved div followed by hr' => array(
151 '<div>Some text</div>' . '<hr />',
152 '<div><p>Some text</p></div>' . CRLF . '<hr />',
153 ),
154 'Preserved div followed by linebreak and hr' => array(
155 '<div>Some text</div>' . CRLF . '<hr />',
156 '<div><p>Some text</p></div>' . CRLF . '<hr />',
157 ),
158 'h1 followed by linebreak and hr' => array(
159 '<h1>Some text</h1>' . CRLF . '<hr />',
160 '<h1>Some text</h1>' . CRLF . '<hr />',
161 ),
162 'Paragraph followed by linebreak and hr' => array(
163 '<p>Some text</p>' . CRLF . '<hr />',
164 '<p>Some text</p>' . CRLF . '<hr />',
165 ),
166 'Some text followed by hr' => array(
167 'Some text<hr />',
168 '<p>Some text</p>' . CRLF . '<hr />',
169 ),
170 'Some text followed by linebreak and hr' => array(
171 'Some text' . CRLF . '<hr />',
172 '<p>Some text</p>' . CRLF . '<hr />',
173 ),
174 );
175 }
176
177 /**
178 * @test
179 * @dataProvider hrTagCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider
180 */
181 public function hrTagCorrectlyTransformedOnWayToDatabaseAndBackToRte($content, $expectedResult) {
182 $thisConfig = array('proc.' => $this->fixture->procOptions);
183 $this->assertEquals($expectedResult, $this->fixture->RTE_transform($this->fixture->RTE_transform($content, array(), 'db', $thisConfig), array(), 'rte', $thisConfig));
184 }
185
186 /**
187 * Data provider for linkWithAtSignCorrectlyTransformedOnWayToRTE
188 */
189 public static function linkWithAtSignCorrectlyTransformedOnWayToRTEProvider() {
190 return array(
191 'external url with @ sign' => array(
192 '<link http://www.example.org/at@sign>link text</link>',
193 '<p><a href="http://www.example.org/at@sign" data-htmlarea-external="1">link text</a></p>'
194 ),
195 'email address with @ sign' => array(
196 '<link name@example.org - mail "Opens window for sending email">link text</link>',
197 '<p><a href="mailto:name@example.org" class="mail" title="Opens window for sending email">link text</a></p>'
198 )
199 );
200 }
201
202 /**
203 * @test
204 * @dataProvider linkWithAtSignCorrectlyTransformedOnWayToRTEProvider
205 */
206 public function linkWithAtSignCorrectlyTransformedOnWayToRTE($content, $expectedResult) {
207 $thisConfig = array('proc.' => $this->fixture->procOptions);
208 $this->assertEquals($expectedResult, $this->fixture->RTE_transform($content, array(), 'rte', $thisConfig));
209 }
210
211 /**
212 * Data provider for paragraphCorrectlyTransformedOnWayToDatabase
213 */
214 public static function paragraphCorrectlyTransformedOnWayToDatabaseProvider() {
215 return array(
216 'Empty string' => array(
217 '',
218 '',
219 ),
220 'Linebreak' => array(
221 CRLF,
222 '',
223 ),
224 'Double linebreak' => array(
225 CRLF . CRLF,
226 '',
227 ),
228 'Empty paragraph' => array(
229 '<p></p>',
230 CRLF,
231 ),
232 'Double empty paragraph' => array(
233 '<p></p><p></p>',
234 CRLF . CRLF,
235 ),
236 'Spacing paragraph' => array(
237 '<p>&nbsp;</p>',
238 CRLF,
239 ),
240 'Double spacing paragraph' => array(
241 '<p>&nbsp;</p>' . '<p>&nbsp;</p>',
242 CRLF . CRLF,
243 ),
244 'Plain text' => array(
245 'plain text',
246 'plain text',
247 ),
248 'Plain text followed by linebreak' => array(
249 'plain text' . CRLF,
250 'plain text ',
251 ),
252 'Paragraph' => array(
253 '<p>paragraph</p>',
254 'paragraph',
255 ),
256 'Paragraph followed by paragraph' => array(
257 '<p>paragraph1</p>' . '<p>paragraph2</p>',
258 'paragraph1' . CRLF . 'paragraph2',
259 ),
260 'Paragraph followed by paragraph, linebreak-separated' => array(
261 '<p>paragraph1</p>' . CRLF . '<p>paragraph2</p>',
262 'paragraph1' . CRLF . 'paragraph2',
263 ),
264 'Double spacing paragraph with text' => array(
265 '<p>&nbsp;</p><p>&nbsp;</p><p>paragraph1</p>',
266 CRLF . CRLF . 'paragraph1',
267 ),
268 'Paragraph followed by linebreak' => array(
269 '<p>paragraph</p>' . CRLF,
270 'paragraph',
271 ),
272 'Paragraph followed by spacing paragraph' => array(
273 '<p>paragraph</p>' . '<p>&nbsp;</p>',
274 'paragraph' . CRLF . CRLF,
275 ),
276 'Paragraph followed by spacing paragraph, linebreak-separated' => array(
277 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>',
278 'paragraph' . CRLF . CRLF,
279 ),
280 'Paragraph followed by double spacing paragraph' => array(
281 '<p>paragraph</p>' . '<p>&nbsp;</p>' . '<p>&nbsp;</p>',
282 'paragraph' . CRLF . CRLF . CRLF,
283 ),
284 'Paragraph followed by double spacing paragraph, linebreak-separated' => array(
285 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
286 'paragraph' . CRLF . CRLF . CRLF,
287 ),
288 'Paragraph followed by spacing paragraph and by paragraph' => array(
289 '<p>paragraph1</p>' . '<p>&nbsp;</p>' . '<p>paragraph2</p>',
290 'paragraph1' . CRLF . CRLF . 'paragraph2',
291 ),
292 'Paragraph followed by spacing paragraph and by paragraph, linebreak-separated' => array(
293 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
294 'paragraph1' . CRLF . CRLF . 'paragraph2',
295 ),
296 'Paragraph followed by double spacing paragraph and by paragraph' => array(
297 '<p>paragraph1</p>' . '<p>&nbsp;</p>' . '<p>&nbsp;</p>' . '<p>paragraph2</p>',
298 'paragraph1' . CRLF . CRLF . CRLF . 'paragraph2',
299 ),
300 'Paragraph followed by double spacing paragraph and by paragraph, linebreak-separated' => array(
301 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
302 'paragraph1' . CRLF . CRLF . CRLF . 'paragraph2',
303 ),
304 'Paragraph followed by block' => array(
305 '<p>paragraph</p>' . '<h1>block</h1>',
306 'paragraph' . CRLF . '<h1>block</h1>',
307 ),
308 'Paragraph followed by block, linebreak-separated' => array(
309 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
310 'paragraph' . CRLF . '<h1>block</h1>',
311 ),
312 'Paragraph followed by spacing paragraph and block' => array(
313 '<p>paragraph</p>' . '<p>&nbsp;</p>' . '<h1>block</h1>',
314 'paragraph' . CRLF . CRLF . '<h1>block</h1>',
315 ),
316 'Paragraph followed by spacing paragraph and block, linebreak-separated' => array(
317 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
318 'paragraph' . CRLF . CRLF . '<h1>block</h1>',
319 ),
320 'Paragraph followed by double spacing paragraph and block' => array(
321 '<p>paragraph</p>' . '<p>&nbsp;</p>' . '<p>&nbsp;</p>' . '<h1>block</h1>',
322 'paragraph' . CRLF . CRLF . CRLF . '<h1>block</h1>',
323 ),
324 'Paragraph followed by double spacing paragraph and block, linebreak-separated' => array(
325 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
326 'paragraph' . CRLF . CRLF . CRLF . '<h1>block</h1>',
327 ),
328 'Block followed by block' => array(
329 '<h1>block1</h1>' . '<h1>block2</h1>',
330 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
331 ),
332 'Block followed by block, linebreak-separated' => array(
333 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
334 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
335 ),
336 'Block followed by empty paragraph and block' => array(
337 '<h1>block1</h1>' . '<p></p>' . '<h1>block2</h1>',
338 '<h1>block1</h1>' . CRLF . CRLF . '<h1>block2</h1>',
339 ),
340 'Block followed by empty paragraph aand block, linebreak-separated' => array(
341 '<h1>block1</h1>' . CRLF . '<p></p>' . CRLF . '<h1>block2</h1>',
342 '<h1>block1</h1>' . CRLF . CRLF . '<h1>block2</h1>',
343 ),
344 'Block followed by spacing paragraph' => array(
345 '<h1>block1</h1>' . '<p>&nbsp;</p>',
346 '<h1>block1</h1>' . CRLF . CRLF,
347 ),
348 'Block followed by spacing paragraph, linebreak-separated' => array(
349 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>',
350 '<h1>block1</h1>' . CRLF . CRLF,
351 ),
352 'Block followed by spacing paragraph and block' => array(
353 '<h1>block1</h1>' . '<p>&nbsp;</p>' . '<h1>block2</h1>',
354 '<h1>block1</h1>' . CRLF . CRLF . '<h1>block2</h1>',
355 ),
356 'Block followed by spacing paragraph and block, linebreak-separated' => array(
357 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
358 '<h1>block1</h1>' . CRLF . CRLF . '<h1>block2</h1>',
359 ),
360 'Block followed by double spacing paragraph and by block' => array(
361 '<h1>block1</h1>' . '<p>&nbsp;</p>' . '<p>&nbsp;</p>' . '<h1>block2</h1>',
362 '<h1>block1</h1>' . CRLF . CRLF . CRLF . '<h1>block2</h1>',
363 ),
364 'Block followed by double spacing paragraph and by block, linebreak-separated' => array(
365 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
366 '<h1>block1</h1>' . CRLF . CRLF . CRLF . '<h1>block2</h1>',
367 ),
368 'Block followed by paragraph and block' => array(
369 '<h1>block1</h1>' . '<p>paragraph</p>' . '<h1>block2</h1>',
370 '<h1>block1</h1>' . CRLF . 'paragraph' . CRLF . '<h1>block2</h1>',
371 ),
372 'Block followed by paragraph and block, linebreak-separated' => array(
373 '<h1>block1</h1>' . CRLF . '<p>paragraph</p>' . CRLF . '<h1>block2</h1>',
374 '<h1>block1</h1>' . CRLF . 'paragraph' . CRLF . '<h1>block2</h1>',
375 ),
376 'Block followed by paragraph, spacing paragraph and block' => array(
377 '<h1>block1</h1>' . '<p>paragraph</p>' . '<p>&nbsp;</p>' . '<h1>block2</h1>',
378 '<h1>block1</h1>' . CRLF . 'paragraph' . CRLF . CRLF . '<h1>block2</h1>',
379 ),
380 'Block followed by paragraph, spacing paragraph and block, linebreak-separated' => array(
381 '<h1>block1</h1>' . CRLF . '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
382 '<h1>block1</h1>' . CRLF . 'paragraph' . CRLF . CRLF . '<h1>block2</h1>',
383 ),
384 );
385 }
386
387 /**
388 * @test
389 * @dataProvider paragraphCorrectlyTransformedOnWayToDatabaseProvider
390 */
391 public function paragraphCorrectlyTransformedOnWayToDatabase($content, $expectedResult) {
392 $thisConfig = array('proc.' => $this->fixture->procOptions);
393 $this->assertEquals($expectedResult, $this->fixture->RTE_transform($content, array(), 'db', $thisConfig));
394 }
395
396 /**
397 * Data provider for lineBreakCorrectlyTransformedOnWayToRte
398 */
399 public static function lineBreakCorrectlyTransformedOnWayToRteProvider() {
400 return array(
401 'Empty string' => array(
402 '',
403 '',
404 ),
405 'Single linebreak' => array(
406 CRLF,
407 '<p>&nbsp;</p>',
408 ),
409 'Double linebreak' => array(
410 CRLF . CRLF,
411 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
412 ),
413 'Triple linebreak' => array(
414 CRLF . CRLF . CRLF,
415 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
416 ),
417 'Paragraph' => array(
418 'paragraph',
419 '<p>paragraph</p>',
420 ),
421 'Paragraph followed by single linebreak' => array(
422 'paragraph' . CRLF,
423 '<p>paragraph</p>',
424 ),
425 'Paragraph followed by double linebreak' => array(
426 'paragraph' . CRLF . CRLF,
427 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>',
428 ),
429 'Paragraph followed by triple linebreak' => array(
430 'paragraph' . CRLF . CRLF . CRLF,
431 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
432 ),
433 'Paragraph followed by paragraph' => array(
434 'paragraph1' . CRLF . 'paragraph2',
435 '<p>paragraph1</p>' . CRLF . '<p>paragraph2</p>',
436 ),
437 'Paragraph followed by double linebreak and paragraph' => array(
438 'paragraph1' . CRLF . CRLF . 'paragraph2',
439 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
440 ),
441 'Paragraph followed by triple linebreak and paragraph' => array(
442 'paragraph1' . CRLF . CRLF . CRLF . 'paragraph2',
443 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
444 ),
445 'Paragraph followed by block' => array(
446 'paragraph' . '<h1>block</h1>',
447 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
448 ),
449 'Paragraph followed by linebreak and block' => array(
450 'paragraph' . CRLF . '<h1>block</h1>',
451 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
452 ),
453 'Paragraph followed by double linebreak and block' => array(
454 'paragraph' . CRLF . CRLF . '<h1>block</h1>',
455 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
456 ),
457 'Paragraph followed by triple linebreak and block' => array(
458 'paragraph' . CRLF . CRLF . CRLF . '<h1>block</h1>',
459 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
460 ),
461 'Block followed by block' => array(
462 '<h1>block1</h1>' . '<h1>block2</h1>',
463 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
464 ),
465 'Block followed by single linebreak and block' => array(
466 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
467 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
468 ),
469 'Block followed by double linebreak and block' => array(
470 '<h1>block1</h1>' . CRLF . CRLF . '<h1>block2</h1>',
471 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
472 ),
473 'Block followed by triple linebreak and block' => array(
474 '<h1>block1</h1>' . CRLF . CRLF . CRLF . '<h1>block2</h1>',
475 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
476 ),
477 'Block followed by paragraph and block' => array(
478 '<h1>block1</h1>' . CRLF . 'paragraph' . CRLF . '<h1>block2</h1>',
479 '<h1>block1</h1>' . CRLF . '<p>paragraph</p>' . CRLF . '<h1>block2</h1>',
480 ),
481 );
482 }
483
484 /**
485 * @test
486 * @dataProvider lineBreakCorrectlyTransformedOnWayToRTEProvider
487 */
488 public function lineBreakCorrectlyTransformedOnWayToRTE($content, $expectedResult) {
489 $thisConfig = array('proc.' => $this->fixture->procOptions);
490 $this->assertEquals($expectedResult, $this->fixture->RTE_transform($content, array(), 'rte', $thisConfig));
491 }
492
493 /**
494 * Data provider for paragraphCorrectlyTransformedOnWayToDatabaseAndBackToRte
495 */
496 public static function paragraphCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider() {
497 return array(
498 'Empty string' => array(
499 '',
500 '',
501 ),
502 'Empty paragraph' => array(
503 '<p></p>',
504 '<p>&nbsp;</p>',
505 ),
506 'Double empty paragraph' => array(
507 '<p></p><p></p>',
508 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
509 ),
510 'Triple empty paragraph' => array(
511 '<p></p><p></p><p></p>',
512 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
513 ),
514 'Plain text' => array(
515 'plain text',
516 '<p>plain text</p>',
517 ),
518 'Plain text followed by linebreak' => array(
519 'plain text' . CRLF,
520 '<p>plain text </p>',
521 ),
522 'Plain text followed by paragraph' => array(
523 'plain text' . '<p>paragraph</p>',
524 '<p>plain text</p>' . CRLF . '<p>paragraph</p>',
525 ),
526 'Spacing paragraph' => array(
527 '<p>&nbsp;</p>',
528 '<p>&nbsp;</p>',
529 ),
530 'Double spacing paragraph' => array(
531 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
532 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
533 ),
534 'Paragraph' => array(
535 '<p>paragraph</p>',
536 '<p>paragraph</p>',
537 ),
538 'Paragraph followed by linebreak' => array(
539 '<p>paragraph</p>' . CRLF,
540 '<p>paragraph</p>',
541 ),
542 'Paragraph followed by spacing paragraph' => array(
543 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>',
544 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>',
545 ),
546 'Paragraph followed by double spacing paragraph' => array(
547 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
548 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
549 ),
550 'Paragraph followed by paragraph' => array(
551 '<p>paragraph1</p>' . '<p>paragraph2</p>',
552 '<p>paragraph1</p>' . CRLF . '<p>paragraph2</p>',
553 ),
554 'Paragraph followed by paragraph, linebreak-separated' => array(
555 '<p>paragraph1</p>' . CRLF . '<p>paragraph2</p>',
556 '<p>paragraph1</p>' . CRLF . '<p>paragraph2</p>',
557 ),
558 'Paragraph followed by spacing paragraph and by paragraph' => array(
559 '<p>paragraph1</p>' . '<p>&nbsp;</p>' . '<p>paragraph2</p>',
560 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
561 ),
562 'Paragraph followed by spacing paragraph and by paragraph, linebreak-separated' => array(
563 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
564 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
565 ),
566 'Paragraph followed by double spacing paragraph and by paragraph' => array(
567 '<p>paragraph1</p>' . '<p>&nbsp;</p>' . '<p>&nbsp;</p>' . '<p>paragraph2</p>',
568 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
569 ),
570 'Paragraph followed by double spacing paragraph and by paragraph, linebreak-separated' => array(
571 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
572 '<p>paragraph1</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>paragraph2</p>',
573 ),
574 'Paragraph followed by block' => array(
575 '<p>paragraph</p>' . '<h1>block</h1>',
576 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
577 ),
578 'Paragraph followed by block, linebreak-separated' => array(
579 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
580 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
581 ),
582 'Paragraph followed by spacing paragraph and by block' => array(
583 '<p>paragraph</p>' . '<p>&nbsp;</p>' . '<h1>block</h1>',
584 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
585 ),
586 'Paragraph followed by spacing paragraph and by block, linebreak-separated' => array(
587 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
588 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
589 ),
590 'Paragraph followed by double spacing paragraph and by block' => array(
591 '<p>paragraph</p>' . '<p>&nbsp;</p>' . '<p>&nbsp;</p>' . '<h1>block</h1>',
592 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
593 ),
594 'Paragraph followed by double spacing paragraph and by block, linebreak-separated' => array(
595 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
596 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block</h1>',
597 ),
598 'Block followed by block' => array(
599 '<h1>block1</h1>' . '<h1>block2</h1>',
600 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
601 ),
602 'Block followed by block, linebreak-separated' => array(
603 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
604 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
605 ),
606 'Block followed by empty paragraph and by block' => array(
607 '<h1>block1</h1>' . '<p></p>' . '<h1>block2</h1>',
608 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
609 ),
610 'Block followed by empty paragraph and by block, linebreak-separated' => array(
611 '<h1>block1</h1>' . CRLF . '<p></p>' . CRLF . '<h1>block2</h1>',
612 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
613 ),
614 'Block followed by spacing paragraph and by block' => array(
615 '<h1>block1</h1>' . '<p>&nbsp;</p>' . '<h1>block2</h1>',
616 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
617 ),
618 'Block followed by spacing paragraph and by block, linebreak-separated' => array(
619 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
620 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
621 ),
622 'Block followed by double spacing paragraph and by block' => array(
623 '<h1>block1</h1>' . '<p>&nbsp;</p>' . '<p>&nbsp;</p>' . '<h1>block2</h1>',
624 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
625 ),
626 'Block followed by double spacing paragraph and by block, linebreak-separated' => array(
627 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
628 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<h1>block2</h1>',
629 ),
630 );
631 }
632
633 /**
634 * @test
635 * @dataProvider paragraphCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider
636 */
637 public function paragraphCorrectlyTransformedOnWayToDatabaseAndBackToRte($content, $expectedResult) {
638 $thisConfig = array('proc.' => $this->fixture->procOptions);
639 $this->assertEquals($expectedResult, $this->fixture->RTE_transform($this->fixture->RTE_transform($content, array(), 'db', $thisConfig), array(), 'rte', $thisConfig));
640 }
641
642 }