ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMailMimeTest Class Reference
+ 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)
 

Detailed Description

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

Definition at line 15 of file ilMailMimeTest.php.

Member Function Documentation

◆ getUserById()

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

Definition at line 171 of file ilMailMimeTest.php.

References array.

Referenced by setUp().

172  {
173  $user = $this->getMockBuilder('\ilObjUser')->disableOriginalConstructor()->setMethods(
174  array()
175  )->getMock();
176  $user->expects($this->any())->method('getId')->will($this->returnValue($usrId));
177 
178  return $user;
179  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ setUp()

ilMailMimeTest::setUp ( )
protected

Definition at line 25 of file ilMailMimeTest.php.

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

26  {
27  if (!defined('ANONYMOUS_USER_ID')) {
28  define('ANONYMOUS_USER_ID', 13);
29  }
30 
32  \ilMailMimeSenderUser::addUserToCache(self::USER_ID, $this->getUserById(self::USER_ID));
33 
34  parent::setUp();
35  }
static setDefaultTransport($transport)
static addUserToCache($usrId, \ilObjUser $user)
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
+ Here is the call graph for this function:

◆ testFactoryWillReturnSystemSenderForAnonymousUserId()

ilMailMimeTest::testFactoryWillReturnSystemSenderForAnonymousUserId ( )

Definition at line 148 of file ilMailMimeTest.php.

References $factory, and array.

149  {
150  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
151 
152  $factory = new \ilMailMimeSenderFactory($settings);
153  $this->assertInstanceOf('\ilMailMimeSenderSystem', $factory->getSenderByUsrId(\ANONYMOUS_USER_ID));
154  }
$factory
Definition: metadata.php:47
Create styles array
The data for the language used.

◆ testFactoryWillReturnSystemSenderWhenExplicitlyRequested()

ilMailMimeTest::testFactoryWillReturnSystemSenderWhenExplicitlyRequested ( )

Definition at line 159 of file ilMailMimeTest.php.

References $factory, and array.

160  {
161  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
162 
163  $factory = new \ilMailMimeSenderFactory($settings);
164  $this->assertInstanceOf('\ilMailMimeSenderSystem', $factory->system());
165  }
$factory
Definition: metadata.php:47
Create styles array
The data for the language used.

◆ testFactoryWillReturnUserSenderForExistingUserId()

ilMailMimeTest::testFactoryWillReturnUserSenderForExistingUserId ( )

Definition at line 184 of file ilMailMimeTest.php.

References $factory, and array.

185  {
186  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
187 
188  $factory = new \ilMailMimeSenderFactory($settings);
189  $this->assertInstanceOf('\ilMailMimeSenderUser', $factory->getSenderByUsrId(self::USER_ID));
190  }
$factory
Definition: metadata.php:47
Create styles array
The data for the language used.

◆ testFactoryWillReturnUserSenderWhenExplicitlyRequested()

ilMailMimeTest::testFactoryWillReturnUserSenderWhenExplicitlyRequested ( )

Definition at line 195 of file ilMailMimeTest.php.

References $factory, and array.

196  {
197  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
198 
199  $factory = new \ilMailMimeSenderFactory($settings);
200  $this->assertInstanceOf('\ilMailMimeSenderUser', $factory->user(self::USER_ID));
201  }
$factory
Definition: metadata.php:47
Create styles array
The data for the language used.

◆ testMimMailDelegatesEmailDeliveryToDefaultTransport()

ilMailMimeTest::testMimMailDelegatesEmailDeliveryToDefaultTransport ( )

Definition at line 62 of file ilMailMimeTest.php.

References array, and ilMailBaseTest\setGlobalVariable().

63  {
64  $defaultTransport = $this->getMockBuilder('\ilMailMimeTransport')->getMock();
65  $defaultTransport->expects($this->once())->method('send');
66 
67  $transportFactory = $this->getMockBuilder('\ilMailMimeTransportFactory')->disableOriginalConstructor()->getMock();
68  $transportFactory->expects($this->any())->method('getTransport')->will($this->returnValue($defaultTransport));
69  $this->setGlobalVariable('mail.mime.transport.factory', $transportFactory);
70 
71  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
72  $this->setGlobalVariable('ilSetting', $settings);
73 
74  $mail = new \ilMimeMail();
75  $mail->send();
76  }
Create styles array
The data for the language used.
setGlobalVariable($name, $value)
+ Here is the call graph for this function:

◆ testMimMailDelegatesEmailDeliveryToThePassedTransporter()

ilMailMimeTest::testMimMailDelegatesEmailDeliveryToThePassedTransporter ( )

Definition at line 40 of file ilMailMimeTest.php.

References array, and ilMailBaseTest\setGlobalVariable().

41  {
42  $defaultTransport = $this->getMockBuilder('\ilMailMimeTransport')->getMock();
43  $defaultTransport->expects($this->never())->method('send');
44 
45  $transport = $this->getMockBuilder('\ilMailMimeTransport')->getMock();
46  $transport->expects($this->once())->method('send');
47 
48  $transportFactory = $this->getMockBuilder('\ilMailMimeTransportFactory')->disableOriginalConstructor()->getMock();
49  $transportFactory->expects($this->any())->method('getTransport')->will($this->returnValue($defaultTransport));
50  $this->setGlobalVariable('mail.mime.transport.factory', $transportFactory);
51 
52  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
53  $this->setGlobalVariable('ilSetting', $settings);
54 
55  $mail = new \ilMimeMail();
56  $mail->send($transport);
57  }
Create styles array
The data for the language used.
setGlobalVariable($name, $value)
+ Here is the call graph for this function:

◆ testTransportFactoryWillReturnNullTransportIfExternalEmailDeliveryIsDisabled()

ilMailMimeTest::testTransportFactoryWillReturnNullTransportIfExternalEmailDeliveryIsDisabled ( )

Definition at line 81 of file ilMailMimeTest.php.

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

82  {
83  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
84  $settings->expects($this->any())->method('get')->will($this->returnCallback(function ($key) {
85  if ('mail_allow_external' == $key) {
86  return false;
87  }
88 
89  return true;
90  }));
91  $this->setGlobalVariable('ilSetting', $settings);
92 
93  $factory = new \ilMailMimeTransportFactory($settings);
94  $this->assertInstanceOf('\ilMailMimeTransportNull', $factory->getTransport());
95  }
$factory
Definition: metadata.php:47
Create styles array
The data for the language used.
setGlobalVariable($name, $value)
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ testTransportFactoryWillReturnSendmailTransportIfSmtpTransportIsDisabled()

ilMailMimeTest::testTransportFactoryWillReturnSendmailTransportIfSmtpTransportIsDisabled ( )

Definition at line 124 of file ilMailMimeTest.php.

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

125  {
126  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
127  $settings->expects($this->any())->method('get')->will($this->returnCallback(function ($key) {
128  if ('mail_allow_external' == $key) {
129  return true;
130  }
131 
132 
133  if ('mail_smtp_status' == $key) {
134  return false;
135  }
136 
137  return true;
138  }));
139  $this->setGlobalVariable('ilSetting', $settings);
140 
141  $factory = new \ilMailMimeTransportFactory($settings);
142  $this->assertInstanceOf('\ilMailMimeTransportSendMail', $factory->getTransport());
143  }
$factory
Definition: metadata.php:47
Create styles array
The data for the language used.
setGlobalVariable($name, $value)
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ testTransportFactoryWillReturnSmtpTransportIfEnabled()

ilMailMimeTest::testTransportFactoryWillReturnSmtpTransportIfEnabled ( )

Definition at line 100 of file ilMailMimeTest.php.

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

101  {
102  $settings = $this->getMockBuilder('\ilSetting')->disableOriginalConstructor()->setMethods(array('set', 'get'))->getMock();
103  $settings->expects($this->any())->method('get')->will($this->returnCallback(function ($key) {
104  if ('mail_allow_external' == $key) {
105  return true;
106  }
107 
108 
109  if ('mail_smtp_status' == $key) {
110  return true;
111  }
112 
113  return true;
114  }));
115  $this->setGlobalVariable('ilSetting', $settings);
116 
117  $factory = new \ilMailMimeTransportFactory($settings);
118  $this->assertInstanceOf('\ilMailMimeTransportSmtp', $factory->getTransport());
119  }
$factory
Definition: metadata.php:47
Create styles array
The data for the language used.
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 20 of file ilMailMimeTest.php.


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