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

Public Member Functions

 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)
 
 stripEmptyTags (bool $stripOn, $tagList, bool $treatNonBreakingSpaceAsEmpty, string $content, string $expectedResult)
 
 stripEmptyTagsKeepsConfiguredTags (string $tagList, bool $treatNonBreakingSpaceAsEmpty, string $content, string $expectedResult)
 
 getFirstTag (string $str, string $expected)
 
 getFirstTagName (string $str, bool $preserveCase, string $expected)
 
 removeFirstAndLastTag (string $str, string $expectedResult)
 
 getTagAttributes (string $tag, array $expectedResult)
 
 rawStripEmptyTagsTest (string $content, string $tagList, bool $treatNonBreakingSpaceAsEmpty, string $expectedResult)
 
 prefixResourcePathTest (string $content, string $prefix, string $expectedResult)
 

Static Public Member Functions

static cDataWillRemainUnmodifiedDataProvider ()
 
static splitIntoBlockDataProvider ()
 
static htmlWithDifferentSingleTagsDataProvider ()
 
static spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider ()
 
static localNestingCorrectlyRemovesInvalidTagsDataProvider ()
 
static globalNestingCorrectlyRemovesInvalidTagsDataProvider ()
 
static emptyTagsDataProvider ()
 
static stripEmptyTagsKeepsConfiguredTagsDataProvider ()
 
static getFirstTagDataProvider ()
 
static getFirstTagNameDataProvider ()
 
static removeFirstAndLastTagDataProvider ()
 
static getTagAttributesDataProvider ()
 
static stripEmptyTagsDataProvider ()
 
static prefixResourcePathDataProvider ()
 

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 28 of file HtmlParserTest.php.

Member Function Documentation

◆ cDataWillRemainUnmodifiedDataProvider()

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

Definition at line 38 of file HtmlParserTest.php.

◆ emptyTagsDataProvider()

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

Definition at line 298 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...

Parameters
string$str‪HTML string with tags
string$expected‪The expected result.

Definition at line 461 of file HtmlParserTest.php.

◆ getFirstTagDataProvider()

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

Data provider for getFirstTag

Definition at line 426 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

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 531 of file HtmlParserTest.php.

◆ getFirstTagNameDataProvider()

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

Data provider for getFirstTagName

Definition at line 469 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

Parameters
string$tag‪String to process

Definition at line 623 of file HtmlParserTest.php.

◆ getTagAttributesDataProvider()

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

Definition at line 587 of file HtmlParserTest.php.

◆ globalNestingCorrectlyRemovesInvalidTags()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::globalNestingCorrectlyRemovesInvalidTags ( string  $content,
string  $expectedResult 
)

◆ globalNestingCorrectlyRemovesInvalidTagsDataProvider()

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

Data provider for globalNestingCorrectlyRemovesInvalidTags

Definition at line 261 of file HtmlParserTest.php.

◆ htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::htmlCleanerKeepsSingleTagsWithAndWithoutEndingSlashUnchanged ( string  $exampleString)

Definition at line 150 of file HtmlParserTest.php.

◆ htmlWithDifferentSingleTagsDataProvider()

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

Data provider for htmlCleanerCanHandleSingleTagsWithEndingSlashes

Definition at line 159 of file HtmlParserTest.php.

◆ localNestingCorrectlyRemovesInvalidTags()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::localNestingCorrectlyRemovesInvalidTags ( string  $content,
string  $expectedResult 
)

◆ localNestingCorrectlyRemovesInvalidTagsDataProvider()

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

Data provider for localNestingCorrectlyRemovesInvalidTags

Definition at line 221 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 417 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()

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

Definition at line 685 of file HtmlParserTest.php.

◆ prefixResourcePathTest()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::prefixResourcePathTest ( string  $content,
string  $prefix,
string  $expectedResult 
)

Definition at line 759 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.

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.

Definition at line 673 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

Parameters
string$str‪String to process

Definition at line 582 of file HtmlParserTest.php.

◆ removeFirstAndLastTagDataProvider()

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

Definition at line 536 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 32 of file HtmlParserTest.php.

◆ spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider()

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

Data provider for spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured

Definition at line 171 of file HtmlParserTest.php.

◆ splitIntoBlock()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::splitIntoBlock ( string  $tag,
string  $content,
bool  $eliminateExtraEndTags,
array  $expected 
)
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

Definition at line 135 of file HtmlParserTest.php.

◆ splitIntoBlockDataProvider()

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

Data provider for splitIntoBlock

Definition at line 63 of file HtmlParserTest.php.

◆ stripEmptyTags()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::stripEmptyTags ( bool  $stripOn,
  $tagList,
bool  $treatNonBreakingSpaceAsEmpty,
string  $content,
string  $expectedResult 
)
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 345 of file HtmlParserTest.php.

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

◆ stripEmptyTagsDataProvider()

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

Definition at line 628 of file HtmlParserTest.php.

◆ stripEmptyTagsKeepsConfiguredTags()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::stripEmptyTagsKeepsConfiguredTags ( string  $tagList,
bool  $treatNonBreakingSpaceAsEmpty,
string  $content,
string  $expectedResult 
)
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 391 of file HtmlParserTest.php.

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

◆ stripEmptyTagsKeepsConfiguredTagsDataProvider()

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

Definition at line 365 of file HtmlParserTest.php.

◆ tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured ( string  $content,
string  $expectedResult 
)

◆ xHtmlCleaningDoesNotModifyCDATA()

TYPO3\CMS\Core\Tests\Unit\Html\HtmlParserTest::xHtmlCleaningDoesNotModifyCDATA ( string  $source,
string  $expected 
)

Definition at line 142 of file HtmlParserTest.php.

Member Data Documentation

◆ $subject

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

Definition at line 30 of file HtmlParserTest.php.