ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceDocumentHtmlPurifierTest Class Reference

Class ilTermsOfServiceDocumentHtmlPurifierTest. More...

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

Public Member Functions

 documentTextProvider ()
 
 testPurifyingWorksAsExpected (string $text, string $expected)
 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
 $dic
 

Detailed Description

Member Function Documentation

◆ documentTextProvider()

ilTermsOfServiceDocumentHtmlPurifierTest::documentTextProvider ( )
Returns
array

Definition at line 33 of file ilTermsOfServiceDocumentHtmlPurifierTest.php.

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

◆ isVsfStreamInstalled()

ilTermsOfServiceDocumentHtmlPurifierTest::isVsfStreamInstalled ( )
private
Returns
bool

Definition at line 15 of file ilTermsOfServiceDocumentHtmlPurifierTest.php.

Referenced by skipIfvfsStreamNotSupported().

15  : bool
16  {
17  return class_exists('org\bovigo\vfs\vfsStreamWrapper');
18  }
+ Here is the caller graph for this function:

◆ skipIfvfsStreamNotSupported()

ilTermsOfServiceDocumentHtmlPurifierTest::skipIfvfsStreamNotSupported ( )
private

Definition at line 23 of file ilTermsOfServiceDocumentHtmlPurifierTest.php.

References isVsfStreamInstalled().

Referenced by testPurifyingWorksAsExpected().

23  : void
24  {
25  if (!$this->isVsfStreamInstalled()) {
26  $this->markTestSkipped('Skipped test, vfsStream (http://vfs.bovigo.org) required');
27  }
28  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testPurifyingWorksAsExpected()

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

documentTextProvider

Parameters
string$text
string$expected
Exceptions
vfs

Definition at line 61 of file ilTermsOfServiceDocumentHtmlPurifierTest.php.

References skipIfvfsStreamNotSupported().

61  : void
62  {
64 
65  vfs\vfsStreamWrapper::register();
66  $root = vfs\vfsStreamWrapper::setRoot(new vfs\vfsStreamDirectory('root'));
67  $cacheDirectory = vfs\vfsStream::newDirectory('HTMLPurifier')->at($root);
68  $cacheDirectory->chmod(0777);
69 
71  [
72  "a",
73  "blockquote",
74  "br",
75  "cite",
76  "code",
77  "dd",
78  "div",
79  "dl",
80  "dt",
81  "em",
82  "h1",
83  "h2",
84  "h3",
85  "h4",
86  "h5",
87  "h6",
88  "hr",
89  "img",
90  "li",
91  "ol",
92  "p",
93  "pre",
94  "span",
95  "strong",
96  "sub",
97  "sup",
98  "u",
99  "ul"
100  ],
101  vfs\vfsStream::url('root/HTMLPurifier')
102  );
103  $this->assertEquals($expected, $purifier->purify($text));
104  }
Class ilTermsOfServiceDocumentHtmlPurifier.
+ Here is the call graph for this function:

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