@@ -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
@@ -498,16 +503,43 @@ public function testGetDefaultFavicon()
498
503
$ this ->model ->getDefaultFavicon ();
499
504
}
500
505
501
- public function testGetIncludes ()
506
+ /**
507
+ * @param bool $isAvailable
508
+ * @param string $result
509
+ * @dataProvider getIncludesDataProvider
510
+ */
511
+ public function testGetIncludes ($ isAvailable , $ result )
502
512
{
503
- $ xml = '
504
- <script type="text/javascript">
505
- Fieldset.addToPrefix(1);
506
- </script>
507
- ' ;
508
- $ this ->scopeConfig ->expects ($ this ->once ())->method ('getValue ' )->with ('design/head/includes ' , 'store ' )->will (
509
- $ this ->returnValue ($ xml )
510
- );
511
- $ this ->assertEquals ($ xml , $ this ->model ->getIncludes ());
513
+ $ model = (new \Magento \Framework \TestFramework \Unit \Helper \ObjectManager ($ this ))
514
+ ->getObject (
515
+ 'Magento\Framework\View\Page\Config ' ,
516
+ [
517
+ 'assetRepo ' => $ this ->assetRepo ,
518
+ 'pageAssets ' => $ this ->pageAssets ,
519
+ 'scopeConfig ' => $ this ->scopeConfig ,
520
+ 'favicon ' => $ this ->favicon ,
521
+ 'localeResolver ' => $ this ->localeMock ,
522
+ 'isIncludesAvailable ' => $ isAvailable
523
+ ]
524
+ );
525
+
526
+ $ this ->scopeConfig ->expects ($ isAvailable ? $ this ->once () : $ this ->never ())
527
+ ->method ('getValue ' )
528
+ ->with ('design/head/includes ' , 'store ' )
529
+ ->willReturn ($ result );
530
+ $ this ->assertEquals ($ result , $ model ->getIncludes ());
531
+ }
532
+
533
+ public function getIncludesDataProvider ()
534
+ {
535
+ return [
536
+ [
537
+ true ,
538
+ '<script type="text/javascript">
539
+ Fieldset.addToPrefix(1);
540
+ </script> '
541
+ ],
542
+ [false , null ]
543
+ ];
512
544
}
513
545
}
0 commit comments