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

Class ilMailMimeTest. More...

+ Inheritance diagram for ilMailMimeTest:
+ Collaboration diagram for ilMailMimeTest:

Public Member Functions

 testMimMailDelegatesEmailDeliveryToThePassedTransporter ()
 
 testMimMailDelegatesEmailDeliveryToDefaultTransport ()
 
 testTransportFactoryWillReturnNullTransportIfExternalEmailDeliveryIsDisabled ()
 
 testTransportFactoryWillReturnSmtpTransportIfEnabled ()
 
 testTransportFactoryWillReturnSendmailTransportIfSmtpTransportIsDisabled ()
 
 testFactoryWillReturnSystemSenderForAnonymousUserId ()
 
 testFactoryWillReturnSystemSenderWhenExplicitlyRequested ()
 
 testFactoryWillReturnUserSenderForExistingUserId ()
 
 testFactoryWillReturnUserSenderWhenExplicitlyRequested ()
 

Data Fields

const USER_ID = 6
 

Protected Member Functions

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

Detailed Description

Class ilMailMimeTest.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 8 of file ilMailMimeTest.php.

Member Function Documentation

◆ getUserById()

ilMailMimeTest::getUserById (   $usrId)
protected
Parameters
int$usrId
Returns

Definition at line 195 of file ilMailMimeTest.php.

References $user.

Referenced by setUp().

196  {
197  $user = $this->getMockBuilder(\ilObjUser::class)->disableOriginalConstructor()->setMethods(
198  array()
199  )->getMock();
200  $user->expects($this->any())->method('getId')->will($this->returnValue($usrId));
201 
202  return $user;
203  }
$user
Definition: migrateto20.php:57
+ Here is the caller graph for this function:

◆ setUp()

ilMailMimeTest::setUp ( )
protected

Definition at line 15 of file ilMailMimeTest.php.

References ilMailMimeSenderUser\addUserToCache(), getUserById(), and ilMimeMail\setDefaultTransport().

16  {
17  if (!defined('ANONYMOUS_USER_ID')) {
18  define('ANONYMOUS_USER_ID', 13);
19  }
20 
22  \ilMailMimeSenderUser::addUserToCache(self::USER_ID, $this->getUserById(self::USER_ID));
23 
24  parent::setUp();
25  }
static setDefaultTransport($transport)
static addUserToCache($usrId, \ilObjUser $user)
+ Here is the call graph for this function:

◆ testFactoryWillReturnSystemSenderForAnonymousUserId()

ilMailMimeTest::testFactoryWillReturnSystemSenderForAnonymousUserId ( )

Definition at line 166 of file ilMailMimeTest.php.

References $factory.

167  {
168  $settings = $this->getMockBuilder(\ilSetting::class)->disableOriginalConstructor()->setMethods(array(
169  'set',
170  'get'
171  ))->getMock();
172 
173  $factory = new \ilMailMimeSenderFactory($settings);
174  $this->assertInstanceOf('\ilMailMimeSenderSystem', $factory->getSenderByUsrId(\ANONYMOUS_USER_ID));
175  }
$factory
Definition: metadata.php:43

◆ testFactoryWillReturnSystemSenderWhenExplicitlyRequested()

ilMailMimeTest::testFactoryWillReturnSystemSenderWhenExplicitlyRequested ( )

Definition at line 180 of file ilMailMimeTest.php.

References $factory.

181  {
182  $settings = $this->getMockBuilder(\ilSetting::class)->disableOriginalConstructor()->setMethods(array(
183  'set',
184  'get'
185  ))->getMock();
186 
187  $factory = new \ilMailMimeSenderFactory($settings);
188  $this->assertInstanceOf('\ilMailMimeSenderSystem', $factory->system());
189  }
$factory
Definition: metadata.php:43

◆ testFactoryWillReturnUserSenderForExistingUserId()

