7782143327745e7a5829f8f8593784d311c97198
[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 'preserveDIVSections' => '1',
33 'allowTagsOutside' => 'hr, address',
34 'disableUnifyLineBreaks' => '0',
35 'overruleMode' => 'ts_css'
36 );
37 }
38
39 /**
40 * Data provider for hrTagCorrectlyTransformedOnWayToDataBase
41 */
42 public static function hrTagCorrectlyTransformedOnWayToDataBaseDataProvider()
43 {
44 return array(
45 'Single hr' => array(
46 '<hr />',
47 '<hr />',
48 ),
49 'Non-xhtml single hr' => array(
50 '<hr/>',
51 '<hr />',
52 ),
53 'Double hr' => array(
54 '<hr /><hr />',
55 '<hr />' . CRLF . '<hr />',
56 ),
57 'Linebreak followed by hr' => array(
58 CRLF . '<hr />',
59 '<hr />',
60 ),
61 'White space followed by hr' => array(
62 ' <hr />',
63 ' ' . CRLF . '<hr />',
64 ),
65 'White space followed linebreak and hr' => array(
66 ' ' . CRLF . '<hr />',
67 ' ' . CRLF . '<hr />',
68 ),
69 'br followed by hr' => array(
70 '<br /><hr />',
71 '<br />' . CRLF . '<hr />',
72 ),
73 'br followed by linebreak and hr' => array(
74 '<br />' . CRLF . '<hr />',
75 '<br />' . CRLF . '<hr />',
76 ),
77 'Preserved div followed by hr' => array(
78 '<div>Some text</div><hr />',
79 '<div>Some text</div>' . CRLF . '<hr />',
80 ),
81 'Preserved div followed by linebreak and hr' => array(
82 '<div>Some text</div>' . CRLF . '<hr />',
83 '<div>Some text</div>' . CRLF . '<hr />',
84 ),
85 'h1 followed by linebreak and hr' => array(
86 '<h1>Some text</h1>' . CRLF . '<hr />',
87 '<h1>Some text</h1>' . CRLF . '<hr />',
88 ),
89 'Paragraph followed by linebreak and hr' => array(
90 '<p>Some text</p>' . CRLF . '<hr />',
91 'Some text' . CRLF . '<hr />',
92 ),
93 'Some text followed by hr' => array(
94 'Some text<hr />',
95 'Some text' . CRLF . '<hr />',
96 ),
97 'Some text followed by linebreak and hr' => array(
98 'Some text' . CRLF . '<hr />',
99 'Some text' . CRLF . '<hr />',
100 ),
101 );
102 }
103
104 /**
105 * @test
106 * @dataProvider hrTagCorrectlyTransformedOnWayToDataBaseDataProvider
107 */
108 public function hrTagCorrectlyTransformedOnWayToDataBase($content, $expectedResult)
109 {
110 $thisConfig = array('proc.' => $this->subject->procOptions);
111 $this->assertEquals($expectedResult, $this->subject->RTE_transform($content, array(), 'db', $thisConfig));
112 }
113
114 /**
115 * Data provider for hrTagCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider
116 */
117 public static function hrTagCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider()
118 {
119 return array(
120 'Single hr' => array(
121 '<hr />',
122 '<hr />',
123 ),
124 'Non-xhtml single hr' => array(
125 '<hr/>',
126 '<hr />',
127 ),
128 'Double hr' => array(
129 '<hr /><hr />',
130 '<hr />' . CRLF . '<hr />',
131 ),
132 'Linebreak followed by hr' => array(
133 CRLF . '<hr />',
134 '<hr />',
135 ),
136 'White space followed by hr' => array(
137 ' <hr />',
138 '<p>&nbsp;</p>' . CRLF . '<hr />',
139 ),
140 'White space followed by linebreak and hr' => array(
141 ' ' . CRLF . '<hr />',
142 '<p>&nbsp;</p>' . CRLF . '<hr />',
143 ),
144 'br followed by hr' => array(
145 '<br /><hr />',
146 '<p><br /></p>' . CRLF . '<hr />',
147 ),
148 'br followed by linebreak and hr' => array(
149 '<br />' . CRLF . '<hr />',
150 '<p><br /></p>' . CRLF . '<hr />',
151 ),
152 'Preserved div followed by hr' => array(
153 '<div>Some text</div>' . '<hr />',
154 '<div><p>Some text</p></div>' . CRLF . '<hr />',
155 ),
156 'Preserved div followed by linebreak and hr' => array(
157 '<div>Some text</div>' . CRLF . '<hr />',
158 '<div><p>Some text</p></div>' . CRLF . '<hr />',
159 ),
160 'h1 followed by linebreak and hr' => array(
161 '<h1>Some text</h1>' . CRLF . '<hr />',
162 '<h1>Some text</h1>' . CRLF . '<hr />',
163 ),
164 'Paragraph followed by linebreak and hr' => array(
165 '<p>Some text</p>' . CRLF . '<hr />',
166 '<p>Some text</p>' . CRLF . '<hr />',
167 ),
168 'Some text followed by hr' => array(
169 'Some text<hr />',
170 '<p>Some text</p>' . CRLF . '<hr />',
171 ),
172 'Some text followed by linebreak and hr' => array(
173 'Some text' . CRLF . '<hr />',
174 '<p>Some text</p>' . CRLF . '<hr />',
175 ),
176 );
177 }
178
179 /**
180 * @test
181 * @dataProvider hrTagCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider
182 */
183 public function hrTagCorrectlyTransformedOnWayToDatabaseAndBackToRte($content, $expectedResult)
184 {
185 $thisConfig = array('proc.' => $this->subject->procOptions);
186 $this->assertEquals($expectedResult, $this->subject->RTE_transform($this->subject->RTE_transform($content, array(), 'db', $thisConfig), array(), 'rte', $thisConfig));
187 }
188
189 /**
190 * Data provider for linkWithAtSignCorrectlyTransformedOnWayToRTE
191 */
192 public static function linkWithAtSignCorrectlyTransformedOnWayToRTEProvider()
193 {
194 return array(
195 'external url with @ sign' => array(
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' => array(
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
206 /**
207 * @test
208 * @dataProvider linkWithAtSignCorrectlyTransformedOnWayToRTEProvider
209 */
210 public function linkWithAtSignCorrectlyTransformedOnWayToRTE($content, $expectedResult)
211 {
212 $thisConfig = array('proc.' => $this->subject->procOptions);
213 $this->assertEquals($expectedResult, $this->subject->RTE_transform($content, array(), 'rte', $thisConfig));
214 }
215
216 /**
217 * Data provider for paragraphCorrectlyTransformedOnWayToDatabase
218 */
219 public static function paragraphCorrectlyTransformedOnWayToDatabaseProvider()
220 {
221 return array(
222 'Empty string' => array(
223 '',
224 '',
225 ),
226 'Linebreak' => array(
227 CRLF,
228 '',
229 ),
230 'Double linebreak' => array(
231 CRLF . CRLF,
232 '',
233 ),
234 'Empty paragraph' => array(
235 '<p></p>',
236 CRLF,
237 ),
238 'Double empty paragraph' => array(
239 '<p></p><p></p>',
240 CRLF . CRLF,
241 ),
242 'Spacing paragraph' => array(
243 '<p>&nbsp;</p>',
244 CRLF,
245 ),
246 'Double spacing paragraph' => array(
247 '<p>&nbsp;</p>' . '<p>&nbsp;</p>',
248 CRLF . CRLF,
249 ),
250 'Plain text' => array(
251 'plain text',
252 'plain text',
253 ),
254 'Plain text followed by linebreak' => array(
255 'plain text' . CRLF,
256 'plain text ',
257 ),
258 'Paragraph' => array(
259 '<p>paragraph</p>',
260 'paragraph',
261 ),
262 'Paragraph followed by paragraph' => array(
263 '<p>paragraph1</p>' . '<p>paragraph2</p>',
264 'paragraph1' . CRLF . 'paragraph2',
265 ),
266 'Paragraph followed by paragraph, linebreak-separated' => array(
267 '<p>paragraph1</p>' . CRLF . '<p>paragraph2</p>',
268 'paragraph1' . CRLF . 'paragraph2',
269 ),
270 'Double spacing paragraph with text' => array(
271 '<p>&nbsp;</p><p>&nbsp;</p><p>paragraph1</p>',
272 CRLF . CRLF . 'paragraph1',
273 ),
274 'Paragraph followed by linebreak' => array(
275 '<p>paragraph</p>' . CRLF,
276 'paragraph',
277 ),
278 'Paragraph followed by spacing paragraph' => array(
279 '<p>paragraph</p>' . '<p>&nbsp;</p>',
280 'paragraph' . CRLF . CRLF,
281 ),
282 'Paragraph followed by spacing paragraph, linebreak-separated' => array(
283 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>',
284 'paragraph' . CRLF . CRLF,
285 ),
286 'Paragraph followed by double spacing paragraph' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
311 '<p>paragraph</p>' . '<h1>block</h1>',
312 'paragraph' . CRLF . '<h1>block</h1>',
313 ),
314 'Paragraph followed by block, linebreak-separated' => array(
315 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
316 'paragraph' . CRLF . '<h1>block</h1>',
317 ),
318 'Paragraph followed by spacing paragraph and block' => array(
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' => array(
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' => array(
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' => array(
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' => array(
335 '<h1>block1</h1>' . '<h1>block2</h1>',
336 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
337 ),
338 'Block followed by block, linebreak-separated' => array(
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' => array(
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' => array(
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' => array(
351 '<h1>block1</h1>' . '<p>&nbsp;</p>',
352 '<h1>block1</h1>' . CRLF . CRLF,
353 ),
354 'Block followed by spacing paragraph, linebreak-separated' => array(
355 '<h1>block1</h1>' . CRLF . '<p>&nbsp;</p>',
356 '<h1>block1</h1>' . CRLF . CRLF,
357 ),
358 'Block followed by spacing paragraph and block' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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
393 /**
394 * @test
395 * @dataProvider paragraphCorrectlyTransformedOnWayToDatabaseProvider
396 */
397 public function paragraphCorrectlyTransformedOnWayToDatabase($content, $expectedResult)
398 {
399 $thisConfig = array('proc.' => $this->subject->procOptions);
400 $this->assertEquals($expectedResult, $this->subject->RTE_transform($content, array(), 'db', $thisConfig));
401 }
402
403 /**
404 * Data provider for lineBreakCorrectlyTransformedOnWayToRte
405 */
406 public static function lineBreakCorrectlyTransformedOnWayToRteProvider()
407 {
408 return array(
409 'Empty string' => array(
410 '',
411 '',
412 ),
413 'Single linebreak' => array(
414 CRLF,
415 '<p>&nbsp;</p>',
416 ),
417 'Double linebreak' => array(
418 CRLF . CRLF,
419 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
420 ),
421 'Triple linebreak' => array(
422 CRLF . CRLF . CRLF,
423 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
424 ),
425 'Paragraph' => array(
426 'paragraph',
427 '<p>paragraph</p>',
428 ),
429 'Paragraph followed by single linebreak' => array(
430 'paragraph' . CRLF,
431 '<p>paragraph</p>',
432 ),
433 'Paragraph followed by double linebreak' => array(
434 'paragraph' . CRLF . CRLF,
435 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>',
436 ),
437 'Paragraph followed by triple linebreak' => array(
438 'paragraph' . CRLF . CRLF . CRLF,
439 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
440 ),
441 'Paragraph followed by paragraph' => array(
442 'paragraph1' . CRLF . 'paragraph2',
443 '<p>paragraph1</p>' . CRLF . '<p>paragraph2</p>',
444 ),
445 'Paragraph followed by double linebreak and paragraph' => array(
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' => array(
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' => array(
454 'paragraph' . '<h1>block</h1>',
455 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
456 ),
457 'Paragraph followed by linebreak and block' => array(
458 'paragraph' . CRLF . '<h1>block</h1>',
459 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
460 ),
461 'Paragraph followed by double linebreak and block' => array(
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' => array(
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' => array(
470 '<h1>block1</h1>' . '<h1>block2</h1>',
471 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
472 ),
473 'Block followed by single linebreak and block' => array(
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' => array(
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' => array(
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' => array(
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
492 /**
493 * @test
494 * @dataProvider lineBreakCorrectlyTransformedOnWayToRTEProvider
495 */
496 public function lineBreakCorrectlyTransformedOnWayToRTE($content, $expectedResult)
497 {
498 $thisConfig = array('proc.' => $this->subject->procOptions);
499 $this->assertEquals($expectedResult, $this->subject->RTE_transform($content, array(), 'rte', $thisConfig));
500 }
501
502 /**
503 * Data provider for paragraphCorrectlyTransformedOnWayToDatabaseAndBackToRte
504 */
505 public static function paragraphCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider()
506 {
507 return array(
508 'Empty string' => array(
509 '',
510 '',
511 ),
512 'Empty paragraph' => array(
513 '<p></p>',
514 '<p>&nbsp;</p>',
515 ),
516 'Double empty paragraph' => array(
517 '<p></p><p></p>',
518 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
519 ),
520 'Triple empty paragraph' => array(
521 '<p></p><p></p><p></p>',
522 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
523 ),
524 'Plain text' => array(
525 'plain text',
526 '<p>plain text</p>',
527 ),
528 'Plain text followed by linebreak' => array(
529 'plain text' . CRLF,
530 '<p>plain text </p>',
531 ),
532 'Plain text followed by paragraph' => array(
533 'plain text' . '<p>paragraph</p>',
534 '<p>plain text</p>' . CRLF . '<p>paragraph</p>',
535 ),
536 'Spacing paragraph' => array(
537 '<p>&nbsp;</p>',
538 '<p>&nbsp;</p>',
539 ),
540 'Double spacing paragraph' => array(
541 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
542 '<p>&nbsp;</p>' . CRLF . '<p>&nbsp;</p>',
543 ),
544 'Paragraph' => array(
545 '<p>paragraph</p>',
546 '<p>paragraph</p>',
547 ),
548 'Paragraph followed by linebreak' => array(
549 '<p>paragraph</p>' . CRLF,
550 '<p>paragraph</p>',
551 ),
552 'Paragraph followed by spacing paragraph' => array(
553 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>',
554 '<p>paragraph</p>' . CRLF . '<p>&nbsp;</p>',
555 ),
556 'Paragraph followed by double spacing paragraph' => array(
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' => array(
561 '<p>paragraph1</p>' . '<p>paragraph2</p>',
562 '<p>paragraph1</p>' . CRLF . '<p>paragraph2</p>',
563 ),
564 'Paragraph followed by paragraph, linebreak-separated' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
585 '<p>paragraph</p>' . '<h1>block</h1>',
586 '<p>paragraph</p>' . CRLF . '<h1>block</h1>',
587 ),
588 'Paragraph followed by block, linebreak-separated' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
609 '<h1>block1</h1>' . '<h1>block2</h1>',
610 '<h1>block1</h1>' . CRLF . '<h1>block2</h1>',
611 ),
612 'Block followed by block, linebreak-separated' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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' => array(
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
643 /**
644 * @test
645 * @dataProvider paragraphCorrectlyTransformedOnWayToDatabaseAndBackToRteProvider
646 */
647 public function paragraphCorrectlyTransformedOnWayToDatabaseAndBackToRte($content, $expectedResult)
648 {
649 $thisConfig = array('proc.' => $this->subject->procOptions);
650 $this->assertEquals($expectedResult, $this->subject->RTE_transform($this->subject->RTE_transform($content, array(), 'db', $thisConfig), array(), 'rte', $thisConfig));
651 }
652 }