[TASK] Add unit test to cover stdWrap_wrap2 34/48534/3
authorElmar Hinz <t3elmar@gmail.com>
Thu, 9 Jun 2016 10:49:27 +0000 (12:49 +0200)
committerFrank Naegler <frank.naegler@typo3.org>
Fri, 10 Jun 2016 07:39:32 +0000 (09:39 +0200)
Resolves: #76551
Releases: master
Change-Id: Ic5449d28b2d46e6dacc4e22389b2c5a5c423e1a5
Reviewed-on: https://review.typo3.org/48534
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 c8f1a35..d3f8400 100755 (executable)
@@ -2819,6 +2819,71 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     }
 
     /**
+     * Data provider for stdWrap_wrap2
+     *
+     * @return array Order expected, input, conf
+     */
+    public function stdWrap_wrap2DataProvider()
+    {
+        return [
+            'no conf' => [
+                'XXX',
+                'XXX',
+                [],
+            ],
+            'simple' => [
+                '<wrapper>XXX</wrapper>',
+                'XXX',
+                ['wrap2' => '<wrapper>|</wrapper>'],
+            ],
+            'trimms whitespace' => [
+                '<wrapper>XXX</wrapper>',
+                'XXX',
+                ['wrap2' => '<wrapper>' . TAB . ' | ' . TAB . '</wrapper>'],
+            ],
+            'missing pipe puts wrap2 before' => [
+                '<pre>XXX',
+                'XXX',
+                [
+                    'wrap2' => '<pre>',
+                ],
+            ],
+            'split char change' => [
+                '<wrapper>XXX</wrapper>',
+                'XXX',
+                [
+                    'wrap2' => '<wrapper> # </wrapper>',
+                    'wrap2.' => ['splitChar' => '#'],
+                ],
+            ],
+            'split by pattern' => [
+                '<wrapper>XXX</wrapper>',
+                'XXX',
+                [
+                    'wrap2' => '<wrapper> ###splitter### </wrapper>',
+                    'wrap2.' => ['splitChar' => '###splitter###'],
+                ],
+            ],
+        ];
+    }
+
+    /**
+     * Check if stdWrap_wrap2 works properly.
+     *
+     * @param string $expected The expected value.
+     * @param string $input The input value.
+     * @param array $conf Properties: wrap2, wrap2.splitChar
+     * @return void
+     * @test
+     * @dataProvider stdWrap_wrap2DataProvider
+     */
+    public function stdWrap_wrap2($expected, $input, $conf)
+    {
+        $this->assertSame($expected,
+            $this->subject->stdWrap_wrap2($input, $conf));
+    }
+
+    /**
      * Data provider for stdWrap_br
      *
      * @return string[][] Order expected, given, xhtmlDoctype