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