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 621d2cf commit b6f9e48
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 @@ -101,7 +101,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 @@ -177,8 +177,9 @@ public function setReplyTo($email, $name = null)
/**
* Set mail from address
*
* @deprecated Use setFromByStore
*
* @param string|array $from
* @param string|int $store
* @return $this
*/
public function setFrom($from, $store = null)
Expand All @@ -188,6 +189,20 @@ public function setFrom($from, $store = null)
return $this;
}

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

/**
* Set template identifier
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,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 b6f9e48

Please sign in to comment.