Skip to content

Commit 52de081

Browse files
committed
MC-42486: Region ID and Country ID values and not properly converted in Email templates
- Written Unit Test
1 parent f5f1847 commit 52de081

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

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

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\Framework\App\Area;
1515
use Magento\Framework\App\Config\ScopeConfigInterface;
1616
use Magento\Framework\App\Filesystem\DirectoryList;
17+
use Magento\Framework\DataObject;
1718
use Magento\Framework\Exception\MailException;
1819
use Magento\Framework\Exception\NoSuchEntityException;
1920
use Magento\Framework\App\State;
@@ -35,12 +36,14 @@
3536
use Magento\Framework\View\LayoutFactory;
3637
use Magento\Framework\View\LayoutInterface;
3738
use Magento\Store\Api\Data\StoreInterface;
39+
use Magento\Store\Model\Store;
3840
use Magento\Store\Model\StoreManagerInterface;
3941
use Magento\Variable\Model\Source\Variables;
4042
use Magento\Variable\Model\VariableFactory;
4143
use PHPUnit\Framework\MockObject\MockObject;
4244
use PHPUnit\Framework\TestCase;
4345
use Psr\Log\LoggerInterface;
46+
use Magento\Store\Model\Information as StoreInformation;
4447

4548
/**
4649
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -148,6 +151,16 @@ class FilterTest extends TestCase
148151
*/
149152
private $directiveProcessors;
150153

154+
/**
155+
* @var StoreInformation
156+
*/
157+
private $storeInformation;
158+
159+
/**
160+
* @var store
161+
*/
162+
private $store;
163+
151164
protected function setUp(): void
152165
{
153166
$this->objectManager = new ObjectManager($this);
@@ -232,6 +245,14 @@ protected function setUp(): void
232245
->disableOriginalConstructor()
233246
->getMock(),
234247
];
248+
249+
$this->store = $this->getMockBuilder(Store::class)
250+
->disableOriginalConstructor()
251+
->getMock();
252+
253+
$this->storeInformation = $this->getMockBuilder(StoreInformation::class)
254+
->disableOriginalConstructor()
255+
->getMock();
235256
}
236257

237258
/**
@@ -260,7 +281,8 @@ protected function getModel($mockedMethods = null)
260281
$this->pubDirectory,
261282
$this->cssInliner,
262283
[],
263-
$this->directiveProcessors
284+
$this->directiveProcessors,
285+
$this->storeInformation
264286
]
265287
)
266288
->setMethods($mockedMethods)
@@ -425,8 +447,10 @@ public function testConfigDirectiveAvailable()
425447
->disableOriginalConstructor()
426448
->getMockForAbstractClass();
427449

428-
$this->storeManager->expects($this->once())->method('getStore')->willReturn($storeMock);
429-
$storeMock->expects($this->once())->method('getId')->willReturn(1);
450+
$this->storeManager->expects($this->any())
451+
->method('getStore')
452+
->willReturn($this->store);
453+
$storeMock->expects($this->any())->method('getId')->willReturn(1);
430454

431455
$this->configVariables->expects($this->once())
432456
->method('getData')
@@ -435,6 +459,10 @@ public function testConfigDirectiveAvailable()
435459
->method('getValue')
436460
->willReturn($scopeConfigValue);
437461

462+
$this->storeInformation->expects($this->once())
463+
->method('getStoreInformationObject')
464+
->willReturn(new DataObject([]));
465+
438466
$this->assertEquals($scopeConfigValue, $this->getModel()->configDirective($construction));
439467
}
440468

@@ -448,8 +476,10 @@ public function testConfigDirectiveUnavailable()
448476
$storeMock = $this->getMockBuilder(StoreInterface::class)
449477
->disableOriginalConstructor()
450478
->getMockForAbstractClass();
451-
$this->storeManager->expects($this->once())->method('getStore')->willReturn($storeMock);
452-
$storeMock->expects($this->once())->method('getId')->willReturn(1);
479+
$this->storeManager->expects($this->any())
480+
->method('getStore')
481+
->willReturn($this->store);
482+
$storeMock->expects($this->any())->method('getId')->willReturn(1);
453483

454484
$this->configVariables->expects($this->once())
455485
->method('getData')
@@ -458,6 +488,10 @@ public function testConfigDirectiveUnavailable()
458488
->method('getValue')
459489
->willReturn($scopeConfigValue);
460490

491+
$this->storeInformation->expects($this->once())
492+
->method('getStoreInformationObject')
493+
->willReturn(new DataObject([]));
494+
461495
$this->assertEquals($scopeConfigValue, $this->getModel()->configDirective($construction));
462496
}
463497

0 commit comments

Comments
 (0)