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