From 051996db56c4a3e1288d07d1c4950249f0cc8911 Mon Sep 17 00:00:00 2001 From: Michael Oehlhof Date: Mon, 17 Aug 2015 01:15:59 +0200 Subject: [PATCH] [TASK] Add unit tests for HtmlParser::getSubpart() Resolves: #69116 Releases: master Change-Id: I07d4d04d2108976287617b458c0f9857099c2ada Reviewed-on: http://review.typo3.org/42667 Reviewed-by: Wouter Wolters Tested-by: Wouter Wolters Reviewed-by: Michael Oehlhof Tested-by: Michael Oehlhof Reviewed-by: Markus Klein Tested-by: Markus Klein --- .../core/Tests/Unit/Html/HtmlParserTest.php | 81 ++++++++++++++++++- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php b/typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php index 64171354be9c..f0ea5ae0fce1 100644 --- a/typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php +++ b/typo3/sysext/core/Tests/Unit/Html/HtmlParserTest.php @@ -14,6 +14,8 @@ namespace TYPO3\CMS\Core\Tests\Unit\Html; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Html\HtmlParser; + /** * Testcase for \TYPO3\CMS\Core\Html\HtmlParser */ @@ -25,7 +27,82 @@ class HtmlParserTest extends \TYPO3\CMS\Core\Tests\UnitTestCase { protected $subject = NULL; protected function setUp() { - $this->subject = new \TYPO3\CMS\Core\Html\HtmlParser(); + $this->subject = new HtmlParser(); + } + + /** + * Data provider for getSubpart + * + * @return array + */ + public function getSubpartDataProvider() { + return array( + 'No start marker' => array( + 'text', + '###SUBPART###', + '' + ), + 'No stop marker' => array( + ' + +text +', + '###SUBPART###', + '' + ), + 'Start and stop marker in HTML comment' => array( + ' + +text + +', + '###SUBPART###', + ' +text +' + ), + 'Stop marker in HTML comment' => array( + ' +###SUBPART### +text + +', + '###SUBPART###', + ' +text +' + ), + 'Start marker in HTML comment' => array( + ' + +text +###SUBPART### +', + '###SUBPART###', + ' +text +' + ), + 'Start and stop marker direct' => array( + ' +###SUBPART### +text +###SUBPART### +', + '###SUBPART###', + ' +text +' + ), + ); + } + + /** + * @test + * @dataProvider getSubpartDataProvider + */ + public function getSubpart($content, $marker, $expected) { + $this->assertSame($expected, HtmlParser::getSubpart($content, $marker)); } /** @@ -227,7 +304,7 @@ Value 2.2 * @dataProvider substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider */ public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused, $expected) { - $this->assertSame($expected, $this->subject->substituteMarkerAndSubpartArrayRecursive($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused)); + $this->assertSame($expected, HtmlParser::substituteMarkerAndSubpartArrayRecursive($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused)); } /** -- 2.20.1