public function testStop() { // Test data $initArea = 'initial area'; $initTheme = 'initial design theme'; $initLocale = 'initial locale code'; $initialStore = 1; $initTranslateInline = false; $this->inlineTranslationMock->expects($this->once())->method('isEnabled')->willReturn($initTranslateInline); $this->viewDesignMock->expects($this->once())->method('getArea')->willReturn($initArea); $this->viewDesignMock->expects($this->once())->method('getDesignTheme')->willReturn($initTheme); $this->storeManagerMock->expects($this->any())->method('getStore')->willReturn($this->storeMock); $this->storeMock->expects($this->once())->method('getStoreId')->willReturn($initialStore); $this->localeResolverMock->expects($this->once())->method('getLocale')->willReturn($initLocale); $this->model->storeCurrentEnvironmentInfo(); // Expectations $this->inlineTranslationMock->expects($this->once())->method('resume')->with($initTranslateInline); $this->viewDesignMock->expects($this->once())->method('setDesignTheme')->with($initTheme, $initArea); $this->storeManagerMock->expects($this->once())->method('setCurrentStore')->with($initialStore); $this->localeResolverMock->expects($this->once())->method('setLocale')->with($initLocale); $this->translateMock->expects($this->once())->method('setLocale')->with($initLocale); $this->translateMock->expects($this->once())->method('loadData')->with($initArea); // Test $this->model->stopEnvironmentEmulation(); }
/** * @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)); }
public function testExecuteValidPost() { $post = ['name' => 'Name', 'comment' => 'Comment', 'email' => '*****@*****.**', 'hideit' => null]; $this->_request->expects($this->any())->method('getPostValue')->will($this->returnValue($post)); $transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface', [], [], '', false); $this->_transportBuilder->expects($this->once())->method('setTemplateIdentifier')->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('setTemplateOptions')->with(['area' => \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE, 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID])->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('setTemplateVars')->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('setFrom')->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('addTo')->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('setReplyTo')->with($post['email'])->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('getTransport')->will($this->returnValue($transport)); $transport->expects($this->once())->method('sendMessage'); $this->_inlineTranslation->expects($this->once())->method('resume'); $this->_inlineTranslation->expects($this->once())->method('suspend'); $this->_controller->execute(); }
protected function sendEmailCheck() { $storeModel = $this->getMockBuilder('\\Magento\\Store\\Model\\Store')->disableOriginalConstructor()->setMethods(['getId'])->getMock(); $transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface'); $this->scopeConfig->expects($this->any())->method('getValue')->willReturn(true); $this->transportBuilder->expects($this->once())->method('setTemplateIdentifier')->willReturnSelf(); $this->transportBuilder->expects($this->once())->method('setTemplateOptions')->willReturnSelf(); $this->transportBuilder->expects($this->once())->method('setTemplateVars')->willReturnSelf(); $this->transportBuilder->expects($this->once())->method('setFrom')->willReturnSelf(); $this->transportBuilder->expects($this->once())->method('addTo')->willReturnSelf(); $this->storeManager->expects($this->any())->method('getStore')->willReturn($storeModel); $storeModel->expects($this->any())->method('getId')->willReturn(1); $this->transportBuilder->expects($this->once())->method('getTransport')->willReturn($transport); $transport->expects($this->once())->method('sendMessage')->willReturnSelf(); $this->inlineTranslation->expects($this->once())->method('suspend')->willReturnSelf(); $this->inlineTranslation->expects($this->once())->method('resume')->willReturnSelf(); return $this; }
public function testExecuteValidPost() { $post = ['name' => 'Name', 'comment' => 'Comment', 'email' => '*****@*****.**', 'hideit' => null]; $this->_request->expects($this->any())->method('getPost')->will($this->returnValue($post)); $store = $this->getMock('\\Magento\\Store\\Model\\Store', ['getId', '__sleep', '__wakeup'], [], '', false); $store->expects($this->once())->method('getId')->will($this->returnValue(1)); $this->_storeManager->expects($this->any())->method('getStore')->will($this->returnValue($store)); $transport = $this->getMock('\\Magento\\Framework\\Mail\\TransportInterface', [], [], '', false); $this->_transportBuilder->expects($this->once())->method('setTemplateIdentifier')->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('setTemplateOptions')->with(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => 1])->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('setTemplateVars')->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('setFrom')->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('addTo')->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('setReplyTo')->with($post['email'])->will($this->returnSelf()); $this->_transportBuilder->expects($this->once())->method('getTransport')->will($this->returnValue($transport)); $transport->expects($this->once())->method('sendMessage'); $this->_inlineTranslation->expects($this->once())->method('resume'); $this->_inlineTranslation->expects($this->once())->method('suspend'); $this->_controller->execute(); }