‪TYPO3CMS  11.5
TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest Class Reference
Inheritance diagram for TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest:

Public Member Functions

array cDataWillRemainUnmodifiedDataProvider ()
 
array splitIntoBlockDataProvider ()
 
 splitIntoBlock (string $tag, string $content, bool $eliminateExtraEndTags, array $expected)
 
 xHtmlCleaningDoesNotModifyCDATA (string $source, string $expected)
 
 htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged (string $exampleString)
 
 tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured (string $content, string $expectedResult)
 
 rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType ()
 
 localNestingCorrectlyRemovesInvalidTags (string $content, string $expectedResult)
 
 globalNestingCorrectlyRemovesInvalidTags (string $content, string $expectedResult)
 
array emptyTagsDataProvider ()
 
 stripEmptyTags (bool $stripOn, $tagList, bool $treatNonBreakingSpaceAsEmpty, string $content, string $expectedResult)
 
array stripEmptyTagsKeepsConfiguredTagsDataProvider ()
 
 stripEmptyTagsKeepsConfiguredTags (string $tagList, bool $treatNonBreakingSpaceAsEmpty, string $content, string $expectedResult)
 
array getFirstTagDataProvider ()
 
 getFirstTag (string $str, string $expected)
 
array getFirstTagNameDataProvider ()
 
 getFirstTagName (string $str, bool $preserveCase, string $expected)
 
array removeFirstAndLastTagDataProvider ()
 
 removeFirstAndLastTag (string $str, string $expectedResult)
 
array getTagAttributesDataProvider ()
 
 getTagAttributes (string $tag, array $expectedResult)
 
array stripEmptyTagsDataProvider ()
 
 rawStripEmptyTagsTest (string $content, string $tagList, bool $treatNonBreakingSpaceAsEmpty, string $expectedResult)
 
 prefixResourcePathDataProvider ()
 
 prefixResourcePathTest (string $content, string $prefix, string $expectedResult)
 

Static Public Member Functions

static htmlWithDifferentSingleTagsDataProvider ()
 
static spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider ()
 
static array localNestingCorrectlyRemovesInvalidTagsDataProvider ()
 
static array globalNestingCorrectlyRemovesInvalidTagsDataProvider ()
 

Protected Member Functions

 setUp ()
 
string parseConfigAndCleanHtml (array $tsConfig, string $content)
 

Protected Attributes

HtmlParser $subject
 

Detailed Description

Testcase for \TYPO3\CMS\Core\Html\HtmlParser

Definition at line 26 of file HtmlParserTest.php.

Member Function Documentation

◆ cDataWillRemainUnmodifiedDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::cDataWillRemainUnmodifiedDataProvider ( )
Returns
‪array

Definition at line 39 of file HtmlParserTest.php.

◆ emptyTagsDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::emptyTagsDataProvider ( )
Returns
‪array

Definition at line 328 of file HtmlParserTest.php.

◆ getFirstTag()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::getFirstTag ( string  $str,
string  $expected 
)

Returns the first tag in $str Actually everything from the beginning of the $str is returned, so you better make sure the tag is the first thing...

Test:
‪@dataProvider getFirstTagDataProvider
Parameters
string$str‪HTML string with tags
string$expected‪The expected result.

Definition at line 496 of file HtmlParserTest.php.

◆ getFirstTagDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::getFirstTagDataProvider ( )

Data provider for getFirstTag

Returns
‪array

Definition at line 461 of file HtmlParserTest.php.

◆ getFirstTagName()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::getFirstTagName ( string  $str,
bool  $preserveCase,
string  $expected 
)

Returns the NAME of the first tag in $str

Test:
‪@dataProvider getFirstTagNameDataProvider
Parameters
string$str‪HTML tag (The element name MUST be separated from the attributes by a space character! Just whitespace will not do)
bool$preserveCase‪If set, then the tag is NOT converted to uppercase by case is preserved.
string$expected‪The expected result.

Definition at line 568 of file HtmlParserTest.php.

◆ getFirstTagNameDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::getFirstTagNameDataProvider ( )

Data provider for getFirstTagName

