ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMailErrorFormatterTest Class Reference
+ Inheritance diagram for ilMailErrorFormatterTest:
+ Collaboration diagram for ilMailErrorFormatterTest:

Public Member Functions

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

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 $errorFormatter
 

Detailed Description

Definition at line 21 of file ilMailErrorFormatterTest.php.

Member Function Documentation

◆ errorCollectionProvider()

static ilMailErrorFormatterTest::errorCollectionProvider ( )
static

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

Definition at line 25 of file ilMailErrorFormatterTest.php.

References ilMailBaseTestCase\setGlobalVariable().

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  }
Class ilMailErrorFormatter.
setGlobalVariable(string $name, $value)
+ Here is the call graph for this function:

◆ testErrorFormatter()

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

errorCollectionProvider

Parameters
ilMailError[]$errors

Definition at line 75 of file ilMailErrorFormatterTest.php.

References ilMailBaseTestCase\brutallyTrimHTML().

75  : void
76  {
77  $this->assertSame($expectedHtml, $this->brutallyTrimHTML($this->errorFormatter->format($errors)));
78  }
brutallyTrimHTML(string $html)
+ 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: