summaryrefslogtreecommitdiffstats
path: root/tests/lib/Mail
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2018-11-28 20:06:48 +0100
committerDaniel Kesselberg <mail@danielkesselberg.de>2018-11-29 16:02:37 +0100
commit4a2c56b71400de7a044e0a3c05a62ae34c4c4d69 (patch)
tree0a9dd0e3037f56955a94d0ab302a52f07b94434c /tests/lib/Mail
parent92675a606e90a57745ee1059e56d264a3213c954 (diff)
downloadnextcloud-server-4a2c56b71400de7a044e0a3c05a62ae34c4c4d69.tar.gz
nextcloud-server-4a2c56b71400de7a044e0a3c05a62ae34c4c4d69.zip
Add testcases for pipe mode
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'tests/lib/Mail')
-rw-r--r--tests/lib/Mail/MailerTest.php50
1 files changed, 38 insertions, 12 deletions
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index ddae38ff54d..4117498885c 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -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);