[TASK] Add unit tests for HtmlParser::substituteMarker() 65/42765/4
authorMichael Oehlhof <typo3@oehlhof.de>
Wed, 19 Aug 2015 19:59:51 +0000 (21:59 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Thu, 20 Aug 2015 08:00:11 +0000 (10:00 +0200)
Resolves: #69196
Releases: master
Change-Id: I46a1f5f1ed0b7d2e0a2ceeb22768140771d99ffb
Reviewed-on: http://review.typo3.org/42765
Reviewed-by: Alexander Opitz <opitz.alexander@googlemail.com>
Tested-by: Alexander Opitz <opitz.alexander@googlemail.com>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php

index 769ee4a..3863251 100644 (file)
@@ -308,8 +308,38 @@ hello
                $this->assertSame($expected, HtmlParser::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused));
        }
 
+       /**
+        * Data provider for substituteMarker
+        */
+       public function substituteMarkerDataProvider() {
+               return array(
+                       'Single marker' => array(
+                               'This is a ###SAMPLE### text',
+                               '###SAMPLE###',
+                               'simple',
+                               'This is a simple text'
+                       ),
+                       'Double marker' => array(
+                               'This is a ###SAMPLE### text with a ###SAMPLE### content',
+                               '###SAMPLE###',
+                               'simple',
+                               'This is a simple text with a simple content'
+                       ),
+               );
+       }
 
-               /**
+       /**
+        * @dataProvider substituteMarkerDataProvider
+        * @param string $content The content stream, typically HTML template content.
+        * @param string $marker The marker string, typically on the form "###[the marker string]###
+        * @param mixed $markContent The content to insert instead of the marker string found.
+        * @param string $expected The expected result of the substitution
+        */
+       public function substituteMarker($content, $marker, $markContent, $expected) {
+               $this->assertSame($expected, HtmlParser::substituteMarker($content, $marker, $markContent));
+       }
+
+       /**
         * Data provider for substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray
         */
        public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider() {