Skip to content

Commit e109b59

Browse files
AnujNehraAnujNehra
authored andcommitted
ACP2E-1529 fix
1 parent b36d05d commit e109b59

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace Magento\Email\Model\Template;
99

1010
use Exception;
11+
use Magento\Backend\Model\Url as BackendModelUrl;
1112
use Magento\Cms\Block\Block;
1213
use Magento\Framework\App\Area;
1314
use Magento\Framework\App\Config\ScopeConfigInterface;
@@ -588,7 +589,7 @@ public function storeDirective($construction)
588589
* Pass extra parameter to distinguish stores urls for property Magento\Framework\Url $cacheUrl
589590
* in multi-store environment
590591
*/
591-
if ($construction[1] !== "store") {
592+
if (!$this->urlModel instanceof BackendModelUrl) {
592593
$this->urlModel->setScope($this->_storeManager->getStore());
593594
}
594595
$params['_escape_params'] = $this->_storeManager->getStore()->getCode();

app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
namespace Magento\Email\Test\Unit\Model\Template;
1010

11+
use Magento\Backend\Model\Url as BackendModelUrl;
1112
use Magento\Backend\Model\UrlInterface;
1213
use Magento\Email\Model\Template\Css\Processor;
1314
use Magento\Email\Model\Template\Filter;
@@ -576,35 +577,47 @@ public function testProtocolDirectiveWithInvalidSchema()
576577
}
577578

578579
/**
579-
* @dataProvider dataProviderCompanyRedirect
580+
* @dataProvider dataProviderUrlModelCompanyRedirect
580581
*/
581-
public function testStoreDirectiveForCompanyRedirect($construction, $expected, $code)
582+
public function testStoreDirectiveForCompanyRedirect($className, $backendModelClass)
582583
{
583584
$this->storeManager->expects($this->any())
584585
->method('getStore')
585586
->willReturn($this->store);
586-
$this->store->expects($this->any())->method('getCode')->willReturn($code);
587+
$this->store->expects($this->any())->method('getCode')->willReturn('frvw');
588+
589+
$this->backendUrlBuilder = $this->getMockBuilder($className)
590+
->onlyMethods(['setScope','getUrl'])
591+
->disableOriginalConstructor()
592+
->getMockForAbstractClass();
587593

588594
$this->backendUrlBuilder->expects($this->once())
589595
->method('getUrl')
590-
->willReturn($expected);
596+
->willReturn('http://m246ceeeb2b.test/frvw/');
591597

592-
$result = $this->getModel()->storeDirective($construction);
593-
$this->assertEquals($expected, $result);
598+
if ($backendModelClass) {
599+
$this->backendUrlBuilder->expects($this->never())->method('setScope');
600+
} else {
601+
$this->backendUrlBuilder->expects($this->once())->method('setScope')->willReturnSelf();
602+
}
603+
$this->assertInstanceOf($className, $this->backendUrlBuilder);
604+
$result = $this->getModel()->storeDirective(["{{store url=''}}",'store',"url=''"]);
605+
$this->assertEquals('http://m246ceeeb2b.test/frvw/', $result);
594606
}
595607

596-
public function dataProviderCompanyRedirect()
608+
/**
609+
* @return array[]
610+
*/
611+
public function dataProviderUrlModelCompanyRedirect(): array
597612
{
598613
return [
599614
[
600-
["{{store url=''}}",'store',"url=''"],
601-
'http://m246ceeeb2b.french.test/frvw/',
602-
'frvw'
615+
UrlInterface::class,
616+
0
603617
],
604618
[
605-
["{{store url=''}}",'store_invalid',"url=''"],
606-
'http://m246ceeeb2b.test/default/',
607-
'default'
619+
BackendModelUrl::class,
620+
1
608621
]
609622
];
610623
}

0 commit comments

Comments
 (0)