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