[TASK] Add unit tests for stdWrap_substring() 99/44899/4
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 22 Nov 2015 12:22:06 +0000 (13:22 +0100)
committerFrank Nägler <frank.naegler@typo3.org>
Mon, 23 Nov 2015 09:10:50 +0000 (10:10 +0100)
Resolves: #71772
Releases: master
Change-Id: I8ca9ab566f3e429c93b64c44bb0697c0b24f96e3
Reviewed-on: https://review.typo3.org/44899
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
typo3/sysext/frontend/Tests/Unit/ContentObject/ContentObjectRendererTest.php

index 75ac55c..fcf1a6f 100644 (file)
@@ -2144,6 +2144,121 @@ class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     }
 
     /**
+     * Data provider for stdWrap_substring test
+     *
+     * @return array
+     */
+    public function stdWrap_substringDataProvider()
+    {
+        return array(
+            'sub -1' => array(
+                'substring',
+                array(
+                    'substring' => '-1',
+                ),
+                'g',
+            ),
+            'sub -1,0' => array(
+                'substring',
+                array(
+                    'substring' => '-1,0',
+                ),
+                'g',
+            ),
+            'sub -1,-1' => array(
+                'substring',
+                array(
+                    'substring' => '-1,-1',
+                ),
+                '',
+            ),
+            'sub -1,1' => array(
+                'substring',
+                array(
+                    'substring' => '-1,1',
+                ),
+                'g',
+            ),
+            'sub 0' => array(
+                'substring',
+                array(
+                    'substring' => '0',
+                ),
+                'substring',
+            ),
+            'sub 0,0' => array(
+                'substring',
+                array(
+                    'substring' => '0,0',
+                ),
+                'substring',
+            ),
+            'sub 0,-1' => array(
+                'substring',
+                array(
+                    'substring' => '0,-1',
+                ),
+                'substrin',
+            ),
+            'sub 0,1' => array(
+                'substring',
+                array(
+                    'substring' => '0,1',
+                ),
+                's',
+            ),
+            'sub 1' => array(
+                'substring',
+                array(
+                    'substring' => '1',
+                ),
+                'ubstring',
+            ),
+            'sub 1,0' => array(
+                'substring',
+                array(
+                    'substring' => '1,0',
+                ),
+                'ubstring',
+            ),
+            'sub 1,-1' => array(
+                'substring',
+                array(
+                    'substring' => '1,-1',
+                ),
+                'ubstrin',
+            ),
+            'sub 1,1' => array(
+                'substring',
+                array(
+                    'substring' => '1,1',
+                ),
+                'u',
+            ),
+            'sub' => array(
+                'substring',
+                array(
+                    'substring' => '',
+                ),
+                'substring',
+            ),
+        );
+    }
+
+    /**
+     * @param string $content
+     * @param array $configuration
+     * @param string $expected
+     * @dataProvider stdWrap_substringDataProvider
+     * @test
+     */
+    public function stdWrap_substring($content, array $configuration, $expected)
+    {
+        $result = $this->subject->stdWrap_substring($content, $configuration);
+        $this->assertSame($expected, $result);
+    }
+
+    /**
      * Data provider for stdWrap_stdWrapValue test
      *
      * @return array