TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
HtmlParserTest Class Reference
Inheritance diagram for HtmlParserTest:
UnitTestCase BaseTestCase

Public Member Functions

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

Static Public Member Functions

static spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider ()
 
static localNestingCorrectlyRemovesInvalidTagsDataProvider ()
 
static globalNestingCorrectlyRemovesInvalidTagsDataProvider ()
 

Protected Member Functions

 setUp ()
 
 parseConfigAndCleanHtml (array $tsConfig, $content)
 
- Protected Member Functions inherited from UnitTestCase
 tearDown ()
 
- Protected Member Functions inherited from BaseTestCase
 getAccessibleMock ($originalClassName, $methods=[], array $arguments=[], $mockClassName= '', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)
 
 getAccessibleMockForAbstractClass ($originalClassName, array $arguments=[], $mockClassName= '', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true, $mockedMethods=[])
 
 buildAccessibleProxy ($className)
 
 callInaccessibleMethod ($object, $name,...$arguments)
 
 inject ($target, $name, $dependency)
 
 getUniqueId ($prefix= '')
 

Protected Attributes

 $subject = null
 
- Protected Attributes inherited from UnitTestCase
 $backupGlobalsBlacklist = ['TYPO3_LOADED_EXT']
 
 $testFilesToDelete = []
 
- Protected Attributes inherited from BaseTestCase
 $backupGlobals = true
 
 $backupStaticAttributes = false
 

Detailed Description

Testcase for

Definition at line 22 of file HtmlParserTest.php.

Member Function Documentation

cDataWillRemainUnmodifiedDataProvider ( )
Returns
array

Definition at line 37 of file HtmlParserTest.php.

emptyTagsDataProvider ( )
Returns
array

Definition at line 294 of file HtmlParserTest.php.

