Skip to content

Commit

Permalink
Updated unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Wharton committed Jul 2, 2019
1 parent fa030f2 commit 7e3bc71
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions lib/internal/Magento/Framework/Mail/Test/Unit/MessageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,34 @@
class MessageTest extends \PHPUnit\Framework\TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Mail\Message
* @var \Magento\Framework\Mail\Message
*/
protected $_messageMock;
protected $message;

protected function setUp()
{
$this->_messageMock = $this->createPartialMock(
\Magento\Framework\Mail\Message::class,
['setBody', 'setMessageType']
);
$this->message = new \Magento\Framework\Mail\Message();
}

public function testSetBodyHtml()
{
$this->_messageMock->expects($this->once())
->method('setMessageType')
->with('text/html');
$this->message->setBodyHtml('body');

$this->_messageMock->expects($this->once())
->method('setBody')
->with('body');

$this->_messageMock->setBodyHtml('body');
$part = $this->message->getBody()->getParts()[0];
$this->assertEquals('text/html', $part->getType());
$this->assertEquals('8bit', $part->getEncoding());
$this->assertEquals('utf-8', $part->getCharset());
$this->assertEquals('body', $part->getContent());
}

public function testSetBodyText()
{
$this->_messageMock->expects($this->once())
->method('setMessageType')
->with('text/plain');

$this->_messageMock->expects($this->once())
->method('setBody')
->with('body');
$this->message->setBodyText('body');

$this->_messageMock->setBodyText('body');
$part = $this->message->getBody()->getParts()[0];
$this->assertEquals('text/plain', $part->getType());
$this->assertEquals('8bit', $part->getEncoding());
$this->assertEquals('utf-8', $part->getCharset());
$this->assertEquals('body', $part->getContent());
}
}

0 comments on commit 7e3bc71

Please sign in to comment.