Skip to content

Commit

Permalink
ENGCOM-3969: Fix referenced to 'store', changing to 'scope' in Framew…
Browse files Browse the repository at this point in the history
…ork/Mail components #20621

 - Merge Pull Request #20621 from gwharton/magento2:2.3-develop-emailfix
 - Merged commits:
   1. 5c7d899
   2. bd0c6f3
  • Loading branch information
magento-engcom-team committed Feb 15, 2019
2 parents 741e610 + bd0c6f3 commit 9360424
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 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 @@ -106,7 +106,7 @@ protected function configureEmailTemplate()
$this->transportBuilder->setTemplateIdentifier($this->templateContainer->getTemplateId());
$this->transportBuilder->setTemplateOptions($this->templateContainer->getTemplateOptions());
$this->transportBuilder->setTemplateVars($this->templateContainer->getTemplateVars());
$this->transportBuilder->setFromByStore(
$this->transportBuilder->setFromByScope(
$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',
'setFromByStore',
'setFromByScope',
]
);

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

$this->identityContainerMock->expects($this->once())
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testSend()
->method('getId')
->willReturn(1);
$this->transportBuilder->expects($this->once())
->method('setFromByStore')
->method('setFromByScope')
->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('setFromByStore')
->method('setFromByScope')
->with($identity, 1);
$this->identityContainerMock->expects($this->once())
->method('getStore')
Expand Down
26 changes: 20 additions & 6 deletions lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,43 @@ public function setReplyTo($email, $name = null)
/**
* Set mail from address
*
* @deprecated This function sets the from address for the first store only.
* new function setFromByStore introduced to allow setting of from address
* based on store.
* @see setFromByStore()
* @deprecated This function sets the from address but does not provide
* a way of setting the correct from addresses based on the scope.
* @see setFromByScope()
*
* @param string|array $from
* @return $this
*/
public function setFrom($from)
{
return $this->setFromByStore($from, null);
return $this->setFromByScope($from, null);
}

/**
* Set mail from address by store
*
* @deprecated Use setFromByScope
* @see setFromByScope()
*
* @param string|array $from
* @param string|int $store
* @return $this
*/
public function setFromByStore($from, $store = null)
{
$result = $this->_senderResolver->resolve($from, $store);
return $this->setFromByScope($from, $store);
}

/**
* Set mail from address by scopeId
*
* @param string|array $from
* @param string|int $scopeId
* @return $this
*/
public function setFromByScope($from, $scopeId = null)
{
$result = $this->_senderResolver->resolve($from, $scopeId);
$this->message->setFromAddress($result['email'], $result['name']);
return $this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,20 @@ public function getTransportDataProvider()
/**
* @return void
*/
public function testSetFromByStore()
public function testSetFromByScope()
{
$sender = ['email' => 'from@example.com', 'name' => 'name'];
$store = 1;
$scopeId = 1;
$this->senderResolverMock->expects($this->once())
->method('resolve')
->with($sender, $store)
->with($sender, $scopeId)
->willReturn($sender);
$this->messageMock->expects($this->once())
->method('setFromAddress')
->with($sender['email'], $sender['name'])
->willReturnSelf();

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

/**
Expand Down

0 comments on commit 9360424

Please sign in to comment.