ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\LegalDocuments\test\HTMLPurifierTest Class Reference
+ Inheritance diagram for ILIAS\LegalDocuments\test\HTMLPurifierTest:
+ Collaboration diagram for ILIAS\LegalDocuments\test\HTMLPurifierTest:

Public Member Functions

 testConstruct ()
 
 testPurify (string $input, string $expected)
 

Static Public Member Functions

static documents ()
 

Private Member Functions

 isVsfStreamInstalled ()
 
 skipIfvfsStreamNotSupported ()
 

Detailed Description

Definition at line 30 of file HTMLPurifierTest.php.

Member Function Documentation

◆ documents()

static ILIAS\LegalDocuments\test\HTMLPurifierTest::documents ( )
static

Definition at line 60 of file HTMLPurifierTest.php.

60 : array
61 {
62 return [
63 'Simple HTML Elements' => [
64 '<h1><b>This</b> <i>is</i> <u>a</u> <em>Headline</em>!</h1><p>And a<br>paragraph.</p>',
65 '<h1><b>This</b> <i>is</i> <span style="text-decoration:underline;">a</span> <em>Headline</em>!</h1><p>And a<br />paragraph.</p>',
66 ],
67 'Simple HTML Elements with an Invalid Tag' => [
68 '<h1>This is a <a href="mailto:info@ilias.de">Headline</a>!</h1><p>And a paragraph with an invalid element: ILIAS e.V. <info@ilias.de>.</p>',
69 '<h1>This is a <a href="mailto:info@ilias.de">Headline</a>!</h1><p>And a paragraph with an invalid element: ILIAS e.V. .</p>',
70 ],
71 'Block Elements and Nested Lists' => [
72 '<div><ul><li>Php</li></ul><hr><ol><li>Unit</li></ol><dl><dt>Test</dt><dd><code>Success or Failure!</code></dd></dl></div>',
73 '<div><ul><li>Php</li></ul><hr /><ol><li>Unit</li></ol><dl><dt>Test</dt><dd><code>Success or Failure!</code></dd></dl></div>',
74 ],
75 'Blockquote' => [
76 '<pre>Text</pre><blockquote><cite><sup>Q</sup>uote</cite></blockquote>',
77 '<pre>Text</pre><blockquote><p><cite><sup>Q</sup>uote</cite></p></blockquote>',
78 ]
79 ];
80 }

◆ isVsfStreamInstalled()

ILIAS\LegalDocuments\test\HTMLPurifierTest::isVsfStreamInstalled ( )
private

Definition at line 82 of file HTMLPurifierTest.php.

82 : bool
83 {
84 return class_exists('org\bovigo\vfs\vfsStreamWrapper');
85 }

Referenced by ILIAS\LegalDocuments\test\HTMLPurifierTest\skipIfvfsStreamNotSupported().

+ Here is the caller graph for this function:

◆ skipIfvfsStreamNotSupported()

ILIAS\LegalDocuments\test\HTMLPurifierTest::skipIfvfsStreamNotSupported ( )
private

Definition at line 87 of file HTMLPurifierTest.php.

87 : void
88 {
89 if (!$this->isVsfStreamInstalled()) {
90 $this->markTestSkipped('Skipped test, vfsStream (https://github.com/bovigo/vfsStream) required');
91 }
92 }

References ILIAS\LegalDocuments\test\HTMLPurifierTest\isVsfStreamInstalled().

Referenced by ILIAS\LegalDocuments\test\HTMLPurifierTest\testConstruct(), and ILIAS\LegalDocuments\test\HTMLPurifierTest\testPurify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testConstruct()

ILIAS\LegalDocuments\test\HTMLPurifierTest::testConstruct ( )

Definition at line 32 of file HTMLPurifierTest.php.

32 : void
33 {
35 vfsStreamWrapper::register();
36 $root = vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
37 $cache_directory = vfsStream::newDirectory('HTMLPurifier')->at($root);
38 $cache_directory->chmod(0777);
39
40 $this->assertInstanceOf(HTMLPurifier::class, new HTMLPurifier([], vfsStream::url('root/HTMLPurifier')));
41 }

References ILIAS\LegalDocuments\test\HTMLPurifierTest\skipIfvfsStreamNotSupported().

+ Here is the call graph for this function:

◆ testPurify()

ILIAS\LegalDocuments\test\HTMLPurifierTest::testPurify ( string  $input,
string  $expected 
)

Definition at line 44 of file HTMLPurifierTest.php.

44 : void
45 {
47 vfsStreamWrapper::register();
48 $root = vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
49 $cache_directory = vfsStream::newDirectory('HTMLPurifier')->at($root);
50 $cache_directory->chmod(0777);
51
52 $instance = new HTMLPurifier([
53 'a', 'blockquote', 'br', 'cite', 'code', 'dd', 'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4',
54 'h5', 'h6', 'hr', 'img', 'li', 'ol', 'p', 'pre', 'span', 'strong', 'sub', 'sup', 'u', 'ul',
55 ], vfsStream::url('root/HTMLPurifier'));
56
57 $this->assertSame($expected, $instance->purify($input));
58 }

References ILIAS\LegalDocuments\test\HTMLPurifierTest\skipIfvfsStreamNotSupported().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: