/** * @param array $requestData Data from the request * @param array $parameters Data from config about which parameters to override * @param array $expectedOverriddenParams Result of overriding $requestData when applying rules from $parameters * * @dataProvider overrideParmasDataProvider */ public function testOverrideParams($requestData, $parameters, $expectedOverriddenParams) { $this->_routeMock->expects($this->once())->method('getParameters')->will($this->returnValue($parameters)); $this->_appStateMock->expects($this->any())->method('isInstalled')->will($this->returnValue(true)); $this->_authzServiceMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); $this->_requestMock->expects($this->any())->method('getRequestData')->will($this->returnValue($requestData)); // serializer should expect overridden params $this->serializerMock->expects($this->once())->method('getInputData')->with($this->equalTo('Magento\\Webapi\\Controller\\TestService'), $this->equalTo('testMethod'), $this->equalTo($expectedOverriddenParams)); $this->_restController->dispatch($this->_requestMock); }
/** * @param array $requestData Data from the request * @param array $parameters Data from config about which parameters to override * @param array $expectedOverriddenParams Result of overriding $requestData when applying rules from $parameters * @param int $userId The id of the user invoking the request * @param int $userType The type of user invoking the request * * @dataProvider overrideParmasDataProvider */ public function testOverrideParams($requestData, $parameters, $expectedOverriddenParams, $userId, $userType) { $this->_routeMock->expects($this->once())->method('getParameters')->will($this->returnValue($parameters)); $this->_routeMock->expects($this->any())->method('getAclResources')->will($this->returnValue(['1'])); $this->_authorizationMock->expects($this->once())->method('isAllowed')->will($this->returnValue(true)); $this->_requestMock->expects($this->any())->method('getRequestData')->will($this->returnValue($requestData)); $this->userContextMock->expects($this->any())->method('getUserId')->will($this->returnValue($userId)); $this->userContextMock->expects($this->any())->method('getUserType')->will($this->returnValue($userType)); // serializer should expect overridden params $this->serializerMock->expects($this->once())->method('getInputData')->with($this->equalTo('Magento\\Webapi\\Controller\\TestService'), $this->equalTo('testMethod'), $this->equalTo($expectedOverriddenParams)); $this->_restController->dispatch($this->_requestMock); }