ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilMailErrorFormatterTest Class Reference
+ Inheritance diagram for ilMailErrorFormatterTest:
+ Collaboration diagram for ilMailErrorFormatterTest:

Public Member Functions

 testErrorFormatter (array $errors, string $exteced_html)
 

Static Public Member Functions

static errorCollectionProvider ()
 

Protected Member Functions

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

Private Attributes

ilMailErrorFormatter $error_formatter
 

Detailed Description

Definition at line 23 of file ilMailErrorFormatterTest.php.

Member Function Documentation

◆ errorCollectionProvider()

static ilMailErrorFormatterTest::errorCollectionProvider ( )
static

Definition at line 51 of file ilMailErrorFormatterTest.php.

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

◆ setUp()

ilMailErrorFormatterTest::setUp ( )
protected

Reimplemented from ilMailBaseTestCase.

Definition at line 27 of file ilMailErrorFormatterTest.php.

27 : void
28 {
29 parent::setUp();
30
31 $component_factory = $this->getMockBuilder(ilComponentFactory::class)->getMock();
32
33 $this->setGlobalVariable('component.factory', $component_factory);
34
35 $language_mock = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
36 $language_mock->method('txt')->willReturnCallback(static function (string $key): string {
37 if ($key === 'error1') {
38 return '-' . $key . '-';
39 }
40
41 if ($key === 'error3') {
42 return $key . ' (1. %s/2. %s/3. %s)';
43 }
44
45 return $key;
46 });
47
48 $this->error_formatter = new ilMailErrorFormatter($language_mock);
49 }
setGlobalVariable(string $name, $value)

References ilMailBaseTestCase\setGlobalVariable().

+ Here is the call graph for this function:

◆ testErrorFormatter()

ilMailErrorFormatterTest::testErrorFormatter ( array  $errors,
string  $exteced_html 
)
Parameters
ilMailError[]$errors

Definition at line 77 of file ilMailErrorFormatterTest.php.

77 : void
78 {
79 $this->assertSame($exteced_html, $this->brutallyTrimHTML($this->error_formatter->format($errors)));
80 }
brutallyTrimHTML(string $html)

References ilMailBaseTestCase\brutallyTrimHTML().

+ Here is the call graph for this function:

Field Documentation

◆ $error_formatter

ilMailErrorFormatter ilMailErrorFormatterTest::$error_formatter
private

Definition at line 25 of file ilMailErrorFormatterTest.php.


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