@@ -69,6 +69,11 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
69
69
*/
70
70
protected $ areaResolverMock ;
71
71
72
+ /**
73
+ * @var \Magento\Framework\Locale\ResolverInterface|\PHPUnit_Framework_MockObject_MockObject
74
+ */
75
+ protected $ localeMock ;
76
+
72
77
protected function setUp ()
73
78
{
74
79
$ this ->assetRepo = $ this ->getMock ('Magento\Framework\View\Asset\Repository ' , [], [], '' , false );
@@ -79,8 +84,8 @@ protected function setUp()
79
84
$ this ->asset = $ this ->getMock ('Magento\Framework\View\Asset\File ' , [], [], '' , false );
80
85
$ this ->remoteAsset = $ this ->getMock ('\Magento\Framework\View\Asset\Remote ' , [], [], '' , false );
81
86
$ this ->title = $ this ->getMock ('Magento\Framework\View\Page\Title ' , [], [], '' , false );
82
- $ locale = $ this ->getMockForAbstractClass ('Magento\Framework\Locale\ResolverInterface ' , [], '' , false );
83
- $ locale ->expects ($ this ->any ())
87
+ $ this -> localeMock = $ this ->getMockForAbstractClass ('Magento\Framework\Locale\ResolverInterface ' , [], '' , false );
88
+ $ this -> localeMock ->expects ($ this ->any ())
84
89
->method ('getLocale ' )
85
90
->willReturn (Resolver::DEFAULT_LOCALE );
86
91
$ this ->model = (new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this ))
@@ -91,7 +96,7 @@ protected function setUp()
91
96
'pageAssets ' => $ this ->pageAssets ,
92
97
'scopeConfig ' => $ this ->scopeConfig ,
93
98
'favicon ' => $ this ->favicon ,
94
- 'localeResolver ' => $ locale
99
+ 'localeResolver ' => $ this -> localeMock
95
100
]
96
101
);
97
102
@@ -491,16 +496,43 @@ public function testGetDefaultFavicon()
491
496
$ this ->model ->getDefaultFavicon ();
492
497
}
493
498
494
- public function testGetIncludes ()
499
+ /**
500
+ * @param bool $isAvailable
501
+ * @param string $result
502
+ * @dataProvider getIncludesDataProvider
503
+ */
504
+ public function testGetIncludes ($ isAvailable , $ result )
495
505
{
496
- $ xml = '
497
- <script type="text/javascript">
498
- Fieldset.addToPrefix(1);
499
- </script>
500
- ' ;
501
- $ this ->scopeConfig ->expects ($ this ->once ())->method ('getValue ' )->with ('design/head/includes ' , 'store ' )->will (
502
- $ this ->returnValue ($ xml )
503
- );
504
- $ this ->assertEquals ($ xml , $ this ->model ->getIncludes ());
506
+ $ model = (new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this ))
507
+ ->getObject (
508
+ 'Magento\Framework\View\Page\Config ' ,
509
+ [
510
+ 'assetRepo ' => $ this ->assetRepo ,
511
+ 'pageAssets ' => $ this ->pageAssets ,
512
+ 'scopeConfig ' => $ this ->scopeConfig ,
513
+ 'favicon ' => $ this ->favicon ,
514
+ 'localeResolver ' => $ this ->localeMock ,
515
+ 'isIncludesAvailable ' => $ isAvailable
516
+ ]
517
+ );
518
+
519
+ $ this ->scopeConfig ->expects ($ isAvailable ? $ this ->once () : $ this ->never ())
520
+ ->method ('getValue ' )
521
+ ->with ('design/head/includes ' , 'store ' )
522
+ ->willReturn ($ result );
523
+ $ this ->assertEquals ($ result , $ model ->getIncludes ());
524
+ }
525
+
526
+ public function getIncludesDataProvider ()
527
+ {
528
+ return [
529
+ [
530
+ true ,
531
+ '<script type="text/javascript">
532
+ Fieldset.addToPrefix(1);
533
+ </script> '
534
+ ],
535
+ [false , null ]
536
+ ];
505
537
}
506
538
}
0 commit comments