Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix referenced to "store", changing to "scope" in Framework/Mail components #20621

Merged
merged 2 commits into from
Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from all 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
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