From 33f8e84e701b30e33fe11d2cb7727b8d7b5c2a77 Mon Sep 17 00:00:00 2001 From: Giorgio Scalvini Date: Thu, 28 Sep 2023 08:45:19 +0200 Subject: [PATCH] Add tests for missing closure tag, missing open tag, paragraph closure, single tag and insecure tag --- tests/HTML_SafeTest.php | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/HTML_SafeTest.php b/tests/HTML_SafeTest.php index 288e69b..514399f 100644 --- a/tests/HTML_SafeTest.php +++ b/tests/HTML_SafeTest.php @@ -34,4 +34,53 @@ public function testSpecialChars() $this->assertSame($expectedOne, $safe->parse($inputOne)); $this->assertSame($expectedTwo, $safe->parse($inputTwo)); } + + public function testMissingClosureTag() + { + $input = '
my text with missing tag closure
'; + $expected = '
my text with missing tag closure
'; + + $safe = new HTML_Safe(); + $this->assertSame($expected, $safe->parse($input)); + } + + public function testMissingOpenTag() + { + $input = '
my text with missing tag opening
'; + $expected = '
my text with missing tag opening
'; + + $safe = new HTML_Safe(); + $this->assertSame($expected, $safe->parse($input)); + } + + public function testParagraphClosure() + { + $input = '

my first title

my text

my second title

'; + $expected = '

my first title

my text

my second title

'; + + $safe = new HTML_Safe(); + $this->assertSame($expected, $safe->parse($input)); + } + + public function testSingleTags() + { + $inputOne = 'Test image'; + $expectedOne = 'Test image'; + + $inputTwo = 'Test imageTEST'; + $expectedTwo = 'Test imageTEST'; + + $safe = new HTML_Safe(); + $this->assertSame($expectedOne, $safe->parse($inputOne)); + $this->assertSame($expectedTwo, $safe->parse($inputTwo)); + } + + public function testInsecureTags() + { + $input = '
Iframe content:
'; + $expected = '
Iframe content:
'; + + $safe = new HTML_Safe(); + $this->assertSame($expected, $safe->parse($input)); + } }