getFirstTag (   $str,
  $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:
getFirstTagDataProvider
Parameters
string$strHTML string with tags
string$expectedThe expected result.

Definition at line 438 of file HtmlParserTest.php.

getFirstTagDataProvider ( )

Data provider for getFirstTag

Returns
array

Definition at line 418 of file HtmlParserTest.php.

getFirstTagName (   $str,
  $preserveCase,
  $expected 
)

Returns the NAME of the first tag in $str

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

Definition at line 482 of file HtmlParserTest.php.

getFirstTagNameDataProvider ( )

Data provider for getFirstTagName

Returns
array

Definition at line 448 of file HtmlParserTest.php.

getTagAttributes (   $tag,
  $expectedResult 
)

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

Test:
getTagAttributesDataProvider
Parameters
string$tagString to process
array$expectedResult

Definition at line 549 of file HtmlParserTest.php.

getTagAttributesDataProvider ( )
Returns
array

Definition at line 519 of file HtmlParserTest.php.

globalNestingCorrectlyRemovesInvalidTags (   $content,
  $expectedResult 
)
Test:
globalNestingCorrectlyRemovesInvalidTagsDataProvider
Parameters
string$content
string$expectedResult

Definition at line 282 of file HtmlParserTest.php.

References HtmlParserTest\parseConfigAndCleanHtml().

static globalNestingCorrectlyRemovesInvalidTagsDataProvider ( )
static

Data provider for globalNestingCorrectlyRemovesInvalidTags

Returns
array

Definition at line 250 of file HtmlParserTest.php.

localNestingCorrectlyRemovesInvalidTags (   $content,
  $expectedResult 
)
Test:
localNestingCorrectlyRemovesInvalidTagsDataProvider
Parameters
string$content
string$expectedResult

Definition at line 236 of file HtmlParserTest.php.

References HtmlParserTest\parseConfigAndCleanHtml().

static localNestingCorrectlyRemovesInvalidTagsDataProvider ( )
static

Data provider for localNestingCorrectlyRemovesInvalidTags

Returns
array

Definition at line 204 of file HtmlParserTest.php.

parseConfigAndCleanHtml ( array  $tsConfig,
  $content 
)
protected

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

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

Definition at line 407 of file HtmlParserTest.php.

Referenced by HtmlParserTest\globalNestingCorrectlyRemovesInvalidTags(), HtmlParserTest\localNestingCorrectlyRemovesInvalidTags(), HtmlParserTest\rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType(), HtmlParserTest\stripEmptyTags(), HtmlParserTest\stripEmptyTagsKeepsConfiguredTags(), and HtmlParserTest\tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured().

rawStripEmptyTagsTest (   $content,
  $tagList,
  $treatNonBreakingSpaceAsEmpty,
  $expectedResult 
)

Strips empty tags from HTML.

Test:
stripEmptyTagsDataProvider
Parameters
string$contentThe content to be stripped of empty tags
string$tagListThe comma separated list of tags to be stripped. If empty, all empty tags will be stripped
bool$treatNonBreakingSpaceAsEmptyIf TRUE tags containing only   entities will be treated as empty.
string$expectedResult

Definition at line 603 of file HtmlParserTest.php.

removeFirstAndLastTag (   $str,
  $expectedResult 
)

Removes the first and last tag in the string Anything before the first and after the last tags respectively is also removed

Test:
removeFirstAndLastTagDataProvider
Parameters
string$strString to process
string$expectedResult

Definition at line 511 of file HtmlParserTest.php.

removeFirstAndLastTagDataProvider ( )
Returns
array

Definition at line 490 of file HtmlParserTest.php.

rmTagIfNoAttribIsConfiguredDoesNotChangeNestingType ( )
Test:

Definition at line 187 of file HtmlParserTest.php.

References HtmlParserTest\parseConfigAndCleanHtml().

setUp ( )
protected

Definition at line 29 of file HtmlParserTest.php.

static spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider ( )
static

Data provider for spanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured

Definition at line 146 of file HtmlParserTest.php.

splitIntoBlock (   $tag,
  $content,
  $eliminateExtraEndTags,
  $expected 
)
Test:
Parameters
string$tagList of tags, comma separated.
string$contentHTML-content
bool$eliminateExtraEndTagsIf set, excessive end tags are ignored - you should probably set this in most cases.
array$expectedThe expected result splitIntoBlockDataProvider

Definition at line 126 of file HtmlParserTest.php.

splitIntoBlockDataProvider ( )

Data provider for splitIntoBlock

Returns
array

Definition at line 64 of file HtmlParserTest.php.

stripEmptyTags (   $stripOn,
  $tagList,
  $treatNonBreakingSpaceAsEmpty,
  $content,
  $expectedResult 
)
Test:
emptyTagsDataProvider
Parameters
bool$stripOnTRUE if stripping should be activated.
string$tagListComma separated list of tags that should be stripped.
bool$treatNonBreakingSpaceAsEmptyIf TRUE   will be considered empty.
string$contentThe HTML code that should be modified.
string$expectedResultThe expected HTML code result.

Definition at line 341 of file HtmlParserTest.php.

References HtmlParserTest\parseConfigAndCleanHtml().

stripEmptyTagsDataProvider ( )
Returns
array

Definition at line 557 of file HtmlParserTest.php.

stripEmptyTagsKeepsConfiguredTags (   $tagList,
  $treatNonBreakingSpaceAsEmpty,
  $content,
  $expectedResult 
)
Test:
stripEmptyTagsKeepsConfiguredTagsDataProvider
Parameters
string$tagListList of tags that should be kept, event if they are empty.
bool$treatNonBreakingSpaceAsEmptyIf true   will be considered empty.
string$contentThe HTML content that should be parsed.
string$expectedResultThe expected HTML code result.

Definition at line 385 of file HtmlParserTest.php.

References HtmlParserTest\parseConfigAndCleanHtml().

stripEmptyTagsKeepsConfiguredTagsDataProvider ( )
Returns
array

Definition at line 359 of file HtmlParserTest.php.

tagCorrectlyRemovedWhenRmTagIfNoAttribIsConfigured (   $content,
  $expectedResult 
)
Test:
Parameters
string$content
string$expectedResultspanTagCorrectlyRemovedWhenRmTagIfNoAttribIsConfiguredDataProvider

Definition at line 170 of file HtmlParserTest.php.

References HtmlParserTest\parseConfigAndCleanHtml().

xHtmlCleaningDoesNotModifyCDATA (   $source,
  $expected 
)
Test:
Parameters
string$source
string$expectedcDataWillRemainUnmodifiedDataProvider

Definition at line 137 of file HtmlParserTest.php.

Member Data Documentation

$subject = null
protected

Definition at line 27 of file HtmlParserTest.php.