From be7db1573dc8c6e7309ec9db124a7a74b8b41199 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 8 Jun 2018 10:26:56 +0200 Subject: Swift to \Swift_Mailer as abstraction * \Swift_Mailer handles starting the transport etc properly * Fixed tests Signed-off-by: Roeland Jago Douma --- tests/lib/Mail/MailerTest.php | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'tests/lib') diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php index 2dd4bca5190..d724cd630d3 100644 --- a/tests/lib/Mail/MailerTest.php +++ b/tests/lib/Mail/MailerTest.php @@ -48,50 +48,41 @@ class MailerTest extends TestCase { ); } - public function testGetMailInstance() { - $this->assertEquals(\Swift_MailTransport::newInstance(), self::invokePrivate($this->mailer, 'getMailinstance')); - } - public function testGetSendMailInstanceSendMail() { $this->config ->expects($this->once()) ->method('getSystemValue') - ->with('mail_smtpmode', 'php') + ->with('mail_smtpmode', 'smtp') ->will($this->returnValue('sendmail')); - $this->assertEquals(\Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs'), self::invokePrivate($this->mailer, 'getSendMailInstance')); + $this->assertEquals(new \Swift_SendmailTransport('/usr/sbin/sendmail -bs'), self::invokePrivate($this->mailer, 'getSendMailInstance')); } public function testGetSendMailInstanceSendMailQmail() { $this->config ->expects($this->once()) ->method('getSystemValue') - ->with('mail_smtpmode', 'php') + ->with('mail_smtpmode', 'smtp') ->will($this->returnValue('qmail')); - $this->assertEquals(\Swift_SendmailTransport::newInstance('/var/qmail/bin/sendmail -bs'), self::invokePrivate($this->mailer, 'getSendMailInstance')); + $this->assertEquals(new \Swift_SendmailTransport('/var/qmail/bin/sendmail -bs'), self::invokePrivate($this->mailer, 'getSendMailInstance')); } public function testGetInstanceDefault() { - $this->assertInstanceOf('\Swift_MailTransport', self::invokePrivate($this->mailer, 'getInstance')); - } - - public function testGetInstancePhp() { - $this->config - ->expects($this->any()) - ->method('getSystemValue') - ->will($this->returnValue('php')); - - $this->assertInstanceOf('\Swift_MailTransport', self::invokePrivate($this->mailer, 'getInstance')); + $mailer = self::invokePrivate($this->mailer, 'getInstance'); + $this->assertInstanceOf(\Swift_Mailer::class, $mailer); + $this->assertInstanceOf(\Swift_SmtpTransport::class, $mailer->getTransport()); } public function testGetInstanceSendmail() { $this->config - ->expects($this->any()) ->method('getSystemValue') - ->will($this->returnValue('sendmail')); + ->with('mail_smtpmode', 'smtp') + ->willReturn('sendmail'); - $this->assertInstanceOf('\Swift_Mailer', self::invokePrivate($this->mailer, 'getInstance')); + $mailer = self::invokePrivate($this->mailer, 'getInstance'); + $this->assertInstanceOf(\Swift_Mailer::class, $mailer); + $this->assertInstanceOf(\Swift_SendmailTransport::class, $mailer->getTransport()); } public function testCreateMessage() { -- cgit v1.2.3