Add testcases for pipe mode
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
parent
4991dfbb14
commit
cbff5fabe7
|
@ -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',
|
||||
],
|
||||
''
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue