ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMailTransportSettingsTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
14  {
15  $mailOptions = $this->getMockBuilder(\ilMailOptions::class)
16  ->disableOriginalConstructor()
17  ->setMethods(array('updateOptions'))
18  ->getMock();
19 
20  $mailOptions->setIncomingType(0);
21  $mailOptions->setMailAddressOption(3);
22 
23  $setting = new ilMailTransportSettings($mailOptions);
24  $setting->adjust('test@ilias-test.de', 'someone@php-test.net');
25 
26 
27  $this->assertEquals(0, $mailOptions->getIncomingType());
28  $this->assertEquals(3, $mailOptions->getMailAddressOption());
29  }
30 
35  {
36  $mailOptions = $this->getMockBuilder(\ilMailOptions::class)
37  ->disableOriginalConstructor()
38  ->setMethods(array('updateOptions'))
39  ->getMock();
40 
41  $mailOptions->expects($this->once())->method('updateOptions');
42  $mailOptions->setIncomingType(2);
43  $mailOptions->setMailAddressOption(4);
44 
45  $setting = new ilMailTransportSettings($mailOptions);
46  $setting->adjust('test@ilias-test.de', '');
47 
48 
49  $this->assertEquals(3, $mailOptions->getMailAddressOption());
50  }
51 
56  {
57  $mailOptions = $this->getMockBuilder(\ilMailOptions::class)
58  ->disableOriginalConstructor()
59  ->setMethods(array('updateOptions'))
60  ->getMock();
61 
62  $mailOptions->expects($this->once())->method('updateOptions');
63  $mailOptions->setIncomingType(2);
64  $mailOptions->setMailAddressOption(3);
65 
66  $setting = new ilMailTransportSettings($mailOptions);
67  $setting->adjust('', 'test@ilias-test.de');
68 
69 
70  $this->assertEquals(4, $mailOptions->getMailAddressOption());
71  }
72 
77  {
78  $mailOptions = $this->getMockBuilder(\ilMailOptions::class)
79  ->disableOriginalConstructor()
80  ->setMethods(array('updateOptions'))
81  ->getMock();
82 
83  $mailOptions->expects($this->once())->method('updateOptions');
84  $mailOptions->setIncomingType(2);
85  $mailOptions->setMailAddressOption(3);
86 
87  $setting = new ilMailTransportSettings($mailOptions);
88  $setting->adjust('', '');
89 
90  $this->assertEquals(0, $mailOptions->getIncomingType());
91  }
92 
96  public function testNothingWillBeAdjusted()
97  {
98  $mailOptions = $this->getMockBuilder(\ilMailOptions::class)
99  ->disableOriginalConstructor()
100  ->setMethods(array('updateOptions'))
101  ->getMock();
102 
103  $mailOptions->expects($this->never())->method('updateOptions');
104  $mailOptions->setIncomingType(2);
105  $mailOptions->setMailAddressOption(5);
106 
107  $setting = new ilMailTransportSettings($mailOptions);
108  $setting->adjust('test@ilias-test.de', 'someone@php-test.net');
109 
110  $this->assertEquals(2, $mailOptions->getIncomingType());
111  $this->assertEquals(5, $mailOptions->getMailAddressOption());
112  }
113 }
Class ilMailTransportSettingsTest.
Class ilMailBaseTest.
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.