Skip to content

Commit

Permalink
Added new setFromByStore function and deprecated old function.
Browse files Browse the repository at this point in the history
TODO : Rest of Magento codebase still uses deprecated setFrom
  • Loading branch information
Graham Wharton committed Oct 16, 2018
1 parent 82a635b commit 16afc09
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Sales/Model/Order/Email/SenderBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function configureEmailTemplate()
$this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId());
$this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions());
$this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars());
$this->transportBuilder->setFrom(
$this->transportBuilder->setFromByStore(
$this->identityContainer->getEmailIdentity(),
$this->identityContainer->getStore()->getId()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function setUp()
'setTemplateIdentifier',
'setTemplateOptions',
'setTemplateVars',
'setFrom',
'setFromByStore',
]
);

Expand All @@ -103,8 +103,8 @@ protected function setUp()
->method('getEmailIdentity')
->will($this->returnValue($emailIdentity));
$this->transportBuilder->expects($this->once())
->method('setFrom')
->with($this->equalTo($emailIdentity));
->method('setFromByStore')
->with($this->equalTo($emailIdentity), 1);

$this->identityContainerMock->expects($this->once())
->method('getEmailCopyTo')
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testSend()
->method('getId')
->willReturn(1);
$this->transportBuilder->expects($this->once())
->method('setFrom')
->method('setFromByStore')
->with($identity, 1);
$this->transportBuilder->expects($this->once())
->method('addTo')
Expand Down Expand Up @@ -176,7 +176,7 @@ public function testSendCopyTo()
->method('addTo')
->with($this->equalTo('example@mail.com'));
$this->transportBuilder->expects($this->once())
->method('setFrom')
->method('setFromByStore')
->with($identity, 1);
$this->identityContainerMock->expects($this->once())
->method('getStore')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,27 @@ public function setReplyTo($email, $name = null)

/**
* Set mail from address
*
* @deprecated Use setFromByStore
*
* @param string|array $from
* @return $this
*/
public function setFrom($from)
{
$result = $this->_senderResolver->resolve($from);
$this->message->setFrom($result['email'], $result['name']);
return $this;
}

/**
* Set mail from address by store
*
* @param string|array $from
* @param string|int $store
* @return $this
*/
public function setFrom($from, $store = null)
public function setFromByStore($from, $store = null)
{
$result = $this->_senderResolver->resolve($from, $store);
$this->message->setFrom($result['email'], $result['name']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ public function testSetFrom()
->with($sender, $store)
->willReturn($sender);
$this->messageMock->expects($this->once())
->method('setFrom')
->method('setFromByStore')
->with('from@example.com', 'name')
->willReturnSelf();

$this->builder->setFrom($sender, $store);
$this->builder->setFromByStore($sender, $store);
}

/**
Expand Down

0 comments on commit 16afc09

Please sign in to comment.