ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailAddressParserTest Class Reference

Class ilMailAddressParserTest. More...

+ Inheritance diagram for ilMailAddressParserTest:
+ Collaboration diagram for ilMailAddressParserTest:

Public Member Functions

 emailAddressesProvider ()
 
 emailInvalidAddressesProvider ()
 
 testBuiltInAddressParser (string $addresses, array $expected)
 
 testPearAddressParser (string $addresses, array $expected)
 
 testExceptionShouldBeRaisedIfEmailCannotBeParsedWithPearAddressParser (string $addresses)
 emailInvalidAddressesProvider More...
 
 testWrappingParserDelegatesParsingToAggregatedParser ()
 

Data Fields

const DEFAULT_HOST = 'ilias'
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from ilMailBaseTest
 setUp ()
 
 setGlobalVariable ($name, $value)
 
 assertException ($exception_class)
 

Detailed Description

Member Function Documentation

◆ emailAddressesProvider()

ilMailAddressParserTest::emailAddressesProvider ( )
Returns
array

Definition at line 23 of file ilMailAddressParserTest.php.

23  : array
24  {
25  return [
26  ['phpunit@' . self::DEFAULT_HOST . ',phpunit', [
27  new \ilMailAddress('phpunit', self::DEFAULT_HOST),
28  new \ilMailAddress('phpunit', self::DEFAULT_HOST)
29  ]],
30  ['phpunit@ilias.de', [
31  new \ilMailAddress('phpunit', 'ilias.de')
32  ]],
33  ['phpunit.@ilias.de',
34  [
35  new ilMailAddress('phpunit.', 'ilias.de')
36  ]
37  ],
38  ['#il_ml_4711', [
39  new \ilMailAddress('#il_ml_4711', self::DEFAULT_HOST)
40  ]],
41  ['#il_role_1000', [
42  new \ilMailAddress('#il_role_1000', self::DEFAULT_HOST)
43  ]],
44  ['#il_crs_member_998', [
45  new \ilMailAddress('#il_crs_member_998', self::DEFAULT_HOST)
46  ]],
47  ['#member@[French Course]', [
48  new \ilMailAddress('#member', '[French Course]')
49  ]],
50  ['Course Administrator <#admin@[Math Course]>', [
51  new \ilMailAddress('#admin', '[Math Course]')
52  ]],
53  ['Course Administrator <#il_crs_admin_2581>', [
54  new \ilMailAddress('#il_crs_admin_2581', self::DEFAULT_HOST)
55  ]],
56  ];
57  }
Class ilMailAddress.

◆ emailInvalidAddressesProvider()

ilMailAddressParserTest::emailInvalidAddressesProvider ( )
Returns
array[]

Definition at line 62 of file ilMailAddressParserTest.php.

62  : array
63  {
64  return [
65  ['phpunit"@'],
66  ['phpunit"@ilias.de'],
67  ];
68  }

◆ setUp()

ilMailAddressParserTest::setUp ( )
protected

Definition at line 15 of file ilMailAddressParserTest.php.

16  {
17  parent::setUp();
18  }

◆ testBuiltInAddressParser()

ilMailAddressParserTest::testBuiltInAddressParser ( string  $addresses,
array  $expected 
)
Parameters
string$addresses
array$expectedemailAddressesProvider

Definition at line 75 of file ilMailAddressParserTest.php.

References $parser.

76  {
77  if (!function_exists('imap_rfc822_parse_adrlist')) {
78  $this->markTestSkipped('Skipped test, imap extension required');
79  }
80 
81  $parser = new \ilMailImapRfc822AddressParser($addresses);
82  $parsedAddresses = $parser->parse();
83 
84  $this->assertCount(count($expected), $parsedAddresses);
85  $this->assertEquals($expected, $parsedAddresses);
86  }
$parser
Definition: BPMN2Parser.php:23

◆ testExceptionShouldBeRaisedIfEmailCannotBeParsedWithPearAddressParser()

ilMailAddressParserTest::testExceptionShouldBeRaisedIfEmailCannotBeParsedWithPearAddressParser ( string  $addresses)

emailInvalidAddressesProvider

Parameters
string$addresses

Definition at line 106 of file ilMailAddressParserTest.php.

References $parser.

106  : void
107  {
108  $this->expectException(ilMailException::class);
109 
111  $parser->parse();
112  }
Class ilMailPearRfc822WrapperAddressParser.
$parser
Definition: BPMN2Parser.php:23

◆ testPearAddressParser()

ilMailAddressParserTest::testPearAddressParser ( string  $addresses,
array  $expected 
)
Parameters
string$addresses
array$expectedemailAddressesProvider

Definition at line 93 of file ilMailAddressParserTest.php.

References $parser.

94  {
95  $parser = new \ilMailPearRfc822WrapperAddressParser($addresses);
96  $parsedAddresses = $parser->parse();
97 
98  $this->assertCount(count($expected), $parsedAddresses);
99  $this->assertEquals($expected, $parsedAddresses);
100  }
$parser
Definition: BPMN2Parser.php:23

◆ testWrappingParserDelegatesParsingToAggregatedParser()

ilMailAddressParserTest::testWrappingParserDelegatesParsingToAggregatedParser ( )

Definition at line 117 of file ilMailAddressParserTest.php.

References $parser, and Sabre\Event\once().

118  {
119  $wrappedParser = $this->getMockBuilder(\ilBaseMailRfc822AddressParser::class)
120  ->setConstructorArgs(['phpunit', 'ilias'])
121  ->getMock();
122  $wrappedParser->expects($this->once())->method('parse');
123 
124  $parser = new \ilMailRfc822AddressParser($wrappedParser);
125  $parser->parse();
126  }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
$parser
Definition: BPMN2Parser.php:23
+ Here is the call graph for this function:

Field Documentation

◆ DEFAULT_HOST

const ilMailAddressParserTest::DEFAULT_HOST = 'ilias'

Definition at line 10 of file ilMailAddressParserTest.php.


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