/** * Test dispatch method. */ public function testDispatch() { $this->_authenticationMock->expects($this->once())->method('authenticate'); /** Init route mock. */ $routeMock = $this->getMockBuilder('Mage_Webapi_Controller_Router_Route_Rest')->disableOriginalConstructor()->getMock(); $routeMock->expects($this->any())->method('getResourceName'); $this->_routerMock->expects($this->once())->method('match')->will($this->returnValue($routeMock)); /** Mock Api Config getMethodNameByOperation method to return isDeleted method of Varien_Onject. */ $this->_apiConfigMock->expects($this->once())->method('getMethodNameByOperation')->will($this->returnValue('isDeleted')); /** Mock Api config identifyVersionSuffix method to return empty string. */ $this->_apiConfigMock->expects($this->once())->method('identifyVersionSuffix')->will($this->returnValue('')); $this->_apiConfigMock->expects($this->once())->method('checkDeprecationPolicy'); $this->_authorizationMock->expects($this->once())->method('checkResourceAcl'); /** Create fake controller mock, e. g. Varien_Object object. */ $controllerMock = $this->getMockBuilder('Varien_Object')->disableOriginalConstructor()->getMock(); /** Assert isDeleted method will be executed once. */ $controllerMock->expects($this->once())->method('isDeleted'); /** Mock factory mock to return fake action controller. */ $this->_controllerFactory->expects($this->once())->method('createActionController')->will($this->returnValue($controllerMock)); /** Mock Rest presentation fetchRequestData method to return empty array. */ $this->_restPresentation->expects($this->once())->method('fetchRequestData')->will($this->returnValue(array())); /** Assert response sendResponse method will be executed once. */ $this->_responseMock->expects($this->once())->method('sendResponse'); $this->_restDispatcher->dispatch(); }