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