[TASK] Add unit tests for HtmlParser->removeFirstAndLastTag() 44/42844/4
authorMichael Oehlhof <typo3@oehlhof.de>
Sun, 23 Aug 2015 08:15:42 +0000 (10:15 +0200)
committerWouter Wolters <typo3@wouterwolters.nl>
Tue, 25 Aug 2015 17:45:35 +0000 (19:45 +0200)
Resolves: #69266
Releases: master
Change-Id: I8c35c1c175e632d2cba9fb6a495daf09486dc290
Reviewed-on: http://review.typo3.org/42844
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 739ab4e..03005cb 100644 (file)
@@ -826,4 +826,30 @@ Value 2.2
                $config = $this->subject->HTMLparserConfig($tsConfig);
                return $this->subject->HTMLcleaner($content, $config[0], $config[1], $config[2], $config[3]);
        }
+
+       /**
+        * @return array
+        */
+       public function removeFirstAndLastTagDataProvider() {
+               return array(
+                       array('<span>Wrapper<div>Some content</div></span>', 'Wrapper<div>Some content</div>'),
+                       array('<td><tr>Some content</tr></td>', '<tr>Some content</tr>'),
+                       array('Something before<span>Wrapper<div>Some content</div></span>Something after', 'Wrapper<div>Some content</div>'),
+                       array('<span class="hidden">Wrapper<div>Some content</div></span>', 'Wrapper<div>Some content</div>'),
+                       array('<span>Wrapper<div class="hidden">Some content</div></span>', 'Wrapper<div class="hidden">Some content</div>'),
+               );
+       }
+
+       /**
+        * Removes the first and last tag in the string
+        * Anything before the first and after the last tags respectively is also removed
+        *
+        * @test
+        * @dataProvider removeFirstAndLastTagDataProvider
+        * @param string $str String to process
+        * @param string $expectedResult
+        */
+       public function removeFirstAndLastTag($str, $expectedResult) {
+               $this->assertEquals($expectedResult, $this->subject->removeFirstAndLastTag($str));
+       }
 }