Exemple #1
0
 function it_should_callback(ClientInterface $mockedClient, RequestInterface $mockedRequest, ResponseInterface $tokenResponse, ResponseInterface $versionResponse, StorageInterface $mockedStorage)
 {
     $mockedClient->post('https://login.salesforce.com/services/oauth2/token', Argument::type('array'))->shouldBeCalled(1)->willReturn($tokenResponse);
     $mockedClient->send(Argument::any())->shouldBeCalled(1)->willReturn($versionResponse);
     $mockedClient->createRequest(Argument::any(), Argument::any(), Argument::any())->willReturn($mockedRequest);
     $tokenResponse->json()->shouldBeCalled(1)->willReturn(array('access_token' => 'value1', 'refresh_token' => 'value2'));
     $versionResponse->json()->shouldBeCalled()->willReturn([['version' => '30.0'], ['version' => '31.0']]);
     $mockedStorage->putTokenData(Argument::type('array'))->shouldBeCalled();
     $mockedStorage->putRefreshToken(Argument::exact('value2'))->shouldBeCalled();
     $mockedStorage->put(Argument::type('string'), Argument::type('array'))->shouldBeCalled();
     $this->callback()->shouldReturn(null);
 }
Exemple #2
0
 public function it_should_callback(ClientInterface $mockedClient, InputInterface $mockedInput, ResponseInterface $tokenResponse, ResponseInterface $storeResources, StorageInterface $mockedStorage)
 {
     $mockedInput->get('code')->shouldBeCalled()->willReturn('callbackCode');
     $mockedInput->get('state')->shouldBeCalled()->willReturn(urlencode('https://login.salesforce.com'));
     $mockedClient->request('post', 'https://login.salesforce.com/services/oauth2/token', ['form_params' => ['code' => 'callbackCode', 'grant_type' => 'authorization_code', 'client_id' => 'testingClientId', 'client_secret' => 'testingClientSecret', 'redirect_uri' => 'callbackURL']])->shouldBeCalled()->willReturn($tokenResponse);
     $tokenResponse->getBody()->shouldBeCalled()->willReturn($this->authenticationJSON);
     $mockedClient->request('get', 'https://na00.salesforce.com', ['headers' => ['Authorization' => 'Oauth accessToken', 'Accept' => 'application/json', 'Content-Type' => 'application/json']])->shouldBeCalled()->willReturn($storeResources);
     $mockedStorage->get('version')->willReturn(null);
     $mockedStorage->put('loginURL', 'https://login.salesforce.com')->shouldBeCalled();
     $mockedStorage->put('resources', ['foo' => 'bar'])->shouldBeCalled();
     $mockedStorage->putTokenData(['access_token' => '00Do0000000secret', 'instance_url' => 'https://na17.salesforce.com', 'id' => 'https://login.salesforce.com/id/00D', 'token_type' => 'Bearer', 'issued_at' => '1447000236011', 'signature' => 'secretsig', 'refresh_token' => 'refreshToken'])->shouldBeCalled();
     $mockedStorage->putRefreshToken('refreshToken')->shouldBeCalled();
     $storeResources->getBody()->shouldBeCalled()->willReturn($this->responseJSON);
     $this->callback()->shouldReturn(null);
 }