ILIAS  release_8 Revision v8.24
ilHtmlPurifierLibWrapperTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
27class ilHtmlPurifierLibWrapperTest extends TestCase
28{
30 {
31 return new class () extends ilHtmlPurifierAbstractLibWrapper {
32 protected function getPurifierConfigInstance(): HTMLPurifier_Config
33 {
34 return HTMLPurifier_Config::createDefault();
35 }
36 };
37 }
38
40 {
41 $purifier = $this->getPurifier();
42
43 $this->assertSame('phpunit', $purifier->purify('phpunit'));
44
45 $toPurify = [
46 'phpunit1',
47 'phpunit2',
48 'phpunit3',
49 ];
50 $this->assertSame($toPurify, $purifier->purifyArray($toPurify));
51 }
52
53 public function invalidHtmlDataTypeProvider(): array
54 {
55 return [
56 'integer' => [5],
57 'float' => [0.1],
58 'null' => [null],
59 'array' => [[]],
60 'object' => [new stdClass()],
61 'bool' => [false],
62 'resource' => [fopen('php://memory', 'rb')],
63 ];
64 }
65
70 {
71 $this->expectException(InvalidArgumentException::class);
72
73 $purifier = $this->getPurifier();
74 $purifier->purifyArray([$element]);
75 }
76}
Abstract class wrapping the HTMLPurifier instance.
Class ilHtmlPurifierLibWrapperTest.
testExceptionIsRaisedIfNonStringElementsArePassedForHtmlBatchProcessing($element)
@dataProvider invalidHtmlDataTypeProvider