ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceTrimmedDocumentPurifierTest Class Reference

Class ilTermsOfServiceTrimmedDocumentPurifierTest. More...

+ Inheritance diagram for ilTermsOfServiceTrimmedDocumentPurifierTest:
+ Collaboration diagram for ilTermsOfServiceTrimmedDocumentPurifierTest:

Public Member Functions

 stringsToTrimProvider ()
 
 stringElementsArrayToTrimProvider ()
 
 testSingleStringIsTrimmed (string $text, string $expectedResult)
 @dataProvider stringsToTrimProvider More...
 
 testArrayOfStringElementsIsTrimmed (array $texts, array $expectedResult)
 @dataProvider stringElementsArrayToTrimProvider More...
 

Additional Inherited Members

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

Detailed Description

Member Function Documentation

◆ stringElementsArrayToTrimProvider()

ilTermsOfServiceTrimmedDocumentPurifierTest::stringElementsArrayToTrimProvider ( )
Returns
array[]

Definition at line 24 of file ilTermsOfServiceTrimmedDocumentPurifierTest.php.

24 : array
25 {
26 return [
27 [[' phpunit '], ['phpunit'], ],
28 [["\n\r\tphpunit\n\r\t"], ['phpunit'], ],
29 ];
30 }

◆ stringsToTrimProvider()

ilTermsOfServiceTrimmedDocumentPurifierTest::stringsToTrimProvider ( )
Returns
array[]

Definition at line 13 of file ilTermsOfServiceTrimmedDocumentPurifierTest.php.

13 : array
14 {
15 return [
16 [' phpunit ', 'phpunit', ],
17 ["\n\r\tphpunit\n\r\t", 'phpunit', ],
18 ];
19 }

◆ testArrayOfStringElementsIsTrimmed()

ilTermsOfServiceTrimmedDocumentPurifierTest::testArrayOfStringElementsIsTrimmed ( array  $texts,
array  $expectedResult 
)

@dataProvider stringElementsArrayToTrimProvider

Parameters
string[]$texts
string[]$expectedResult

Definition at line 59 of file ilTermsOfServiceTrimmedDocumentPurifierTest.php.

60 {
61 $aggregated = $this
62 ->getMockBuilder(\ilHtmlPurifierInterface::class)
63 ->getMock();
64
65 $aggregated
66 ->expects($this->exactly(count($texts)))
67 ->method('purify')
68 ->with($this->isType('string'))
69 ->willReturnArgument(0);
70
71 $purifier = new \ilTermsOfServiceTrimmedDocumentPurifier($aggregated);
72
73 $this->assertEquals($expectedResult, $purifier->purifyArray($texts));
74 }

◆ testSingleStringIsTrimmed()

ilTermsOfServiceTrimmedDocumentPurifierTest::testSingleStringIsTrimmed ( string  $text,
string  $expectedResult 
)

@dataProvider stringsToTrimProvider

Parameters
string$text
string$expectedResult

Definition at line 37 of file ilTermsOfServiceTrimmedDocumentPurifierTest.php.

38 {
39 $aggregated = $this
40 ->getMockBuilder(\ilHtmlPurifierInterface::class)
41 ->getMock();
42
43 $aggregated
44 ->expects($this->once())
45 ->method('purify')
46 ->with($text)
47 ->willReturn($text);
48
49 $purifier = new \ilTermsOfServiceTrimmedDocumentPurifier($aggregated);
50
51 $this->assertEquals($expectedResult, $purifier->purify($text));
52 }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$text
Definition: errorreport.php:18

References $text, and Sabre\Event\once().

+ Here is the call graph for this function:

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