Skip to content
Snippets Groups Projects
Unverified Commit 4a2c56b7 authored by Daniel Kesselberg's avatar Daniel Kesselberg
Browse files

Add testcases for pipe mode

parent 92675a60
No related branches found
No related tags found
No related merge requests found
......@@ -74,6 +74,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
'mail_smtpauthtype' => 'NTLM',
'mail_smtpauth' => 1,
'mail_smtpport' => '25',
'mail_sendmailmode' => null,
]],
[[
'mail_domain' => 'nextcloud.com',
......@@ -86,6 +87,7 @@ class MailSettingsControllerTest extends \Test\TestCase {
'mail_smtpport' => '25',
'mail_smtpname' => null,
'mail_smtppassword' => null,
'mail_sendmailmode' => null,
]]
);
......@@ -98,7 +100,8 @@ class MailSettingsControllerTest extends \Test\TestCase {
'mx.nextcloud.org',
'NTLM',
1,
'25'
'25',
null
);
$this->assertSame(Http::STATUS_OK, $response->getStatus());
......@@ -111,7 +114,8 @@ class MailSettingsControllerTest extends \Test\TestCase {
'mx.nextcloud.org',
'NTLM',
0,
'25'
'25',
null
);
$this->assertSame(Http::STATUS_OK, $response->getStatus());
......
......@@ -48,30 +48,54 @@ class MailerTest extends TestCase {
);
}
public function testGetSendMailInstanceSendMail() {
/**
* @return array
*/
public function sendmailModeProvider(): array {
return [
'smtp' => ['smtp', ' -bs'],
'pipe' => ['pipe', ' -t'],
];
}
/**
* @dataProvider sendmailModeProvider
* @param $sendmailMode
* @param $binaryParam
*/
public function testGetSendmailInstanceSendMail($sendmailMode, $binaryParam) {
$this->config
->expects($this->once())
->expects($this->exactly(2))
->method('getSystemValue')
->with('mail_smtpmode', 'smtp')
->will($this->returnValue('sendmail'));
->will($this->returnValueMap([
['mail_smtpmode', 'smtp', 'sendmail'],
['mail_sendmailmode', 'smtp', $sendmailMode],
]));
$path = \OC_Helper::findBinaryPath('sendmail');
if ($path === null) {
$path = '/usr/sbin/sendmail';
}
$expected = new \Swift_SendmailTransport($path . ' -bs');
$expected = new \Swift_SendmailTransport($path . $binaryParam);
$this->assertEquals($expected, self::invokePrivate($this->mailer, 'getSendMailInstance'));
}
public function testGetSendMailInstanceSendMailQmail() {
/**
* @dataProvider sendmailModeProvider
* @param $sendmailMode
* @param $binaryParam
*/
public function testGetSendmailInstanceSendMailQmail($sendmailMode, $binaryParam) {
$this->config
->expects($this->once())
->expects($this->exactly(2))
->method('getSystemValue')
->with('mail_smtpmode', 'smtp')
->will($this->returnValue('qmail'));
->will($this->returnValueMap([
['mail_smtpmode', 'smtp', 'qmail'],
['mail_sendmailmode', 'smtp', $sendmailMode],
]));
$this->assertEquals(new \Swift_SendmailTransport('/var/qmail/bin/sendmail -bs'), self::invokePrivate($this->mailer, 'getSendMailInstance'));
$this->assertEquals(new \Swift_SendmailTransport('/var/qmail/bin/sendmail' . $binaryParam), self::invokePrivate($this->mailer, 'getSendMailInstance'));
}
public function testGetInstanceDefault() {
......@@ -83,8 +107,10 @@ class MailerTest extends TestCase {
public function testGetInstanceSendmail() {
$this->config
->method('getSystemValue')
->with('mail_smtpmode', 'smtp')
->willReturn('sendmail');
->will($this->returnValueMap([
['mail_smtpmode', 'smtp', 'sendmail'],
['mail_sendmailmode', 'smtp', 'smtp'],
]));
$mailer = self::invokePrivate($this->mailer, 'getInstance');
$this->assertInstanceOf(\Swift_Mailer::class, $mailer);
......
......@@ -95,6 +95,11 @@ class MailTest extends TestCase {
->method('getSystemValue')
->with('mail_smtppassword', '')
->willReturn('mypassword');
$this->config
->expects($this->at(10))
->method('getSystemValue')
->with('mail_sendmailmode', 'smtp')
->willReturn('smtp');
$expected = new TemplateResponse(
'settings',
......@@ -111,6 +116,7 @@ class MailTest extends TestCase {
'mail_smtpauth' => true,
'mail_smtpname' => 'smtp.sender.com',
'mail_smtppassword' => '********',
'mail_sendmailmode' => 'smtp',
],
''
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment