diff --git a/extensions/swiftmailer/yii/swiftmailer/Message.php b/extensions/swiftmailer/yii/swiftmailer/Message.php index b8813f5..8997695 100644 --- a/extensions/swiftmailer/yii/swiftmailer/Message.php +++ b/extensions/swiftmailer/yii/swiftmailer/Message.php @@ -97,7 +97,7 @@ class Message extends BaseMessage /** * @inheritdoc */ - public function text($text) + public function textBody($text) { $this->setBody($text, 'text/plain'); return $this; @@ -106,7 +106,7 @@ class Message extends BaseMessage /** * @inheritdoc */ - public function html($html) + public function htmlBody($html) { $this->setBody($html, 'text/html'); return $this; diff --git a/framework/yii/mail/BaseMailer.php b/framework/yii/mail/BaseMailer.php index 6ee5899..4e1982c 100644 --- a/framework/yii/mail/BaseMailer.php +++ b/framework/yii/mail/BaseMailer.php @@ -52,8 +52,8 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont * - 'cc' argument for [[MessageInterface::cc()]] * - 'bcc' argument for [[MessageInterface::bcc()]] * - 'subject' argument for [[MessageInterface::subject()]] - * - 'text' argument for [[MessageInterface::text()]] - * - 'html' argument for [[MessageInterface::html()]] + * - 'textBody' argument for [[MessageInterface::textBody()]] + * - 'htmlBody' argument for [[MessageInterface::htmlBody()]] * For example: * ~~~ * array( @@ -115,15 +115,15 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont $params['message'] = $message; if (is_array($view)) { if (array_key_exists('html', $view)) { - $message->html($this->render($view['html'], $params, $this->htmlLayout)); + $message->htmlBody($this->render($view['html'], $params, $this->htmlLayout)); } if (array_key_exists('text', $view)) { - $message->text($this->render($view['text'], $params, $this->textLayout)); + $message->textBody($this->render($view['text'], $params, $this->textLayout)); } } else { $html = $this->render($view, $params, $this->htmlLayout); - $message->html($html); - $message->text(strip_tags($html)); + $message->htmlBody($html); + $message->textBody(strip_tags($html)); } } return $message; @@ -147,8 +147,8 @@ abstract class BaseMailer extends Component implements MailerInterface, ViewCont 'cc', 'bcc', 'subject', - 'text', - 'html', + 'textBody', + 'htmlBody', ]; $directSetterConfig = []; foreach ($config as $name => $value) { diff --git a/framework/yii/mail/MessageInterface.php b/framework/yii/mail/MessageInterface.php index 69344a4..85f3f9e 100644 --- a/framework/yii/mail/MessageInterface.php +++ b/framework/yii/mail/MessageInterface.php @@ -87,14 +87,14 @@ interface MessageInterface * @param string $text message plain text content. * @return static self reference. */ - public function text($text); + public function textBody($text); /** * Sets message HTML content. * @param string $html message HTML content. * @return static self reference. */ - public function html($html); + public function htmlBody($html); /** * Attaches existing file to the email message. diff --git a/tests/unit/extensions/swiftmailer/MessageTest.php b/tests/unit/extensions/swiftmailer/MessageTest.php index 7a6fedf..33eff29 100644 --- a/tests/unit/extensions/swiftmailer/MessageTest.php +++ b/tests/unit/extensions/swiftmailer/MessageTest.php @@ -160,7 +160,7 @@ class MessageTest extends VendorTestCase $message->to($this->testEmailReceiver); $message->from('someuser@somedomain.com'); $message->subject('Yii Swift Test'); - $message->text('Yii Swift Test body'); + $message->textBody('Yii Swift Test body'); $this->assertTrue($message->send()); } @@ -174,7 +174,7 @@ class MessageTest extends VendorTestCase $message->to($this->testEmailReceiver); $message->from('someuser@somedomain.com'); $message->subject('Yii Swift Attach File Test'); - $message->text('Yii Swift Attach File Test body'); + $message->textBody('Yii Swift Attach File Test body'); $fileName = __FILE__; $message->attach($fileName); @@ -195,7 +195,7 @@ class MessageTest extends VendorTestCase $message->to($this->testEmailReceiver); $message->from('someuser@somedomain.com'); $message->subject('Yii Swift Create Attachment Test'); - $message->text('Yii Swift Create Attachment Test body'); + $message->textBody('Yii Swift Create Attachment Test body'); $fileName = 'test.txt'; $fileContent = 'Test attachment content'; $message->attachContent($fileContent, ['fileName' => $fileName]); @@ -221,7 +221,7 @@ class MessageTest extends VendorTestCase $message->to($this->testEmailReceiver); $message->from('someuser@somedomain.com'); $message->subject('Yii Swift Embed File Test'); - $message->html('Embed image: pic'); + $message->htmlBody('Embed image: pic'); $this->assertTrue($message->send()); @@ -247,7 +247,7 @@ class MessageTest extends VendorTestCase $message->to($this->testEmailReceiver); $message->from('someuser@somedomain.com'); $message->subject('Yii Swift Embed File Test'); - $message->html('Embed image: pic'); + $message->htmlBody('Embed image: pic'); $this->assertTrue($message->send()); @@ -267,8 +267,8 @@ class MessageTest extends VendorTestCase $message->to($this->testEmailReceiver); $message->from('someuser@somedomain.com'); $message->subject('Yii Swift Alternative Body Test'); - $message->html('Yii Swift test HTML body'); - $message->text('Yii Swift test plain text body'); + $message->htmlBody('Yii Swift test HTML body'); + $message->textBody('Yii Swift test plain text body'); $this->assertTrue($message->send()); @@ -300,7 +300,7 @@ class MessageTest extends VendorTestCase $message->to($this->testEmailReceiver); $message->from('someuser@somedomain.com'); $message->subject('Yii Swift Alternative Body Test'); - $message->text('Yii Swift test plain text body'); + $message->textBody('Yii Swift test plain text body'); $serializedMessage = serialize($message); $this->assertNotEmpty($serializedMessage, 'Unable to serialize message!'); diff --git a/tests/unit/framework/mail/BaseMailerTest.php b/tests/unit/framework/mail/BaseMailerTest.php index 505652c..4eab7e1 100644 --- a/tests/unit/framework/mail/BaseMailerTest.php +++ b/tests/unit/framework/mail/BaseMailerTest.php @@ -115,8 +115,8 @@ class BaseMailerTest extends TestCase 'cc' => 'cc@domain.com', 'bcc' => 'bcc@domain.com', 'subject' => 'Test subject', - 'text' => 'Test text body', - 'html' => 'Test HTML body', + 'textBody' => 'Test text body', + 'htmlBody' => 'Test HTML body', ]; $propertyConfig = [ 'id' => 'test-id', @@ -201,12 +201,12 @@ class BaseMailerTest extends TestCase 'html' => $htmlViewName, 'text' => $textViewName, ]); - $this->assertEquals($htmlViewFileContent, $message->_html, 'Unable to render html!'); - $this->assertEquals($textViewFileContent, $message->_text, 'Unable to render text!'); + $this->assertEquals($htmlViewFileContent, $message->_htmlBody, 'Unable to render html!'); + $this->assertEquals($textViewFileContent, $message->_textBody, 'Unable to render text!'); $message = $mailer->compose($htmlViewName); - $this->assertEquals($htmlViewFileContent, $message->_html, 'Unable to render html by direct view!'); - $this->assertEquals(strip_tags($htmlViewFileContent), $message->_text, 'Unable to render text by direct view!'); + $this->assertEquals($htmlViewFileContent, $message->_htmlBody, 'Unable to render html by direct view!'); + $this->assertEquals(strip_tags($htmlViewFileContent), $message->_textBody, 'Unable to render text by direct view!'); } } @@ -237,8 +237,8 @@ class Message extends BaseMessage public $_cc; public $_bcc; public $_subject; - public $_text; - public $_html; + public $_textBody; + public $_htmlBody; public function charset($charset) { @@ -276,15 +276,15 @@ class Message extends BaseMessage return $this; } - public function text($text) + public function textBody($text) { - $this->_text = $text; + $this->_textBody = $text; return $this; } - public function html($html) + public function htmlBody($html) { - $this->_html = $html; + $this->_htmlBody = $html; return $this; } diff --git a/tests/unit/framework/mail/BaseMessageTest.php b/tests/unit/framework/mail/BaseMessageTest.php index 7b36a93..1820764 100644 --- a/tests/unit/framework/mail/BaseMessageTest.php +++ b/tests/unit/framework/mail/BaseMessageTest.php @@ -97,11 +97,11 @@ class TestMessage extends BaseMessage public function subject($subject) {} - public function text($text) { + public function textBody($text) { $this->text = $text; } - public function html($html) { + public function htmlBody($html) { $this->html = $html; }