9 use \Magento\Framework\App\Area;
10 use \Magento\Framework\App\AreaList;
11 use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
33 $this->scopeMock = $this->getMockForAbstractClass(
40 $this->areaListMock = $this->createMock(AreaList::class);
41 $this->areaListMock->expects($this->any())
47 [
'configScope' => $this->scopeMock]
50 $objectManager->setBackwardCompatibleProperty($this->model,
'areaList', $this->areaListMock);
56 $this->scopeMock->expects($this->once())->method(
'setCurrentScope')->with($areaCode);
57 $this->model->setAreaCode($areaCode);
58 $this->expectException(\
Magento\Framework\Exception\LocalizedException::class);
64 $this->scopeMock->expects($this->never())->method(
'setCurrentScope');
65 $this->expectException(\
Magento\Framework\Exception\LocalizedException::class);
66 $this->model->getAreaCode();
72 $this->scopeMock->expects($this->once())->method(
'setCurrentScope')->with($areaCode);
73 $this->model->setAreaCode($areaCode);
74 $this->assertEquals($areaCode, $this->model->getAreaCode());
81 $this->scopeMock->expects($this->once())->method(
'setCurrentScope')->with($areaCode);
82 $this->model->setAreaCode($areaCode);
85 $this->model->emulateAreaCode($emulatedCode, [$this,
'emulateAreaCodeCallback'])
87 $this->assertEquals($this->model->getAreaCode(), $areaCode);
96 return $this->model->getAreaCode();
103 $this->scopeMock->expects($this->once())->method(
'setCurrentScope')->with($areaCode);
104 $this->model->setAreaCode($areaCode);
106 $this->model->isAreaCodeEmulated(),
107 'By default, area code is not emulated' 110 $this->model->emulateAreaCode($emulatedCode, [$this,
'isAreaCodeEmulatedCallback']),
111 'isAreaCodeEmulated should return true when being called within the context of an emulated method' 114 $this->model->isAreaCodeEmulated(),
115 'Now that emulateAreaCode execution has finished, this should return false again' 126 return $this->model->isAreaCodeEmulated();
137 $this->scopeMock->expects($this->once())->method(
'setCurrentScope')->with($areaCode);
138 $this->model->setAreaCode($areaCode);
139 $this->model->emulateAreaCode($emulatedCode, [$this,
'emulateAreaCodeCallbackException']);
140 $this->assertEquals($this->model->getAreaCode(), $areaCode);
145 throw new \Exception(
'Some error');
154 $model = new \Magento\Framework\App\State(
155 $this->getMockForAbstractClass(\
Magento\Framework\
Config\ScopeInterface::class, [],
'',
false),
179 new \Magento\Framework\App\State(
180 $this->getMockForAbstractClass(\
Magento\Framework\
Config\ScopeInterface::class, [],
'',
false),
191 $this->model->setAreaCode(
'any code');
emulateAreaCodeCallback()
isAreaCodeEmulatedCallback()
static constructorDataProvider()
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
emulateAreaCodeCallbackException()
testCheckAreaCodeException()
testEmulateAreaCodeException()
testGetAreaCodeException()
testConstructorException()