[TASK] Add unit tests for HtmlParser->splitIntoBlock() 40/42840/5
authorMichael Oehlhof <typo3@oehlhof.de>
Sat, 22 Aug 2015 18:03:04 +0000 (20:03 +0200)
committerAlexander Opitz <opitz.alexander@googlemail.com>
Wed, 26 Aug 2015 06:45:36 +0000 (08:45 +0200)
Resolves: #69264
Releases: master
Change-Id: I73e1bd8894180658fd6911dbca0104518ceaf585
Reviewed-on: http://review.typo3.org/42840
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 03005cb..8cde01d 100644 (file)
@@ -312,6 +312,7 @@ hello
         * @param string $wrap A wrap value - [part 1] | [part 2] - for the markers before substitution
         * @param bool $uppercase If set, all marker string substitution is done with upper-case markers.
         * @param bool $deleteUnused If set, all unused marker are deleted.
+        * @param string $expected
         */
        public function substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused, $expected) {
                $this->assertSame($expected, HtmlParser::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused));
@@ -616,6 +617,76 @@ Value 2.2
        }
 
        /**
+        * Data provider for splitIntoBlock
+        *
+        * @return array
+        */
+       public function splitIntoBlockDataProvider() {
+               return array(
+                       'splitBlock' => array(
+                               'h1,span',
+                               '<body><h1>Title</h1><span>Note</span></body>',
+                               FALSE,
+                               array('<body>',
+                                       '<h1>Title</h1>',
+                                       '',
+                                       '<span>Note</span>',
+                                       '</body>')
+                       ),
+                       'splitBlock br' => array(
+                               'h1,span',
+                               '<body><h1>Title</h1><br /><span>Note</span><br /></body>',
+                               FALSE,
+                               array('<body>',
+                                       '<h1>Title</h1>',
+                                       '<br />',
+                                       '<span>Note</span>',
+                                       '<br /></body>')
+                       ),
+                       'splitBlock with attribute' => array(
+                               'h1,span',
+                               '<body><h1 class="title">Title</h1><span>Note</span></body>',
+                               FALSE,
+                               array('<body>',
+                                       '<h1 class="title">Title</h1>',
+                                       '',
+                                       '<span>Note</span>',
+                                       '</body>')
+                       ),
+                       'splitBlock span with attribute' => array(
+                               'span',
+                               '<body><h1>Title</h1><span class="title">Note</span></body>',
+                               FALSE,
+                               array('<body><h1>Title</h1>',
+                                       '<span class="title">Note</span>',
+                                       '</body>')
+                       ),
+                       'splitBlock without extra end tags' => array(
+                               'h1,span,div',
+                               '<body><h1>Title</h1><span>Note</span></body></div>',
+                               TRUE,
+                               array('<body>',
+                                       '<h1>Title</h1>',
+                                       '',
+                                       '<span>Note</span>',
+                                       '</body>')
+                       ),
+               );
+       }
+
+       /**
+        * @test
+        * @param string $tag List of tags, comma separated.
+        * @param string $content HTML-content
+        * @param bool $eliminateExtraEndTags If set, excessive end tags are ignored - you should probably set this in most cases.
+        * @param array $expected The expected result
+        * @dataProvider splitIntoBlockDataProvider
+        */
+       public function splitIntoBlock($tag, $content, $eliminateExtraEndTags, $expected) {
+               $this->assertSame($expected, $this->subject->splitIntoBlock($tag, $content, $eliminateExtraEndTags));
+       }
+
+       /**
         * @test
         * @param string $source
         * @param string $expected