public function testStartDefaults() { // Test data $inlineTranslate = false; $initArea = 'initial area'; $initTheme = 'initial design theme'; $initStore = 1; $initLocale = 'initial locale code'; $newInlineTranslate = false; $newLocale = 'new locale code'; $newArea = \Magento\Framework\App\Area::AREA_FRONTEND; // Stubs $this->inlineTranslationMock->expects($this->any())->method('isEnabled')->willReturn($inlineTranslate); $this->viewDesignMock->expects($this->any())->method('getArea')->willReturn($initArea); $this->viewDesignMock->expects($this->any())->method('getDesignTheme')->willReturn($initTheme); $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock); $this->storeMock->expects($this->any())->method('getStoreId')->willReturn($initStore); $this->localeResolverMock->expects($this->any())->method('getLocale')->willReturn($initLocale); $this->inlineConfigMock->expects($this->any())->method('isActive')->willReturn($newInlineTranslate); $this->viewDesignMock->expects($this->any())->method('getConfigurationDesignTheme')->willReturn($initTheme); $this->scopeConfigMock->expects($this->any())->method('getValue')->willReturn($newLocale); // Expectations $this->storeMock->expects($this->any())->method('getStoreId')->willReturn($initStore); $this->inlineTranslationMock->expects($this->any())->method('suspend')->with($newInlineTranslate); $this->viewDesignMock->expects($this->any())->method('setDesignTheme')->with($initTheme); $this->localeResolverMock->expects($this->any())->method('setLocale')->with($newLocale); $this->translateMock->expects($this->any())->method('setLocale')->with($newLocale); $this->translateMock->expects($this->any())->method('loadData')->with($newArea); $this->storeManagerMock->expects($this->any())->method('setCurrentStore')->with(self::NEW_STORE_ID); // Test $this->model->startEnvironmentEmulation(self::NEW_STORE_ID, \Magento\Framework\App\Area::AREA_FRONTEND); }
/** * @param bool $isEnabled * @param bool $isActive * @param bool $isDevAllowed * @param null|string $scope */ protected function prepareIsAllowed($isEnabled, $isActive, $isDevAllowed, $scope = null) { $scopeMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface', [], [], '', false); $this->stateMock->expects($this->any())->method('isEnabled')->will($this->returnValue($isEnabled)); $this->scopeResolverMock->expects($this->once())->method('getScope')->with($scope)->will($this->returnValue($scopeMock)); $this->configMock->expects($this->once())->method('isActive')->with($scopeMock)->will($this->returnValue($isActive)); $this->configMock->expects($this->exactly((int) $isActive))->method('isDevAllowed')->will($this->returnValue($isDevAllowed)); }