TYPO3 CMS  TYPO3_7-6
MailerTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
17 
22 {
26  protected $subject;
27 
28  protected function setUp()
29  {
30  $this->subject = $this->getMock(\TYPO3\CMS\Core\Mail\Mailer::class, ['emitPostInitializeMailerSignal'], [], '', false);
31  }
32 
34  // Tests concerning TYPO3\CMS\Core\Mail\Mailer
36 
40  {
41  $settings = ['transport' => 'mbox', 'transport_mbox_file' => '/path/to/file'];
42  $GLOBALS['TYPO3_CONF_VARS']['MAIL'] = ['transport' => 'sendmail', 'transport_sendmail_command' => 'sendmail'];
43  $this->subject->injectMailSettings($settings);
44  $this->subject->__construct();
45  $this->assertAttributeSame($settings, 'mailSettings', $this->subject);
46  }
47 
52  {
53  $settings = ($GLOBALS['TYPO3_CONF_VARS']['MAIL'] = ['transport' => 'sendmail', 'transport_sendmail_command' => 'sendmail']);
54  $this->subject->__construct();
55  $this->assertAttributeSame($settings, 'mailSettings', $this->subject);
56  }
57 
63  public static function wrongConfigigurationProvider()
64  {
65  return [
66  'smtp but no host' => [['transport' => 'smtp']],
67  'sendmail but no command' => [['transport' => 'sendmail']],
68  'mbox but no file' => [['transport' => 'mbox']],
69  'no instance of Swift_Transport' => [['transport' => \TYPO3\CMS\Core\Messaging\ErrorpageMessage::class]]
70  ];
71  }
72 
79  public function wrongConfigigurationThrowsException($settings)
80  {
81  $this->subject->injectMailSettings($settings);
82  $this->subject->__construct();
83  }
84 
89  {
90  $this->subject->injectMailSettings(['transport' => FakeTransportFixture::class]);
91  $this->subject->__construct();
92  }
93 
97  public function noPortSettingSetsPortTo25()
98  {
99  $this->subject->injectMailSettings(['transport' => 'smtp', 'transport_smtp_server' => 'localhost']);
100  $this->subject->__construct();
101  $port = $this->subject->getTransport()->getPort();
102  $this->assertEquals(25, $port);
103  }
104 
109  {
110  $this->subject->injectMailSettings(['transport' => 'smtp', 'transport_smtp_server' => 'localhost:']);
111  $this->subject->__construct();
112  $port = $this->subject->getTransport()->getPort();
113  $this->assertEquals(25, $port);
114  }
115 
119  public function givenPortSettingIsRespected()
120  {
121  $this->subject->injectMailSettings(['transport' => 'smtp', 'transport_smtp_server' => 'localhost:12345']);
122  $this->subject->__construct();
123  $port = $this->subject->getTransport()->getPort();
124  $this->assertEquals(12345, $port);
125  }
126 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']