Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Eliminate usage of Zend_Mail from Magento 2 Open Source #136

Open
wants to merge 3 commits into
base: 2.3.1-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class TemplateTest extends \PHPUnit\Framework\TestCase
protected $model;

/**
* @var \Zend_Mail|\PHPUnit_Framework_MockObject_MockObject
* @var \Magento\Framework\Mail\Message|\PHPUnit_Framework_MockObject_MockObject
*/
protected $mail;
protected $message;

/**
* @var \Magento\Framework\ObjectManagerInterface
Expand All @@ -45,8 +45,8 @@ protected function mockModel($filesystem = null)
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
}

$this->mail = $this->getMockBuilder(\Zend_Mail::class)
->setMethods(['send', 'addTo', 'addBcc', 'setReturnPath', 'setReplyTo'])
$this->message = $this->getMockBuilder(\Magento\Framework\Mail\Message::class)
->setMethods(['addTo', 'addBcc', 'setReplyTo'])
->setConstructorArgs(['utf-8'])
->getMock();

Expand All @@ -71,18 +71,18 @@ protected function mockModel($filesystem = null)

$this->objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');

$this->model->expects($this->any())->method('_getMail')->will($this->returnCallback([$this, 'getMail']));
$this->model->expects($this->any())->method('_getMail')->will($this->returnCallback([$this, 'getMessage']));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like _getMail() method doesn't exist anymore. It shouldn't be necessary here then.

Copy link
Contributor Author

@mhauri mhauri Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @buskamuza for catching this, I overlooked it. Will fix it asap.
This test seems to be obsolete, am I right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... probably the test itself still makes some sense. But anything related to $this->mail does not.

$this->model->setSenderName('sender')->setSenderEmail('[email protected]')->setTemplateSubject('Subject');
}

/**
* Return a disposable \Zend_Mail instance
* Return a disposable \Magento\Framework\Mail\Message instance
*
* @return \PHPUnit_Framework_MockObject_MockObject|\Zend_Mail
*/
public function getMail()
public function getMessage()
{
return clone $this->mail;
return clone $this->message;
}

public function testSetGetTemplateFilter()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4237,4 +4237,5 @@
['Zend_Feed', 'Zend\Feed'],
['Zend_Uri', 'Zend\Uri\Uri'],
['Zend_Mime', 'Magento\Framework\HTTP\Mime'],
['Zend_Mail', 'Zend\Mail'],
];