ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ValidHTMLTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use PHPUnit\Framework\TestCase;
25use PHPUnit\Framework\Attributes\DataProvider;
26
27class ValidHTMLTest extends TestCase
28{
29 public function testConstruct(): void
30 {
31 $this->assertInstanceOf(ValidHTML::class, new ValidHTML());
32 }
33
34 #[DataProvider('textProvider')]
35 public function testIsTrue(string $text, bool $result): void
36 {
37 $instance = new ValidHTML();
38 $this->assertSame($result, $instance->isTrue($text));
39 }
40
41 public static function textProvider(): array
42 {
43 return [
44 'Plain Text' => ['phpunit', false],
45 'HTML Fragment' => ['php<b>unit</b>', true],
46 'HTML Fragment with Email Address Wrapped in <>' => ['php<b>unit</b> <info@ilias.de>', false],
47 'HTML' => ['<html><body>php<b>unit</b></body></html>', true],
48 'HTML with Email Address Wrapped in <>' => ['<html><body>php<b>unit</b>Php Unit <info@ilias.de></body></html>', false],
49 'HTML with Unsupported Entities' => ['<html><body>php<b>unit</b>Php Unit<figure></figure></body></html>', true],
50 'Invalid HTML' => ['<html><body>php<b>unit</b>Php Unit<div </body></html>', false],
51 ];
52 }
53}
testIsTrue(string $text, bool $result)