public function testCheckResourceAclMageWebapiException() { $this->_coreAuthorization->expects($this->exactly(2))->method('isAllowed')->will($this->returnValue(false)); $this->_helperMock->expects($this->once())->method('__')->will($this->returnArgument(0)); $this->setExpectedException('Mage_Webapi_Exception', 'Access to resource is forbidden.'); $this->_webapiAuthorization->checkResourceAcl('invalidResource', 'invalidMethod'); }
protected function setUp() { $this->_helper = new Magento_Test_Helper_ObjectManager($this); $this->_helperData = $this->getMockBuilder('Mage_Webapi_Helper_Data')->disableOriginalConstructor()->setMethods(array('__'))->getMock(); $this->_helperData->expects($this->any())->method('__')->will($this->returnArgument(0)); $this->_objectManager = $this->getMockBuilder('Magento_ObjectManager')->disableOriginalConstructor()->setMethods(array('create'))->getMockForAbstractClass(); }
protected function setUp() { /** Prepare mocks for SUT constructor. */ $this->_apiConfigMock = $this->getMockBuilder('Mage_Webapi_Model_Config_Rest')->disableOriginalConstructor()->getMock(); $interpreterFactory = $this->getMockBuilder('Mage_Webapi_Controller_Request_Rest_Interpreter_Factory')->disableOriginalConstructor()->getMock(); $this->_helperMock = $this->getMockBuilder('Mage_Webapi_Helper_Data')->disableOriginalConstructor()->setMethods(array('__'))->getMock(); $this->_helperMock->expects($this->any())->method('__')->will($this->returnArgument(0)); $this->_routeMock = $this->getMockBuilder('Mage_Webapi_Controller_Router_Route_Rest')->disableOriginalConstructor()->setMethods(array('match'))->getMock(); $this->_request = new Mage_Webapi_Controller_Request_Rest($interpreterFactory, $this->_helperMock); /** Initialize SUT. */ $this->_router = new Mage_Webapi_Controller_Router_Rest($this->_helperMock, $this->_apiConfigMock); }
/** * Test renderException method with turned on Developer mode. */ public function testRenderExecutionInDeveloperMode() { $this->markTestIncomplete("Think how to replace this test."); $_SERVER['HTTP_ACCEPT'] = 'json'; /** Init base Exception object. */ $exception = new Exception('Message'); /** Mock app to return enabled developer mode flag. */ $this->_appMock->expects($this->any())->method('isDeveloperMode')->will($this->returnValue(true)); /** Assert jsonEncode will be executed once. */ $this->_helperMock->expects($this->once())->method('jsonEncode'); $this->_errorProcessor->renderException($exception); }