14
14
use Magento \Framework \App \Area ;
15
15
use Magento \Framework \App \Config \ScopeConfigInterface ;
16
16
use Magento \Framework \App \Filesystem \DirectoryList ;
17
+ use Magento \Framework \DataObject ;
17
18
use Magento \Framework \Exception \MailException ;
18
19
use Magento \Framework \Exception \NoSuchEntityException ;
19
20
use Magento \Framework \App \State ;
35
36
use Magento \Framework \View \LayoutFactory ;
36
37
use Magento \Framework \View \LayoutInterface ;
37
38
use Magento \Store \Api \Data \StoreInterface ;
39
+ use Magento \Store \Model \Store ;
38
40
use Magento \Store \Model \StoreManagerInterface ;
39
41
use Magento \Variable \Model \Source \Variables ;
40
42
use Magento \Variable \Model \VariableFactory ;
41
43
use PHPUnit \Framework \MockObject \MockObject ;
42
44
use PHPUnit \Framework \TestCase ;
43
45
use Psr \Log \LoggerInterface ;
46
+ use Magento \Store \Model \Information as StoreInformation ;
44
47
45
48
/**
46
49
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
@@ -148,6 +151,16 @@ class FilterTest extends TestCase
148
151
*/
149
152
private $ directiveProcessors ;
150
153
154
+ /**
155
+ * @var StoreInformation
156
+ */
157
+ private $ storeInformation ;
158
+
159
+ /**
160
+ * @var store
161
+ */
162
+ private $ store ;
163
+
151
164
protected function setUp (): void
152
165
{
153
166
$ this ->objectManager = new ObjectManager ($ this );
@@ -232,6 +245,14 @@ protected function setUp(): void
232
245
->disableOriginalConstructor ()
233
246
->getMock (),
234
247
];
248
+
249
+ $ this ->store = $ this ->getMockBuilder (Store::class)
250
+ ->disableOriginalConstructor ()
251
+ ->getMock ();
252
+
253
+ $ this ->storeInformation = $ this ->getMockBuilder (StoreInformation::class)
254
+ ->disableOriginalConstructor ()
255
+ ->getMock ();
235
256
}
236
257
237
258
/**
@@ -260,7 +281,8 @@ protected function getModel($mockedMethods = null)
260
281
$ this ->pubDirectory ,
261
282
$ this ->cssInliner ,
262
283
[],
263
- $ this ->directiveProcessors
284
+ $ this ->directiveProcessors ,
285
+ $ this ->storeInformation
264
286
]
265
287
)
266
288
->setMethods ($ mockedMethods )
@@ -425,8 +447,10 @@ public function testConfigDirectiveAvailable()
425
447
->disableOriginalConstructor ()
426
448
->getMockForAbstractClass ();
427
449
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 );
430
454
431
455
$ this ->configVariables ->expects ($ this ->once ())
432
456
->method ('getData ' )
@@ -435,6 +459,10 @@ public function testConfigDirectiveAvailable()
435
459
->method ('getValue ' )
436
460
->willReturn ($ scopeConfigValue );
437
461
462
+ $ this ->storeInformation ->expects ($ this ->once ())
463
+ ->method ('getStoreInformationObject ' )
464
+ ->willReturn (new DataObject ([]));
465
+
438
466
$ this ->assertEquals ($ scopeConfigValue , $ this ->getModel ()->configDirective ($ construction ));
439
467
}
440
468
@@ -448,8 +476,10 @@ public function testConfigDirectiveUnavailable()
448
476
$ storeMock = $ this ->getMockBuilder (StoreInterface::class)
449
477
->disableOriginalConstructor ()
450
478
->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 );
453
483
454
484
$ this ->configVariables ->expects ($ this ->once ())
455
485
->method ('getData ' )
@@ -458,6 +488,10 @@ public function testConfigDirectiveUnavailable()
458
488
->method ('getValue ' )
459
489
->willReturn ($ scopeConfigValue );
460
490
491
+ $ this ->storeInformation ->expects ($ this ->once ())
492
+ ->method ('getStoreInformationObject ' )
493
+ ->willReturn (new DataObject ([]));
494
+
461
495
$ this ->assertEquals ($ scopeConfigValue , $ this ->getModel ()->configDirective ($ construction ));
462
496
}
463
497
0 commit comments