Skip to content

Commit

Permalink
[TASK] Failing (and not-failing) tests for #646
Browse files Browse the repository at this point in the history
  • Loading branch information
zoliszabo committed Jan 3, 2019
1 parent e9446cf commit ba33460
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions tests/Unit/EmogrifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,70 @@ public function emogrifyBodyContentKeepsSpecialCharactersInTextNodes($codeNotToB
static::assertContains($codeNotToBeChanged, $result);
}

/**
* Provides a list of common template variable formats.
* To be extended...
*
* @return string[]
*/
private function templateVariablesProvider()
{
return ['{var}', '{$var}'];
}

/**
* Provides a list of elements & attributes which should not be URI-encoded.
*
* @return string[]
*/
private function elementsWithUriSpecificAttributesProvider()
{
return [
'a[href] + %s' => '<a href="%s"></a>',
'link[href] + %s' => '<link href="%s">',
'base[href] + %s' => '<base href="%s">',
'script[src] + %s' => '<script src="%s"></script>',
'form[action] + %s' => '<form action="%s"></form>',
'iframe[src] + %s' => '<iframe src="%s"></iframe>',
'iframe[srcdoc] + %s' => '<iframe srcdoc="%s"></iframe>',
'q[cite] + %s' => '<q cite="%s"></q>',
'blockquote[cite] + %s' => '<blockquote cite="%s"></blockquote>',
'ins[cite] + %s' => '<ins cite="%s"></ins>',
'del[cite] + %s' => '<del cite="%s"></del>',
];
}

/**
* @return string[][]
*/
public function attributesWithSpecialCharactersDataProvider()
{
$data = [];
foreach ($this->elementsWithUriSpecificAttributesProvider() as $nameTemplate => $attributeTemplate) {
foreach ($this->templateVariablesProvider() as $variable) {
$data[\sprintf($nameTemplate, $variable)] = [\sprintf($attributeTemplate, $variable)];
}
}
return $data;
}

/**
* @test
*
* @param string $codeNotToBeChanged
*
* @dataProvider attributesWithSpecialCharactersDataProvider
*/
public function emogrifyKeepsSpecialCharactersInUriSpecificAttributes($codeNotToBeChanged)
{
$html = '<html><p>' . $codeNotToBeChanged . '</p></html>';
$this->subject->setHtml($html);

$result = $this->subject->emogrify();

static::assertContains($codeNotToBeChanged, $result);
}

/**
* @test
*/
Expand Down

0 comments on commit ba33460

Please sign in to comment.