Skip to content

Commit 6b749c0

Browse files
author
Stanislav Idolov
committed
1 parent baaff95 commit 6b749c0

File tree

1 file changed

+44
-52
lines changed

1 file changed

+44
-52
lines changed

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/ApplicationTest.php

Lines changed: 44 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -85,37 +85,59 @@ public function testConstructor()
8585

8686
/**
8787
* Test \Magento\TestFramework\Application will correctly load specified areas.
88-
*
89-
* @dataProvider loadAreaDataProvider
90-
* @param string $areaCode
9188
*/
92-
public function testLoadArea(string $areaCode)
89+
public function testBackEndLoadArea()
9390
{
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));
10093

101-
$configLoader = $this->getMockBuilder(ConfigLoader::class)
102-
->disableOriginalConstructor()
103-
->getMock();
94+
$configLoader = $this->getMockBuilder(ConfigLoader::class)->disableOriginalConstructor()->getMock();
10495
$configLoader->expects($this->once())
10596
->method('load')
106-
->with($this->identicalTo($areaCode))
97+
->with($this->identicalTo(Area::AREA_ADMINHTML))
10798
->willReturn([]);
108-
$areaList = $this->getMockBuilder(AreaList::class)
109-
->disableOriginalConstructor()
110-
->getMock();
99+
$areaList = $this->getMockBuilder(AreaList::class)->disableOriginalConstructor()->getMock();
111100

112101
/** @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)
114115
->disableOriginalConstructor()
115116
->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([]));
119141
$objectManager->expects($this->exactly(3))
120142
->method('get')
121143
->willReturnOnConsecutiveCalls(
@@ -125,20 +147,7 @@ public function testLoadArea(string $areaCode)
125147
);
126148

127149
\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);
142151
}
143152

144153
/**
@@ -221,21 +230,4 @@ public function partialLoadAreaDataProvider()
221230
],
222231
];
223232
}
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-
}
241233
}

0 commit comments

Comments
 (0)