ILIAS  release_8 Revision v8.24
ilMailErrorFormatterTest Class Reference
+ Inheritance diagram for ilMailErrorFormatterTest:
+ Collaboration diagram for ilMailErrorFormatterTest:

Public Member Functions

 errorCollectionProvider ()
 
 testErrorFormatter (array $errors, string $expectedHtml)
 @dataProvider errorCollectionProvider More...
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from ilMailBaseTest
 brutallyTrimHTML (string $html)
 
 setUp ()
 
 tearDown ()
 
 setGlobalVariable (string $name, $value)
 

Private Attributes

ilMailErrorFormatter $errorFormatter
 

Detailed Description

Definition at line 21 of file ilMailErrorFormatterTest.php.

Member Function Documentation

◆ errorCollectionProvider()

ilMailErrorFormatterTest::errorCollectionProvider ( )

Definition at line 49 of file ilMailErrorFormatterTest.php.

49 : array
50 {
51 return [
52 'Zero errors' => [
53 [],
54 ''
55 ],
56 'Exactly one error' => [
57 [new ilMailError('error1')],
58 'error1'
59 ],
60 'Two errors' => [
61 [new ilMailError('error1'), new ilMailError('error2')],
62 'error1<ul><li>error2</li></ul>'
63 ],
64 'More than two errors with placeholders' => [
65 [new ilMailError('error1'), new ilMailError('error2'), new ilMailError('error3', ['a', 'b', 'c'])],
66 'error1<ul><li>error2</li><li>error3 (1. a/2. b/3. c)</li></ul>'
67 ],
68 ];
69 }
Class ilMailError.

◆ setUp()

ilMailErrorFormatterTest::setUp ( )
protected

Reimplemented from ilMailBaseTest.

Definition at line 25 of file ilMailErrorFormatterTest.php.

25 : void
26 {
27 parent::setUp();
28
29 $componentFactory = $this->getMockBuilder(ilComponentFactory::class)->getMock();
30
31 $this->setGlobalVariable('component.factory', $componentFactory);
32
33 $languageMock = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
34 $languageMock->method('txt')->willReturnCallback(static function (string $key): string {
35 if ('error1' === $key) {
36 return '-' . $key . '-';
37 }
38
39 if ('error3' === $key) {
40 return $key . ' (1. %s/2. %s/3. %s)';
41 }
42
43 return $key;
44 });
45
46 $this->errorFormatter = new ilMailErrorFormatter($languageMock);
47 }
setGlobalVariable(string $name, $value)
Class ilMailErrorFormatter.
string $key
Consumer key/client ID value.
Definition: System.php:193

References ILIAS\LTI\ToolProvider\$key, and ilMailBaseTest\setGlobalVariable().

+ Here is the call graph for this function:

◆ testErrorFormatter()

ilMailErrorFormatterTest::testErrorFormatter ( array  $errors,
string  $expectedHtml 
)

@dataProvider errorCollectionProvider

Parameters
ilMailError[]$errors
string$expectedHtml
Returns
void

Definition at line 77 of file ilMailErrorFormatterTest.php.

77 : void
78 {
79 $this->assertSame($expectedHtml, $this->brutallyTrimHTML($this->errorFormatter->format($errors)));
80 }
brutallyTrimHTML(string $html)
$errors
Definition: imgupload.php:65

References $errors, and ilMailBaseTest\brutallyTrimHTML().

+ Here is the call graph for this function:

Field Documentation

◆ $errorFormatter

ilMailErrorFormatter ilMailErrorFormatterTest::$errorFormatter
private

Definition at line 23 of file ilMailErrorFormatterTest.php.


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