1414use Magento \Framework \App \Area ;
1515use Magento \Framework \App \Config \ScopeConfigInterface ;
1616use Magento \Framework \App \Filesystem \DirectoryList ;
17+ use Magento \Framework \DataObject ;
1718use Magento \Framework \Exception \MailException ;
1819use Magento \Framework \Exception \NoSuchEntityException ;
1920use Magento \Framework \App \State ;
3536use Magento \Framework \View \LayoutFactory ;
3637use Magento \Framework \View \LayoutInterface ;
3738use Magento \Store \Api \Data \StoreInterface ;
39+ use Magento \Store \Model \Store ;
3840use Magento \Store \Model \StoreManagerInterface ;
3941use Magento \Variable \Model \Source \Variables ;
4042use Magento \Variable \Model \VariableFactory ;
4143use PHPUnit \Framework \MockObject \MockObject ;
4244use PHPUnit \Framework \TestCase ;
4345use 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