[TASK] Add unit test to cover stdWrap_br 23/48423/8
authorElmar Hinz <t3elmar@gmail.com>
Tue, 31 May 2016 18:57:12 +0000 (20:57 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Tue, 7 Jun 2016 07:46:11 +0000 (09:46 +0200)
Resolves: #76409
Releases: master
Change-Id: I79e09082c88aa5cee213d166beb033e6ed3776e5
Reviewed-on: https://review.typo3.org/48423
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 668f954..a3fc0ba 100755 (executable)
@@ -2588,6 +2588,11 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $this->assertEquals($expected, $result);
     }
 
+    /**
+     * Data provider for stdWrap_brTag
+     *
+     * @return array
+     */
     public function stdWrapBrTagDataProvider()
     {
         $noConfig = [];
@@ -2682,6 +2687,53 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     }
 
     /**
+     * Data provider for stdWrap_br
+     *
+     * @return string[][] Order expected, given, xhtmlDoctype
+     */
+    public function stdWrapBrDataProvider()
+    {
+        return [
+            'no xhtml with LF in between' => [
+                'one<br>' . LF . 'two',
+                'one' . LF . 'two',
+                null
+            ],
+            'no xhtml with LF in between and around' => [
+                '<br>' . LF . 'one<br>' . LF . 'two<br>' . LF,
+                LF . 'one' . LF . 'two' . LF,
+                null
+            ],
+            'xhtml with LF in between' => [
+                'one<br />' . LF . 'two',
+                'one' . LF . 'two',
+                'xhtml_strict'
+            ],
+            'xhtml with LF in between and around' => [
+                '<br />' . LF . 'one<br />' . LF . 'two<br />' . LF,
+                LF . 'one' . LF . 'two' . LF,
+                'xhtml_strict'
+            ],
+        ];
+    }
+
+    /**
+     * Test that stdWrap_br works as expected.
+     *
+     * @param string $expected The expected value.
+     * @param string $input The input value.
+     * @param string $xhtmlDoctype Xhtml document type.
+     * @return void
+     * @test
+     * @dataProvider stdWrapBrDataProvider
+     */
+    public function stdWrap_br($expected, $input, $xhtmlDoctype)
+    {
+        $GLOBALS['TSFE']->xhtmlDoctype = $xhtmlDoctype;
+        $this->assertSame($expected, $this->subject->stdWrap_br($input));
+    }
+
+    /**
      * Check if char works properly
      *
      * @test