Skip to content

Commit

Permalink
Rewrite test for raw entities input
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Jan 4, 2024
1 parent b56380f commit f501c5e
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/test/php/de/thekid/crews/unittest/MarkupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,27 @@ public function rewrites($input, $expected) {
Assert::equals($expected, $fixture->transform($input));
}

#[Test]
public function text_escaping() {
$fixture= new Markup();
Assert::equals('1 &lt; 2', $fixture->transform('1 < 2'));
}

#[Test, Values([
['Test &lt;&amp;&quot;&gt;&euro;&unknown; Works'],
['1 < 2'],
['1 & 2'],
['Test <&">&euro;&unknown; Works'],
])]
public function html_entities_are_escaped($input) {
public function does_not_contain_unescaped_entities($input) {
$fixture= new Markup();
Assert::equals('Test &lt;&amp;&quot;&gt;€&amp;unknown; Works', $fixture->transform($input));
$transformed= $fixture->transform($input);

foreach (['/</', '/>/', '/"/', '/&(?![a-z]+;)/'] as $pattern) {
Assert::equals(0, preg_match($pattern, $fixture->transform($input)));
}
}

#[Test]
public function html_entities_are_escaped() {
$fixture= new Markup();
Assert::equals(
'Test &lt;&amp;&quot;&gt;€&amp;unknown; Works',
$fixture->transform('Test &lt;&amp;&quot;&gt;&euro;&unknown; Works')
);
}

#[Test, Values([
Expand Down

0 comments on commit f501c5e

Please sign in to comment.