ilMailMimeTest::testFactoryWillReturnUserSenderForExistingUserId ( )

Definition at line 208 of file ilMailMimeTest.php.

References $factory.

209  {
210  $settings = $this->getMockBuilder(\ilSetting::class)->disableOriginalConstructor()->setMethods(array(
211  'set',
212  'get'
213  ))->getMock();
214 
215  $factory = new \ilMailMimeSenderFactory($settings);
216  $this->assertInstanceOf('\ilMailMimeSenderUser', $factory->getSenderByUsrId(self::USER_ID));
217  }
$factory
Definition: metadata.php:43

◆ testFactoryWillReturnUserSenderWhenExplicitlyRequested()

ilMailMimeTest::testFactoryWillReturnUserSenderWhenExplicitlyRequested ( )

Definition at line 222 of file ilMailMimeTest.php.

References $factory.

223  {
224  $settings = $this->getMockBuilder(\ilSetting::class)->disableOriginalConstructor()->setMethods(array(
225  'set',
226  'get'
227  ))->getMock();
228 
229  $factory = new \ilMailMimeSenderFactory($settings);
230  $this->assertInstanceOf('\ilMailMimeSenderUser', $factory->user(self::USER_ID));
231  }
$factory
Definition: metadata.php:43

◆ testMimMailDelegatesEmailDeliveryToDefaultTransport()

ilMailMimeTest::testMimMailDelegatesEmailDeliveryToDefaultTransport ( )

Definition at line 55 of file ilMailMimeTest.php.

References Sabre\Event\once(), and ilMailBaseTest\setGlobalVariable().

56  {
57  $defaultTransport = $this->getMockBuilder(\ilMailMimeTransport::class)->getMock();
58  $defaultTransport->expects($this->once())->method('send');
59 
60  $transportFactory = $this->getMockBuilder(\ilMailMimeTransportFactory::class)->disableOriginalConstructor()->getMock();
61  $transportFactory->expects($this->any())->method('getTransport')->will($this->returnValue($defaultTransport));
62  $this->setGlobalVariable('mail.mime.transport.factory', $transportFactory);
63 
64  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array(
65  'set',
66  'get'
67  ))->getMock();
68  $this->setGlobalVariable('ilSetting', $settings);
69 
70  $mail = new \ilMimeMail();
71  $mail->send();
72  }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
setGlobalVariable($name, $value)
+ Here is the call graph for this function:

◆ testMimMailDelegatesEmailDeliveryToThePassedTransporter()

ilMailMimeTest::testMimMailDelegatesEmailDeliveryToThePassedTransporter ( )

Definition at line 30 of file ilMailMimeTest.php.

References Sabre\Event\once(), and ilMailBaseTest\setGlobalVariable().

31  {
32  $defaultTransport = $this->getMockBuilder(\ilMailMimeTransport::class)->getMock();
33  $defaultTransport->expects($this->never())->method('send');
34 
35  $transport = $this->getMockBuilder(\ilMailMimeTransport::class)->getMock();
36  $transport->expects($this->once())->method('send');
37 
38  $transportFactory = $this->getMockBuilder(\ilMailMimeTransportFactory::class)->disableOriginalConstructor()->getMock();
39  $transportFactory->expects($this->any())->method('getTransport')->will($this->returnValue($defaultTransport));
40  $this->setGlobalVariable('mail.mime.transport.factory', $transportFactory);
41 
42  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array(
43  'set',
44  'get'
45  ))->getMock();
46  $this->setGlobalVariable('ilSetting', $settings);
47 
48  $mail = new \ilMimeMail();
49  $mail->send($transport);
50  }
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
setGlobalVariable($name, $value)
+ Here is the call graph for this function:

◆ testTransportFactoryWillReturnNullTransportIfExternalEmailDeliveryIsDisabled()

ilMailMimeTest::testTransportFactoryWillReturnNullTransportIfExternalEmailDeliveryIsDisabled ( )

