Skip to content

Commit

Permalink
Fixed setFrom function by deprecating old and introducing new function.
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Wharton committed Nov 8, 2018
1 parent c32ca7a commit 99621b3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
15 changes: 14 additions & 1 deletion lib/internal/Magento/Framework/Mail/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,23 @@ public function getBody()

/**
* {@inheritdoc}
*
* @deprecated This function is missing the from name. The
* setFromAddress() function sets both from address and from name.
* @see setFromAddress()
*/
public function setFrom($fromAddress)
{
$this->zendMessage->setFrom($fromAddress);
$this->setFromAddress($fromAddress, null);
return $this;
}

/**
* {@inheritdoc}
*/
public function setFromAddress($fromAddress, $fromName = null)
{
$this->zendMessage->setFrom($fromAddress, $fromName);
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public function setFrom($from)
public function setFromByStore($from, $store = null)
{
$result = $this->_senderResolver->resolve($from, $store);
$this->message->setFrom($result['email'], $result['name']);
$this->message->setFromAddress($result['email'], $result['name']);
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(
public function setFromByStore($from, $store)
{
$result = $this->senderResolver->resolve($from, $store);
$this->message->setFrom($result['email'], $result['name']);
$this->message->setFromAddress($result['email'], $result['name']);

return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function testSetFromByStore()
->with($sender, $store)
->willReturn($sender);
$this->messageMock->expects($this->once())
->method('setFrom')
->with('from@example.com', 'name')
->method('setFromAddress')
->with($sender['email'], $sender['name'])
->willReturnSelf();

$this->model->setFromByStore($sender, $store);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ public function testSetFromByStore()
->with($sender, $store)
->willReturn($sender);
$this->messageMock->expects($this->once())
->method('setFrom')
->with('from@example.com', 'name')
->method('setFromAddress')
->with($sender['email'], $sender['name'])
->willReturnSelf();

$this->builder->setFromByStore($sender, $store);
Expand Down

0 comments on commit 99621b3

Please sign in to comment.