ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceTrimmedDocumentPurifierTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9{
13 public function stringsToTrimProvider() : array
14 {
15 return [
16 [' phpunit ', 'phpunit', ],
17 ["\n\r\tphpunit\n\r\t", 'phpunit', ],
18 ];
19 }
20
24 public function stringElementsArrayToTrimProvider() : array
25 {
26 return [
27 [[' phpunit '], ['phpunit'], ],
28 [["\n\r\tphpunit\n\r\t"], ['phpunit'], ],
29 ];
30 }
31
37 public function testSingleStringIsTrimmed(string $text, string $expectedResult)
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 }
53
59 public function testArrayOfStringElementsIsTrimmed(array $texts, array $expectedResult)
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 }
75}
An exception for terminatinating execution or to throw for unit testing.
Class ilTermsOfServiceCriterionBaseTest.
Class ilTermsOfServiceTrimmedDocumentPurifierTest.
testArrayOfStringElementsIsTrimmed(array $texts, array $expectedResult)
@dataProvider stringElementsArrayToTrimProvider
testSingleStringIsTrimmed(string $text, string $expectedResult)
@dataProvider stringsToTrimProvider
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$text
Definition: errorreport.php:18