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