@@ -85,37 +85,59 @@ public function testConstructor()
85
85
86
86
/**
87
87
* Test \Magento\TestFramework\Application will correctly load specified areas.
88
- *
89
- * @dataProvider loadAreaDataProvider
90
- * @param string $areaCode
91
88
*/
92
- public function testLoadArea ( string $ areaCode )
89
+ public function testBackEndLoadArea ( )
93
90
{
94
- $ configScope = $ this ->getMockBuilder (Scope::class)
95
- ->disableOriginalConstructor ()
96
- ->getMock ();
97
- $ configScope ->expects ($ this ->once ())
98
- ->method ('setCurrentScope ' )
99
- ->with ($ this ->identicalTo ($ areaCode ));
91
+ $ configScope = $ this ->getMockBuilder (Scope::class)->disableOriginalConstructor ()->getMock ();
92
+ $ configScope ->expects ($ this ->once ())->method ('setCurrentScope ' )->with ($ this ->identicalTo (Area::AREA_ADMINHTML ));
100
93
101
- $ configLoader = $ this ->getMockBuilder (ConfigLoader::class)
102
- ->disableOriginalConstructor ()
103
- ->getMock ();
94
+ $ configLoader = $ this ->getMockBuilder (ConfigLoader::class)->disableOriginalConstructor ()->getMock ();
104
95
$ configLoader ->expects ($ this ->once ())
105
96
->method ('load ' )
106
- ->with ($ this ->identicalTo ($ areaCode ))
97
+ ->with ($ this ->identicalTo (Area:: AREA_ADMINHTML ))
107
98
->willReturn ([]);
108
- $ areaList = $ this ->getMockBuilder (AreaList::class)
109
- ->disableOriginalConstructor ()
110
- ->getMock ();
99
+ $ areaList = $ this ->getMockBuilder (AreaList::class)->disableOriginalConstructor ()->getMock ();
111
100
112
101
/** @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManager */
113
- $ objectManager = $ this ->getMockBuilder (ObjectManagerInterface::class)
102
+ $ objectManager = $ this ->getMockBuilder (ObjectManagerInterface::class)->disableOriginalConstructor ()->getMock ();
103
+ $ objectManager ->expects ($ this ->once ())->method ('configure ' )->with ($ this ->identicalTo ([]));
104
+ $ objectManager ->expects ($ this ->exactly (3 ))
105
+ ->method ('get ' )
106
+ ->willReturnOnConsecutiveCalls (
107
+ $ configScope ,
108
+ $ configLoader ,
109
+ $ areaList
110
+ );
111
+
112
+ \Magento \TestFramework \Helper \Bootstrap::setObjectManager ($ objectManager );
113
+
114
+ $ bootstrap = $ this ->getMockBuilder (\Magento \TestFramework \Helper \Bootstrap::class)
114
115
->disableOriginalConstructor ()
115
116
->getMock ();
116
- $ objectManager ->expects ($ this ->once ())
117
- ->method ('configure ' )
118
- ->with ($ this ->identicalTo ([]));
117
+ $ bootstrap ->expects ($ this ->once ())->method ('loadArea ' )->with ($ this ->identicalTo (Area::AREA_ADMINHTML ));
118
+ \Magento \TestFramework \Helper \Bootstrap::setInstance ($ bootstrap );
119
+
120
+ $ this ->subject ->loadArea (Area::AREA_ADMINHTML );
121
+ }
122
+
123
+ /**
124
+ * Test \Magento\TestFramework\Application will correctly load specified areas.
125
+ */
126
+ public function testFrontEndLoadArea ()
127
+ {
128
+ $ configScope = $ this ->getMockBuilder (Scope::class)->disableOriginalConstructor ()->getMock ();
129
+ $ configScope ->expects ($ this ->once ())->method ('setCurrentScope ' )->with ($ this ->identicalTo (Area::AREA_FRONTEND ));
130
+
131
+ $ configLoader = $ this ->getMockBuilder (ConfigLoader::class)->disableOriginalConstructor ()->getMock ();
132
+ $ configLoader ->expects ($ this ->once ())
133
+ ->method ('load ' )
134
+ ->with ($ this ->identicalTo (Area::AREA_FRONTEND ))
135
+ ->willReturn ([]);
136
+ $ areaList = $ this ->getMockBuilder (AreaList::class)->disableOriginalConstructor ()->getMock ();
137
+
138
+ /** @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManager */
139
+ $ objectManager = $ this ->getMockBuilder (ObjectManagerInterface::class)->disableOriginalConstructor ()->getMock ();
140
+ $ objectManager ->expects ($ this ->once ())->method ('configure ' )->with ($ this ->identicalTo ([]));
119
141
$ objectManager ->expects ($ this ->exactly (3 ))
120
142
->method ('get ' )
121
143
->willReturnOnConsecutiveCalls (
@@ -125,20 +147,7 @@ public function testLoadArea(string $areaCode)
125
147
);
126
148
127
149
\Magento \TestFramework \Helper \Bootstrap::setObjectManager ($ objectManager );
128
- try {
129
- \Magento \TestFramework \Helper \Bootstrap::getInstance ();
130
- } catch (LocalizedException $ e ) {
131
- /** @var \Magento\TestFramework\Helper\Bootstrap|\PHPUnit_Framework_MockObject_MockObject $bootstrap */
132
- $ bootstrap = $ this ->getMockBuilder (\Magento \TestFramework \Helper \Bootstrap::class)
133
- ->disableOriginalConstructor ()
134
- ->getMock ();
135
- $ bootstrap ->expects ($ this ->once ())
136
- ->method ('loadArea ' )
137
- ->with ($ this ->identicalTo ($ areaCode ));
138
- \Magento \TestFramework \Helper \Bootstrap::setInstance ($ bootstrap );
139
- }
140
-
141
- $ this ->subject ->loadArea ($ areaCode );
150
+ $ this ->subject ->loadArea (Area::AREA_FRONTEND );
142
151
}
143
152
144
153
/**
@@ -221,21 +230,4 @@ public function partialLoadAreaDataProvider()
221
230
],
222
231
];
223
232
}
224
-
225
- /**
226
- * Provide test data for testLoadArea().
227
- *
228
- * @return array
229
- */
230
- public function loadAreaDataProvider ()
231
- {
232
- return [
233
- [
234
- 'area_code ' => Area::AREA_ADMINHTML ,
235
- ],
236
- [
237
- 'area_code ' => Area::AREA_FRONTEND ,
238
- ],
239
- ];
240
- }
241
233
}
0 commit comments