|
|
|
@ -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); |
|
|
|
|