Returns
‪array

Definition at line 506 of file HtmlParserTest.php.

◆ getTagAttributes()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::getTagAttributes ( string  $tag,
array  $expectedResult 
)

Returns an array with all attributes and its meta information from a tag. Removes tag-name if found

Test:
‪@dataProvider getTagAttributesDataProvider
Parameters
string$tag‪String to process
array$expectedResult

Definition at line 668 of file HtmlParserTest.php.

◆ getTagAttributesDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::getTagAttributesDataProvider ( )
Returns
‪array

Definition at line 631 of file HtmlParserTest.php.

◆ globalNestingCorrectlyRemovesInvalidTags()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::globalNestingCorrectlyRemovesInvalidTags ( string  $content,
string  $expectedResult 
)
Test:
‪@dataProvider globalNestingCorrectlyRemovesInvalidTagsDataProvider
Parameters
string$content
string$expectedResult

Definition at line 316 of file HtmlParserTest.php.

References TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\parseConfigAndCleanHtml().

◆ globalNestingCorrectlyRemovesInvalidTagsDataProvider()

static array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::globalNestingCorrectlyRemovesInvalidTagsDataProvider ( )
static

Data provider for globalNestingCorrectlyRemovesInvalidTags

Returns
‪array

Definition at line 284 of file HtmlParserTest.php.

◆ htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged ( string  $exampleString)
Test:
‪@dataProvider htmlWithDifferentSingleTagsDataProvider

Definition at line 159 of file HtmlParserTest.php.

◆ htmlWithDifferentSingleTagsDataProvider()

static TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::htmlWithDifferentSingleTagsDataProvider ( )
static

Data provider for htmlCleanerCanHandleSingleTagsWithEndingSlashes

Definition at line 168 of file HtmlParserTest.php.

◆ localNestingCorrectlyRemovesInvalidTags()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::localNestingCorrectlyRemovesInvalidTags ( string  $content,
string  $expectedResult 
)
Test:
‪@dataProvider localNestingCorrectlyRemovesInvalidTagsDataProvider
Parameters
string$content
string$expectedResult

Definition at line 270 of file HtmlParserTest.php.

References TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\parseConfigAndCleanHtml().

◆ localNestingCorrectlyRemovesInvalidTagsDataProvider()

static array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::localNestingCorrectlyRemovesInvalidTagsDataProvider ( )
static

Data provider for localNestingCorrectlyRemovesInvalidTags

Returns
‪array

Definition at line 238 of file HtmlParserTest.php.

◆ parseConfigAndCleanHtml()

string TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::parseConfigAndCleanHtml ( array  $tsConfig,
string  $content 
)
protected

Calls HTMLparserConfig() and passes the generated config to the HTMLcleaner() method on the current subject.

Parameters
array$tsConfig‪The TypoScript that should be used to generate the HTML parser config.
string$content‪The content that should be parsed by the HTMLcleaner.
Returns
‪string The parsed content.

Definition at line 450 of file HtmlParserTest.php.

Referenced by TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\globalNestingCorrectlyRemovesInvalidTags(), TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\localNestingCorrectlyRemovesInvalidTags(), TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType(), TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\stripEmptyTags(), TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\stripEmptyTagsKeepsConfiguredTags(), and TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured().

◆ prefixResourcePathDataProvider()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::prefixResourcePathDataProvider ( )

Definition at line 734 of file HtmlParserTest.php.

◆ prefixResourcePathTest()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::prefixResourcePathTest ( string  $content,
string  $prefix,
string  $expectedResult 
)
Test:
‪@dataProvider prefixResourcePathDataProvider

Definition at line 810 of file HtmlParserTest.php.

◆ rawStripEmptyTagsTest()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::rawStripEmptyTagsTest ( string  $content,
string  $tagList,
bool  $treatNonBreakingSpaceAsEmpty,
string  $expectedResult 
)

Strips empty tags from HTML.

Test:
‪@dataProvider stripEmptyTagsDataProvider
Parameters
string$content‪The content to be stripped of empty tags
string$tagList‪The comma separated list of tags to be stripped. If empty, all empty tags will be stripped
bool$treatNonBreakingSpaceAsEmpty‪If TRUE tags containing only   entities will be treated as empty.
string$expectedResult

