ILIAS  release_8 Revision v8.25
ilTermsOfServiceDocumentHtmlPurifierTest Class Reference

Class ilTermsOfServiceDocumentHtmlPurifierTest. More...

+ Inheritance diagram for ilTermsOfServiceDocumentHtmlPurifierTest:
+ Collaboration diagram for ilTermsOfServiceDocumentHtmlPurifierTest:

Public Member Functions

 documentTextProvider ()
 
 testPurifyingWorksAsExpected (string $text, string $expected)
 @dataProvider documentTextProvider More...
 

Private Member Functions

 isVsfStreamInstalled ()
 
 skipIfvfsStreamNotSupported ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilTermsOfServiceCriterionBaseTest
 getRbacReviewMock ()
 
 getObjectDataCacheMock ()
 
 getRadioGroupMock ()
 
 getFormMock ()
 
 getUserMock ()
 
- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 setUp ()
 
 getLanguageMock ()
 
 getUiFactoryMock ()
 
 setGlobalVariable (string $name, $value)
 
 getCriterionConfig ($value=null)
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
Container $dic
 

Detailed Description

Member Function Documentation

◆ documentTextProvider()

ilTermsOfServiceDocumentHtmlPurifierTest::documentTextProvider ( )

Definition at line 41 of file ilTermsOfServiceDocumentHtmlPurifierTest.php.

41 : array
42 {
43 return [
44 'Simple HTML Elements' => [
45 '<h1><b>This</b> <i>is</i> <u>a</u> <em>Headline</em>!</h1><p>And a<br>paragraph.</p>',
46 '<h1><b>This</b> <i>is</i> <span style="text-decoration:underline;">a</span> <em>Headline</em>!</h1><p>And a<br />paragraph.</p>',
47 ],
48 'Simple HTML Elements with an Invalid Tag' => [
49 '<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>',
50 '<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>',
51 ],
52 'Block Elements and Nested Lists' => [
53 '<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>',
54 '<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>',
55 ],
56 'Blockquote' => [
57 '<pre>Text</pre><blockquote><cite><sup>Q</sup>uote</cite></blockquote>',
58 '<pre>Text</pre><blockquote><p><cite><sup>Q</sup>uote</cite></p></blockquote>',
59 ]
60 ];
61 }

◆ isVsfStreamInstalled()

ilTermsOfServiceDocumentHtmlPurifierTest::isVsfStreamInstalled ( )
private

Definition at line 29 of file ilTermsOfServiceDocumentHtmlPurifierTest.php.

29 : bool
30 {
31 return class_exists('org\bovigo\vfs\vfsStreamWrapper');
32 }

Referenced by skipIfvfsStreamNotSupported().

+ Here is the caller graph for this function:

◆ skipIfvfsStreamNotSupported()

ilTermsOfServiceDocumentHtmlPurifierTest::skipIfvfsStreamNotSupported ( )
private

Definition at line 34 of file ilTermsOfServiceDocumentHtmlPurifierTest.php.

34 : void
35 {
36 if (!$this->isVsfStreamInstalled()) {
37 $this->markTestSkipped('Skipped test, vfsStream (https://github.com/bovigo/vfsStream) required');
38 }
39 }

References isVsfStreamInstalled().

Referenced by testPurifyingWorksAsExpected().

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

◆ testPurifyingWorksAsExpected()

ilTermsOfServiceDocumentHtmlPurifierTest::testPurifyingWorksAsExpected ( string  $text,
string  $expected 
)

@dataProvider documentTextProvider

Parameters
string$text
string$expected

Definition at line 68 of file ilTermsOfServiceDocumentHtmlPurifierTest.php.

68 : void
69 {
71
72 vfs\vfsStreamWrapper::register();
73 $root = vfs\vfsStreamWrapper::setRoot(new vfs\vfsStreamDirectory('root'));
74 $cacheDirectory = vfs\vfsStream::newDirectory('HTMLPurifier')->at($root);
75 $cacheDirectory->chmod(0777);
76
78 [
79 'a',
80 'blockquote',
81 'br',
82 'cite',
83 'code',
84 'dd',
85 'div',
86 'dl',
87 'dt',
88 'em',
89 'h1',
90 'h2',
91 'h3',
92 'h4',
93 'h5',
94 'h6',
95 'hr',
96 'img',
97 'li',
98 'ol',
99 'p',
100 'pre',
101 'span',
102 'strong',
103 'sub',
104 'sup',
105 'u',
106 'ul'
107 ],
108 vfs\vfsStream::url('root/HTMLPurifier')
109 );
110 $this->assertSame($expected, $purifier->purify($text));
111 }

References skipIfvfsStreamNotSupported().

+ Here is the call graph for this function:

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