Definition at line 77 of file ilMailMimeTest.php.

References $factory, $key, and ilMailBaseTest\setGlobalVariable().

78  {
79  $settings = $this->getMockBuilder(\ilSetting::class)->disableOriginalConstructor()->setMethods(array(
80  'set',
81  'get'
82  ))->getMock();
83  $settings->expects($this->any())->method('get')->will($this->returnCallback(function ($key) {
84  if ('mail_allow_external' == $key) {
85  return false;
86  }
87 
88  return true;
89  }));
90  $this->setGlobalVariable('ilSetting', $settings);
91 
92  $eventHandler = $this->getMockBuilder(\ilAppEventHandler::class)->disableOriginalConstructor()->setMethods(array(
93  'raise',
94  ))->getMock();
95 
96  $factory = new \ilMailMimeTransportFactory($settings, $eventHandler);
97  $this->assertInstanceOf('\ilMailMimeTransportNull', $factory->getTransport());
98  }
$factory
Definition: metadata.php:43
setGlobalVariable($name, $value)
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ testTransportFactoryWillReturnSendmailTransportIfSmtpTransportIsDisabled()

ilMailMimeTest::testTransportFactoryWillReturnSendmailTransportIfSmtpTransportIsDisabled ( )

Definition at line 134 of file ilMailMimeTest.php.

References $factory, $key, and ilMailBaseTest\setGlobalVariable().

135  {
136  $settings = $this->getMockBuilder(\ilSetting::class)->disableOriginalConstructor()->setMethods(array(
137  'set',
138  'get'
139  ))->getMock();
140 
141  $settings->expects($this->any())->method('get')->will($this->returnCallback(function ($key) {
142  if ('mail_allow_external' == $key) {
143  return true;
144  }
145 
146 
147  if ('mail_smtp_status' == $key) {
148  return false;
149  }
150 
151  return true;
152  }));
153  $this->setGlobalVariable('ilSetting', $settings);
154 
155  $eventHandler = $this->getMockBuilder(\ilAppEventHandler::class)->disableOriginalConstructor()->setMethods(array(
156  'raise',
157  ))->getMock();
158 
159  $factory = new \ilMailMimeTransportFactory($settings, $eventHandler);
160  $this->assertInstanceOf('\ilMailMimeTransportSendMail', $factory->getTransport());
161  }
$factory
Definition: metadata.php:43
setGlobalVariable($name, $value)
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ testTransportFactoryWillReturnSmtpTransportIfEnabled()

ilMailMimeTest::testTransportFactoryWillReturnSmtpTransportIfEnabled ( )

Definition at line 103 of file ilMailMimeTest.php.

References $factory, $key, and ilMailBaseTest\setGlobalVariable().

104  {
105  $settings = $this->getMockBuilder(\ilSetting::class)->disableOriginalConstructor()->setMethods(array(
106  'set',
107  'get'
108  ))->getMock();
109  $settings->expects($this->any())->method('get')->will($this->returnCallback(function ($key) {
110  if ('mail_allow_external' == $key) {
111  return true;
112  }
113 
114 
115  if ('mail_smtp_status' == $key) {
116  return true;
117  }
118 
119  return true;
120  }));
121  $this->setGlobalVariable('ilSetting', $settings);
122 
123  $eventHandler = $this->getMockBuilder(\ilAppEventHandler::class)->disableOriginalConstructor()->setMethods(array(
124  'raise',
125  ))->getMock();
126 
127  $factory = new \ilMailMimeTransportFactory($settings, $eventHandler);
128  $this->assertInstanceOf('\ilMailMimeTransportSmtp', $factory->getTransport());
129  }
$factory
Definition: metadata.php:43
setGlobalVariable($name, $value)
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

Field Documentation

◆ USER_ID

const ilMailMimeTest::USER_ID = 6

Definition at line 10 of file ilMailMimeTest.php.


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