Skip to content

Commit

Permalink
Raise code coverage 100%.
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Feb 28, 2024
1 parent 4bbee12 commit d02abe8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/SanitizeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace PHPForge\Html\Tests\Helper;

use PHPForge\{Html\Helper\Sanitize, Support\Assert};
use PHPForge\{Html\Helper\Sanitize, Html\Helper\Tests\Support\InputWidget, Support\Assert};

final class SanitizeTest extends \PHPUnit\Framework\TestCase
{
Expand All @@ -22,7 +22,7 @@ public function testInitializate(): void
);
}

public function testSantizeXSS(): void
public function testHtml(): void
{
$this->assertSame(
'<a >click</a>',
Expand Down Expand Up @@ -65,4 +65,12 @@ public function testSantizeXSS(): void
)
);
}

public function testHtmlWithRenderInterface(): void
{
$this->assertSame(
'<input type="text" value="test" style="padding-left:20px" oinvalid="" />',
Sanitize::html(new InputWidget())
);
}
}
20 changes: 20 additions & 0 deletions tests/Support/InputWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Helper\Tests\Support;

use PHPForge\Html\Interop\RenderInterface;

final class InputWidget implements RenderInterface
{
public function __toString(): string
{
return $this->render();
}

public function render(): string
{
return '<input type="text" value="test" style="padding-left:20px" oinvalid="" onfocus="alert(\'XSS\')" />';
}
}

0 comments on commit d02abe8

Please sign in to comment.