TYPO3 CMS  TYPO3_6-2
MailerTest.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $fixture;
28 
29  public function setUp() {
30  $this->fixture = $this->getMock('TYPO3\\CMS\\Core\\Mail\\Mailer', array('noMethodMocked'), array(), '', FALSE);
31  }
32 
34  // Tests concerning TYPO3\CMS\Core\Mail\Mailer
36 
40  $settings = array('transport' => 'mbox', 'transport_mbox_file' => '/path/to/file');
41  $GLOBALS['TYPO3_CONF_VARS']['MAIL'] = array('transport' => 'sendmail', 'transport_sendmail_command' => 'sendmail');
42  $this->fixture->injectMailSettings($settings);
43  $this->fixture->__construct();
44  $this->assertAttributeSame($settings, 'mailSettings', $this->fixture);
45  }
46 
51  $settings = ($GLOBALS['TYPO3_CONF_VARS']['MAIL'] = array('transport' => 'sendmail', 'transport_sendmail_command' => 'sendmail'));
52  $this->fixture->__construct();
53  $this->assertAttributeSame($settings, 'mailSettings', $this->fixture);
54  }
55 
61  static public function wrongConfigigurationProvider() {
62  return array(
63  'smtp but no host' => array(array('transport' => 'smtp')),
64  'sendmail but no command' => array(array('transport' => 'sendmail')),
65  'mbox but no file' => array(array('transport' => 'mbox')),
66  'no instance of Swift_Transport' => array(array('transport' => 'TYPO3\\CMS\\Core\\Messaging\\ErrorpageMessage'))
67  );
68  }
69 
76  public function wrongConfigigurationThrowsException($settings) {
77  $this->fixture->injectMailSettings($settings);
78  $this->fixture->__construct();
79  }
80 
85  if (!class_exists('t3lib_mail_SwiftMailerFakeTransport')) {
86  // Create fake custom transport class
87  eval('class t3lib_mail_SwiftMailerFakeTransport extends \\TYPO3\\CMS\\Core\\Mail\\MboxTransport {
88  public function __construct($settings) {}
89  }');
90  }
91  $this->fixture->injectMailSettings(array('transport' => 't3lib_mail_SwiftMailerFakeTransport'));
92  $this->fixture->__construct();
93  }
94 
98  public function noPortSettingSetsPortTo25() {
99  $this->fixture->injectMailSettings(array('transport' => 'smtp', 'transport_smtp_server' => 'localhost'));
100  $this->fixture->__construct();
101  $port = $this->fixture->getTransport()->getPort();
102  $this->assertEquals(25, $port);
103  }
104 
108  public function emptyPortSettingSetsPortTo25() {
109  $this->fixture->injectMailSettings(array('transport' => 'smtp', 'transport_smtp_server' => 'localhost:'));
110  $this->fixture->__construct();
111  $port = $this->fixture->getTransport()->getPort();
112  $this->assertEquals(25, $port);
113  }
114 
118  public function givenPortSettingIsRespected() {
119  $this->fixture->injectMailSettings(array('transport' => 'smtp', 'transport_smtp_server' => 'localhost:12345'));
120  $this->fixture->__construct();
121  $port = $this->fixture->getTransport()->getPort();
122  $this->assertEquals(12345, $port);
123  }
124 }
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]