ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilHtmlPurifierLibWrapperTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 class 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 }
testExceptionIsRaisedIfNonStringElementsArePassedForHtmlBatchProcessing($element)
invalidHtmlDataTypeProvider
Abstract class wrapping the HTMLPurifier instance.
Class ilHtmlPurifierLibWrapperTest.