ILIAS  release_8 Revision v8.24
ilTermsOfServiceTrimmedDocumentPurifierTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 public function stringsToTrimProvider(): array
28 {
29 return [
30 'Text with or without Spaces' => [' phpunit ', 'phpunit',],
31 'Text with or without Line Endings and Tabs' => ["\n\r\tphpunit\n\r\t", 'phpunit',],
32 ];
33 }
34
35 public function stringElementsArrayToTrimProvider(): array
36 {
37 return [
38 'Text with or without Spaces' => [[' phpunit '], ['phpunit'],],
39 'Text with or without Line Endings and Tabs' => [["\n\r\tphpunit\n\r\t"], ['phpunit'],],
40 ];
41 }
42
48 public function testSingleStringIsTrimmed(string $text, string $expectedResult): void
49 {
50 $aggregated = $this
51 ->getMockBuilder(ilHtmlPurifierInterface::class)
52 ->getMock();
53
54 $aggregated
55 ->expects($this->once())
56 ->method('purify')
57 ->with($text)
58 ->willReturn($text);
59
60 $purifier = new ilTermsOfServiceTrimmedDocumentPurifier($aggregated);
61
62 $this->assertSame($expectedResult, $purifier->purify($text));
63 }
64
70 public function testArrayOfStringElementsIsTrimmed(array $texts, array $expectedResult): void
71 {
72 $aggregated = $this
73 ->getMockBuilder(ilHtmlPurifierInterface::class)
74 ->getMock();
75
76 $aggregated
77 ->expects($this->exactly(count($texts)))
78 ->method('purify')
79 ->with($this->isType('string'))
80 ->willReturnArgument(0);
81
82 $purifier = new ilTermsOfServiceTrimmedDocumentPurifier($aggregated);
83
84 $this->assertSame($expectedResult, $purifier->purifyArray($texts));
85 }
86}
Class ilTermsOfServiceCriterionBaseTest.
Class ilTermsOfServiceTrimmedDocumentPurifierTest.
testArrayOfStringElementsIsTrimmed(array $texts, array $expectedResult)
@dataProvider stringElementsArrayToTrimProvider
testSingleStringIsTrimmed(string $text, string $expectedResult)
@dataProvider stringsToTrimProvider