[TASK] Add unit tests for HtmlParser::substituteSubpartArray() 37/42737/4
authorMichael Oehlhof <typo3@oehlhof.de>
Tue, 18 Aug 2015 22:56:20 +0000 (00:56 +0200)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Thu, 20 Aug 2015 08:06:29 +0000 (10:06 +0200)
Resolves: #69175
Releases: master
Change-Id: Id85a7ab6bc7f3b3281f394fd9a41ecd64ab51ec7
Reviewed-on: http://review.typo3.org/42737
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php

index 3863251..739ab4e 100644 (file)
@@ -99,6 +99,9 @@ text
 
        /**
         * @test
+        * @param string $content
+        * @param string $marker
+        * @param string $expected
         * @dataProvider getSubpartDataProvider
         */
        public function getSubpart($content, $marker, $expected) {
@@ -227,6 +230,12 @@ hello
 
        /**
         * @test
+        * @param string $content
+        * @param string $marker
+        * @param array $subpartContent
+        * @param bool $recursive
+        * @param bool $keepMarker
+        * @param string $expected
         * @dataProvider substituteSubpartDataProvider
         */
        public function substituteSubpart($content, $marker, $subpartContent, $recursive, $keepMarker, $expected) {
@@ -340,7 +349,42 @@ hello
        }
 
        /**
+        * Data provider for substituteSubpartArray
+        *
+        * @return array
+        */
+       public function substituteSubpartArrayDataProvider() {
+               return array(
+                       'Substitute multiple subparts at once with plain marker' => array(
+                               '<body>
+###SUBPART1###text1###SUBPART1###
+###SUBPART2###text2###SUBPART2###
+</body>',
+                               array ('###SUBPART1###' => 'hello',
+                                       '###SUBPART2###' => 'world'),
+                               '<body>
+hello
+world
+</body>'
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @param string $content
+        * @param array $subpartsContent
+        * @param string $expected
+        * @dataProvider substituteSubpartArrayDataProvider
+        */
+       public function substituteSubpartArray($content, array $subpartsContent, $expected) {
+               $this->assertSame($expected, HtmlParser::substituteSubpartArray($content, $subpartsContent));
+       }
+
+       /**
         * Data provider for substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray
+        *
+        * @return array
         */
        public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider() {
                $template = '###SINGLEMARKER1###
@@ -535,6 +579,12 @@ Value 2.2
 
        /**
         * @test
+        * @param string $template
+        * @param array $markersAndSubparts
+        * @param string $wrap
+        * @param bool $uppercase
+        * @param bool $deleteUnused
+        * @param string $expected
         * @dataProvider substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider
         */
        public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused, $expected) {
@@ -598,6 +648,8 @@ Value 2.2
 
        /**
         * @test
+        * @param string $content
+        * @param string $expectedResult
         * @dataProvider spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider
         */
        public function tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured($content, $expectedResult) {
@@ -629,6 +681,8 @@ Value 2.2
 
        /**
         * Data provider for localNestingCorrectlyRemovesInvalidTags
+        *
+        * @return array
         */
        public static function localNestingCorrectlyRemovesInvalidTagsDataProvider() {
                return array(
@@ -671,6 +725,8 @@ Value 2.2
 
        /**
         * Data provider for globalNestingCorrectlyRemovesInvalidTags
+        *
+        * @return array
         */
        public static function globalNestingCorrectlyRemovesInvalidTagsDataProvider() {
                return array(