protected function setUp() { /** Init all dependencies for SUT. */ $this->_storeMock = $this->getMockBuilder('Mage_Core_Model_Store')->disableOriginalConstructor()->getMock(); $this->_applicationMock = $this->getMockBuilder('Mage_Core_Model_App')->disableOriginalConstructor()->getMock(); $this->_applicationMock->expects($this->any())->method('getStore')->will($this->returnValue($this->_storeMock)); $this->_requestMock = $this->getMockBuilder('Mage_Webapi_Controller_Request_Soap')->disableOriginalConstructor()->getMock(); $this->_domDocumentFactory = $this->getMockBuilder('Magento_DomDocument_Factory')->disableOriginalConstructor()->getMock(); parent::setUp(); }
/** * Test maskException method with turned on developer mode. */ public function testMaskExceptionInDeveloperMode() { /** Mock app isDeveloperMode to return true. */ $this->_appMock->expects($this->once())->method('isDeveloperMode')->will($this->returnValue(true)); /** Init Logical exception. */ $logicalException = new LogicException(); /** Asser Webapi exception was not masked. */ $this->assertEquals($this->_errorProcessor->maskException($logicalException), $logicalException, 'Exception was masked wrong in developer mode.'); }
/** * Test sendResponse method with exception rendering. * * @dataProvider dataProviderForSendResponseWithExceptionInDeveloperMode */ public function testSendResponseWithExceptionInDeveloperMode($exception, $expectedResult, $assertMessage) { /** Mock all required objects. */ $this->_rendererMock->expects($this->any())->method('getMimeType')->will($this->returnValue('application/json')); $this->_rendererMock->expects($this->any())->method('render')->will($this->returnCallback(array($this, 'callbackForSendResponseTest'), $this->returnArgument(0))); $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(true)); $this->_responseRest->setException($exception); /** Start output buffering. */ ob_start(); $this->_responseRest->sendResponse(); /** Clear output buffering. */ ob_end_clean(); $actualResponse = $this->_responseRest->getBody(); $this->assertStringStartsWith($expectedResult, $actualResponse, $assertMessage); }
public function testUpdateDesignMode() { $this->_setAdditionalExpectations(); $request = $this->getMock('Mage_Core_Controller_Request_Http', array('getParam'), array(), '', false); $controller = $this->getMock('Mage_Adminhtml_Controller_Action', array('getFullActionName'), array(), '', false); $request->expects($this->once())->method('getParam')->with('handle', '')->will($this->returnValue('default')); $this->_backendSession->expects($this->once())->method('setData')->with('vde_current_mode', Mage_DesignEditor_Model_State::MODE_DESIGN); $this->_backendSession->expects($this->once())->method('getData')->with('theme_id')->will($this->returnValue(self::THEME_ID)); $this->_urlModelFactory->expects($this->once())->method('replaceClassName')->with(self::URL_MODEL_DESIGN_MODE_CLASS_NAME); $this->_layoutFactory->expects($this->once())->method('createLayout')->with(array('area' => self::AREA_CODE), self::LAYOUT_DESIGN_CLASS_NAME); $this->_objectManager->expects($this->once())->method('addAlias')->with(self::LAYOUT_UPDATE_RESOURCE_MODEL_CORE_CLASS_NAME, self::LAYOUT_UPDATE_RESOURCE_MODEL_VDE_CLASS_NAME); $this->_designPackage->expects($this->once())->method('getConfigPathByArea')->with(Mage_Core_Model_App_Area::AREA_FRONTEND)->will($this->returnValue(self::THEME_CONFIGURATION)); $store = $this->getMock('Mage_Core_Model_Store', array('setConfig'), array(), '', false); $store->expects($this->once())->method('setConfig')->with(self::THEME_CONFIGURATION, self::THEME_ID); $this->_application->expects($this->once())->method('getStore')->will($this->returnValue($store)); $this->_model->update(self::AREA_CODE, $request, $controller); }