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