/** * @param int|null $integrationId * @param array $oauthRequest * @return void */ public function setupUserId($integrationId, $oauthRequest) { $integration = $this->getMockBuilder('Magento\\Integration\\Model\\Integration')->disableOriginalConstructor()->setMethods(['getId', '__wakeup'])->getMock(); $this->integrationService->expects($this->any())->method('findActiveIntegrationByConsumerId')->will($this->returnValue($integration)); $this->oauthRequestHelper->expects($this->once())->method('prepareRequest')->will($this->returnValue($oauthRequest)); $this->oauthService->expects($this->any())->method('validateAccessTokenRequest')->will($this->returnValue(1)); $integration->expects($this->any())->method('getId')->will($this->returnValue($integrationId)); }
/** * Test the basic Request action. */ public function testRequestAction() { $this->request->expects($this->any())->method('getMethod')->willReturn('GET'); $this->helperMock->expects($this->once())->method('getRequestUrl'); $this->helperMock->expects($this->once())->method('prepareRequest'); $this->frameworkOauthSvcMock->expects($this->once())->method('getRequestToken')->willReturn(['response']); $this->response->expects($this->once())->method('setBody'); $this->requestAction->execute(); }
/** * Test the basic Access action. */ public function testAccessAction() { $this->request->expects($this->any())->method('getMethod')->willReturn('GET'); $this->helperMock->expects($this->once())->method('getRequestUrl'); $this->helperMock->expects($this->once())->method('prepareRequest'); $this->frameworkOauthSvcMock->expects($this->once())->method('getAccessToken')->willReturn(['response']); /** @var \Magento\Integration\Model\Oauth\Consumer|\PHPUnit_Framework_MockObject_MockObject */ $consumerMock = $this->getMock('Magento\\Integration\\Model\\Oauth\\Consumer', [], [], '', false); $consumerMock->expects($this->once())->method('getId'); $this->intOauthServiceMock->expects($this->once())->method('loadConsumerByKey')->willReturn($consumerMock); /** @var \Magento\Integration\Model\Integration|\PHPUnit_Framework_MockObject_MockObject */ $integrationMock = $this->getMock('Magento\\Integration\\Model\\Integration', [], [], '', false); $integrationMock->expects($this->once())->method('save')->willReturnSelf(); $this->integrationServiceMock->expects($this->once())->method('findByConsumerId')->willReturn($integrationMock); $this->response->expects($this->once())->method('setBody'); $this->accessAction->executeInternal(); }