Definition at line 722 of file HtmlParserTest.php.

◆ removeFirstAndLastTag()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::removeFirstAndLastTag ( string  $str,
string  $expectedResult 
)

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
Parameters
string$str‪String to process
string$expectedResult

Definition at line 623 of file HtmlParserTest.php.

◆ removeFirstAndLastTagDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::removeFirstAndLastTagDataProvider ( )
Returns
‪array

Definition at line 576 of file HtmlParserTest.php.

◆ rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType ( )

◆ setUp()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::setUp ( )
protected

Definition at line 30 of file HtmlParserTest.php.

◆ spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider()

static TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider ( )
static

Data provider for spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured

Definition at line 180 of file HtmlParserTest.php.

◆ splitIntoBlock()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::splitIntoBlock ( string  $tag,
string  $content,
bool  $eliminateExtraEndTags,
array  $expected 
)
Test:
Parameters
string$tag‪List of tags, comma separated.
string$content‪HTML-content
bool$eliminateExtraEndTags‪If set, excessive end tags are ignored - you should probably set this in most cases.
array$expected‪The expected result @dataProvider splitIntoBlockDataProvider

Definition at line 138 of file HtmlParserTest.php.

◆ splitIntoBlockDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::splitIntoBlockDataProvider ( )

Data provider for splitIntoBlock

Returns
‪array

Definition at line 66 of file HtmlParserTest.php.

◆ stripEmptyTags()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::stripEmptyTags ( bool  $stripOn,
  $tagList,
bool  $treatNonBreakingSpaceAsEmpty,
string  $content,
string  $expectedResult 
)
Test:
‪@dataProvider emptyTagsDataProvider
Parameters
bool$stripOn‪TRUE if stripping should be activated.
string | bool$tagList‪Comma separated list of tags that should be stripped.
bool$treatNonBreakingSpaceAsEmpty‪If TRUE   will be considered empty.
string$content‪The HTML code that should be modified.
string$expectedResult‪The expected HTML code result.

Definition at line 375 of file HtmlParserTest.php.

References TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\parseConfigAndCleanHtml().

◆ stripEmptyTagsDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::stripEmptyTagsDataProvider ( )
Returns
‪array

Definition at line 676 of file HtmlParserTest.php.

◆ stripEmptyTagsKeepsConfiguredTags()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::stripEmptyTagsKeepsConfiguredTags ( string  $tagList,
bool  $treatNonBreakingSpaceAsEmpty,
string  $content,
string  $expectedResult 
)
Test:
‪@dataProvider stripEmptyTagsKeepsConfiguredTagsDataProvider
Parameters
string$tagList‪List of tags that should be kept, event if they are empty.
bool$treatNonBreakingSpaceAsEmpty‪If true   will be considered empty.
string$content‪The HTML content that should be parsed.
string$expectedResult‪The expected HTML code result.

Definition at line 424 of file HtmlParserTest.php.

References TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\parseConfigAndCleanHtml().

◆ stripEmptyTagsKeepsConfiguredTagsDataProvider()

array TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::stripEmptyTagsKeepsConfiguredTagsDataProvider ( )
Returns
‪array

Definition at line 398 of file HtmlParserTest.php.

◆ tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured ( string  $content,
string  $expectedResult 
)
Test:
Parameters
string$content
string$expectedResult‪@dataProvider spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider

Definition at line 204 of file HtmlParserTest.php.

References TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest\parseConfigAndCleanHtml().

◆ xHtmlCleaningDoesNotModifyCDATA()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::xHtmlCleaningDoesNotModifyCDATA ( string  $source,
string  $expected 
)
Test:
Parameters
string$source
string$expected‪@dataProvider cDataWillRemainUnmodifiedDataProvider

Definition at line 149 of file HtmlParserTest.php.

Member Data Documentation

◆ $subject

HtmlParser TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::$subject
protected

Definition at line 28 of file HtmlParserTest.php.