Browse Source

Getters for 'yii\swiftmailer\Message' fixed.

tags/2.0.0-beta
Paul Klimov 11 years ago
parent
commit
b9fb97d68d
  1. 2
      extensions/swiftmailer/Mailer.php
  2. 14
      extensions/swiftmailer/Message.php
  3. 36
      tests/unit/extensions/swiftmailer/MessageTest.php

2
extensions/swiftmailer/Mailer.php

@ -108,7 +108,7 @@ class Mailer extends BaseMailer
{ {
$address = $message->getTo(); $address = $message->getTo();
if (is_array($address)) { if (is_array($address)) {
$address = implode(', ', $address); $address = implode(', ', array_keys($address));
} }
Yii::trace('Sending email "' . $message->getSubject() . '" to "' . $address . '"', __METHOD__); Yii::trace('Sending email "' . $message->getSubject() . '" to "' . $address . '"', __METHOD__);
return $this->getSwiftMailer()->send($message->getSwiftMessage()) > 0; return $this->getSwiftMailer()->send($message->getSwiftMessage()) > 0;

14
extensions/swiftmailer/Message.php

@ -44,7 +44,7 @@ class Message extends BaseMessage
*/ */
public function getCharset() public function getCharset()
{ {
$this->getSwiftMessage()->getCharset(); return $this->getSwiftMessage()->getCharset();
} }
/** /**
@ -61,7 +61,7 @@ class Message extends BaseMessage
*/ */
public function getFrom() public function getFrom()
{ {
$this->getSwiftMessage()->getFrom(); return $this->getSwiftMessage()->getFrom();
} }
/** /**
@ -78,7 +78,7 @@ class Message extends BaseMessage
*/ */
public function getReplyTo() public function getReplyTo()
{ {
$this->getSwiftMessage()->getReplyTo(); return $this->getSwiftMessage()->getReplyTo();
} }
/** /**
@ -95,7 +95,7 @@ class Message extends BaseMessage
*/ */
public function getTo() public function getTo()
{ {
$this->getSwiftMessage()->getTo(); return $this->getSwiftMessage()->getTo();
} }
/** /**
@ -112,7 +112,7 @@ class Message extends BaseMessage
*/ */
public function getCc() public function getCc()
{ {
$this->getSwiftMessage()->getCc(); return $this->getSwiftMessage()->getCc();
} }
/** /**
@ -129,7 +129,7 @@ class Message extends BaseMessage
*/ */
public function getBcc() public function getBcc()
{ {
$this->getSwiftMessage()->getBcc(); return $this->getSwiftMessage()->getBcc();
} }
/** /**
@ -146,7 +146,7 @@ class Message extends BaseMessage
*/ */
public function getSubject() public function getSubject()
{ {
$this->getSwiftMessage()->getSubject(); return $this->getSwiftMessage()->getSubject();
} }
/** /**

36
tests/unit/extensions/swiftmailer/MessageTest.php

@ -115,6 +115,42 @@ class MessageTest extends VendorTestCase
/** /**
* @depends testGetSwiftMessage * @depends testGetSwiftMessage
*/ */
public function testSetGet()
{
$message = new Message();
$charset = 'utf-16';
$message->setCharset($charset);
$this->assertEquals($charset, $message->getCharset(), 'Unable to set charset!');
$subject = 'Test Subject';
$message->setSubject($subject);
$this->assertEquals($subject, $message->getSubject(), 'Unable to set subject!');
$from = 'from@somedomain.com';
$message->setFrom($from);
$this->assertContains($from, array_keys($message->getFrom()), 'Unable to set from!');
$replyTo = 'reply-to@somedomain.com';
$message->setReplyTo($replyTo);
$this->assertContains($replyTo, array_keys($message->getReplyTo()), 'Unable to set replyTo!');
$to = 'someuser@somedomain.com';
$message->setTo($to);
$this->assertContains($to, array_keys($message->getTo()), 'Unable to set to!');
$cc = 'ccuser@somedomain.com';
$message->setCc($cc);
$this->assertContains($cc, array_keys($message->getCc()), 'Unable to set cc!');
$bcc = 'bccuser@somedomain.com';
$message->setBcc($bcc);
$this->assertContains($bcc, array_keys($message->getBcc()), 'Unable to set bcc!');
}
/**
* @depends testGetSwiftMessage
*/
public function testSetupHeaders() public function testSetupHeaders()
{ {
$charset = 'utf-16'; $charset = 'utf-16';

Loading…
Cancel
Save