ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilHtmlPurifierLibWrapperTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
25 {
26  private const array TO_PURIFY = [
27  'phpunit1',
28  'phpunit2',
29  'phpunit3',
30  ];
31 
33  {
34  return new class () extends ilHtmlPurifierAbstractLibWrapper {
35  protected function getPurifierConfigInstance(): HTMLPurifier_Config
36  {
37  return HTMLPurifier_Config::createDefault();
38  }
39  };
40  }
41 
43  {
44  $purifier = $this->getPurifier();
45 
46  $this->assertSame('phpunit', $purifier->purify('phpunit'));
47  $this->assertSame(self::TO_PURIFY, $purifier->purifyArray(self::TO_PURIFY));
48  }
49 
53  public static 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 
66  #[DataProvider('invalidHtmlDataTypeProvider')]
68  {
69  $this->expectException(InvalidArgumentException::class);
70 
71  $purifier = $this->getPurifier();
72  $purifier->purifyArray([$element]);
73  }
74 }
testExceptionIsRaisedIfNonStringElementsArePassedForHtmlBatchProcessing($element)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null