Skip to content

Commit bb45fc6

Browse files
author
Bohdan Korablov
committed
MAGETWO-44045: Reset password page not displayed, instead user login page displayed.
1 parent 108f621 commit bb45fc6

File tree

5 files changed

+78
-23
lines changed

5 files changed

+78
-23
lines changed

app/code/Magento/User/Model/User.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ public function sendPasswordResetConfirmationEmail()
369369
{
370370
$templateId = $this->_config->getValue(self::XML_PATH_FORGOT_EMAIL_TEMPLATE);
371371
$transport = $this->_transportBuilder->setTemplateIdentifier($templateId)
372+
->setTemplateNamespace('Magento\Email\Model\BackendTemplate')
372373
->setTemplateOptions(['area' => FrontNameResolver::AREA_CODE, 'store' => Store::DEFAULT_STORE_ID])
373374
->setTemplateVars(['user' => $this, 'store' => $this->_storeManager->getStore(Store::DEFAULT_STORE_ID)])
374375
->setFrom($this->_config->getValue(self::XML_PATH_FORGOT_EMAIL_IDENTITY))
@@ -388,6 +389,7 @@ public function sendPasswordResetNotificationEmail()
388389
{
389390
$templateId = $this->_config->getValue(self::XML_PATH_RESET_PASSWORD_TEMPLATE);
390391
$transport = $this->_transportBuilder->setTemplateIdentifier($templateId)
392+
->setTemplateNamespace('Magento\Email\Model\BackendTemplate')
391393
->setTemplateOptions(['area' => FrontNameResolver::AREA_CODE, 'store' => Store::DEFAULT_STORE_ID])
392394
->setTemplateVars(['user' => $this, 'store' => $this->_storeManager->getStore(Store::DEFAULT_STORE_ID)])
393395
->setFrom($this->_config->getValue(self::XML_PATH_FORGOT_EMAIL_IDENTITY))

lib/internal/Magento/Framework/Mail/Template/Factory.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ class Factory implements \Magento\Framework\Mail\Template\FactoryInterface
1212
/**
1313
* @var \Magento\Framework\ObjectManagerInterface
1414
*/
15-
protected $_objectManager = null;
15+
protected $objectManager = null;
1616

1717
/**
1818
* @var string
1919
*/
20-
protected $_instanceName = null;
20+
protected $instanceName = null;
2121

2222
/**
2323
* @param \Magento\Framework\ObjectManagerInterface $objectManager
@@ -27,17 +27,17 @@ public function __construct(
2727
\Magento\Framework\ObjectManagerInterface $objectManager,
2828
$instanceName = 'Magento\Framework\Mail\TemplateInterface'
2929
) {
30-
$this->_objectManager = $objectManager;
31-
$this->_instanceName = $instanceName;
30+
$this->objectManager = $objectManager;
31+
$this->instanceName = $instanceName;
3232
}
3333

3434
/**
3535
* {@inheritdoc}
3636
*/
37-
public function get($identifier)
37+
public function get($identifier, $namespace = null)
3838
{
39-
return $this->_objectManager->create(
40-
$this->_instanceName,
39+
return $this->objectManager->create(
40+
$namespace ? $namespace : $this->instanceName,
4141
['data' => ['template_id' => $identifier]]
4242
);
4343
}

lib/internal/Magento/Framework/Mail/Template/FactoryInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ interface FactoryInterface
1616
* Returns the mail template associated with the identifier.
1717
*
1818
* @param string $identifier
19+
* @param null|string $namespace
1920
* @return \Magento\Framework\Mail\TemplateInterface
2021
*/
21-
public function get($identifier);
22+
public function get($identifier, $namespace = null);
2223
}

lib/internal/Magento/Framework/Mail/Template/TransportBuilder.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class TransportBuilder
2323
*/
2424
protected $templateIdentifier;
2525

26+
/**
27+
* Template Namespace
28+
*
29+
* @var string
30+
*/
31+
protected $templateNamespace;
32+
2633
/**
2734
* Template Variables
2835
*
@@ -174,6 +181,18 @@ public function setTemplateIdentifier($templateIdentifier)
174181
return $this;
175182
}
176183

184+
/**
185+
* Set template namespace
186+
*
187+
* @param string $templateNamespace
188+
* @return $this
189+
*/
190+
public function setTemplateNamespace($templateNamespace)
191+
{
192+
$this->templateNamespace = $templateNamespace;
193+
return $this;
194+
}
195+
177196
/**
178197
* Set template vars
179198
*
@@ -233,7 +252,7 @@ protected function reset()
233252
*/
234253
protected function getTemplate()
235254
{
236-
return $this->templateFactory->get($this->templateIdentifier)
255+
return $this->templateFactory->get($this->templateIdentifier, $this->templateNamespace)
237256
->setVars($this->templateVars)
238257
->setOptions($this->templateOptions);
239258
}

lib/internal/Magento/Framework/Mail/Test/Unit/Template/FactoryTest.php

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,70 @@
55
*/
66
namespace Magento\Framework\Mail\Test\Unit\Template;
77

8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
9+
810
class FactoryTest extends \PHPUnit_Framework_TestCase
911
{
1012
/**
11-
* @var \PHPUnit_Framework_MockObject
13+
* @var \PHPUnit_Framework_MockObject_MockObject
14+
*/
15+
protected $objectManagerMock;
16+
17+
/**
18+
* @var \PHPUnit_Framework_MockObject_MockObject
1219
*/
13-
protected $_objectManagerMock;
20+
protected $templateMock;
1421

1522
/**
16-
* @var \PHPUnit_Framework_MockObject
23+
* @var ObjectManagerHelper
1724
*/
18-
protected $_templateMock;
25+
protected $objectManagerHelper;
1926

27+
/**
28+
* @return void
29+
*/
2030
public function setUp()
2131
{
22-
$this->_objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface');
23-
$this->_templateMock = $this->getMock('\Magento\Framework\Mail\TemplateInterface');
32+
$this->objectManagerHelper = new ObjectManagerHelper($this);
33+
$this->objectManagerMock = $this->getMock('\Magento\Framework\ObjectManagerInterface');
34+
$this->templateMock = $this->getMock('\Magento\Framework\Mail\TemplateInterface');
2435
}
2536

2637
/**
27-
* @covers \Magento\Framework\Mail\Template\Factory::get
28-
* @covers \Magento\Framework\Mail\Template\Factory::__construct
38+
* @param string $expectedArgument
39+
* @param null|string $namespace
40+
* @return void
41+
* @dataProvider getDataProvider
2942
*/
30-
public function testGet()
43+
public function testGet($expectedArgument, $namespace)
3144
{
32-
$model = new \Magento\Framework\Mail\Template\Factory($this->_objectManagerMock);
45+
$factory = $this->objectManagerHelper->getObject(
46+
'Magento\Framework\Mail\Template\Factory',
47+
['objectManager' => $this->objectManagerMock]
48+
);
3349

34-
$this->_objectManagerMock->expects($this->once())
50+
$this->objectManagerMock->expects($this->once())
3551
->method('create')
36-
->with('Magento\Framework\Mail\TemplateInterface', ['data' => ['template_id' => 'identifier']])
37-
->will($this->returnValue($this->_templateMock));
52+
->with($expectedArgument, ['data' => ['template_id' => 'identifier']])
53+
->willReturn($this->templateMock);
3854

39-
$this->assertInstanceOf('\Magento\Framework\Mail\TemplateInterface', $model->get('identifier'));
55+
$this->assertInstanceOf('\Magento\Framework\Mail\TemplateInterface', $factory->get('identifier', $namespace));
56+
}
57+
58+
/**
59+
* @return array
60+
*/
61+
public function getDataProvider()
62+
{
63+
return [
64+
[
65+
'expectedArgument' => 'Magento\Framework\Mail\TemplateInterface',
66+
'namespace' => null
67+
],
68+
[
69+
'expectedArgument' => 'Test\Namespace\Implements\TemplateInterface',
70+
'namespace' => 'Test\Namespace\Implements\TemplateInterface'
71+
]
72+
];
4073
}
4174
}

0 commit comments

Comments
 (0)