Ejemplo n.º 1
0
 /**
  * Get token.
  *
  * @return array
  */
 public function getTokenData()
 {
     if (empty($this->tokenData)) {
         $this->tokenData = (array) $this->storage->getTokenData();
     }
     return $this->tokenData;
 }
Ejemplo n.º 2
0
 public function let(ClientInterface $mockedClient, EventInterface $mockedEvent, InputInterface $mockedInput, RedirectInterface $mockedRedirect, ResponseInterface $mockedResponse, RequestInterface $mockedRequest, StorageInterface $mockedStorage)
 {
     $settings = ['credentials' => ['consumerKey' => 'testingClientId', 'consumerSecret' => 'testingClientSecret', 'callbackURI' => 'callbackURL', 'loginURL' => 'https://login.salesforce.com'], 'authenticationFlow' => 'WebServer', 'parameters' => ['display' => 'popup', 'immediate' => 'false', 'state' => '', 'scope' => '', 'prompt' => ''], 'instanceURL' => '', 'authRedirect' => 'redirectURL', 'version' => '30.0', 'defaults' => ['method' => 'get', 'format' => 'json', 'compression' => false, 'compressionType' => 'gzip'], 'language' => 'en_US'];
     $token = ['access_token' => 'xxxxaccess.tokenxxxx', 'id' => 'https://login.salesforce.com/id/00Di0000000XXXXXX/005i0000000xxxxXXX', 'instance_url' => 'https://na##.salesforce.com', 'token_type' => 'Bearer', 'refresh_token' => 'xxxxrefresh.tokenxxxx'];
     $resources = ['sobjects' => '/services/data/v30.0/sobjects', 'connect' => '/services/data/v30.0/connect', 'query' => '/services/data/v30.0/query', 'theme' => '/services/data/v30.0/theme', 'queryAll' => '/services/data/v30.0/queryAll', 'tooling' => '/services/data/v30.0/tooling', 'chatter' => '/services/data/v30.0/chatter', 'analytics' => '/services/data/v30.0/analytics', 'recent' => '/services/data/v30.0/recent', 'process' => '/services/data/v30.0/process', 'identity' => 'https://login.salesforce.com/id/00D', 'flexiPage' => '/services/data/v30.0/flexiPage', 'search' => '/services/data/v30.0/search', 'quickActions' => '/services/data/v30.0/quickActions', 'appMenu' => '/services/data/v30.0/appMenu'];
     //Storage stubs
     $mockedStorage->get('resources')->willReturn($resources);
     $mockedStorage->get('version')->willReturn(['url' => '/services/data/v35.0', 'version' => '35.0']);
     $mockedStorage->getTokenData()->willReturn(['access_token' => 'accessToken', 'id' => 'https://login.salesforce.com/id/00D', 'instance_url' => 'https://na00.salesforce.com', 'token_type' => 'Oauth']);
     $this->beConstructedWith($mockedClient, $mockedEvent, $mockedInput, $mockedRedirect, $mockedStorage, $settings);
 }
Ejemplo n.º 3
0
 public function it_returns_a_resource(ClientInterface $mockedClient, StorageInterface $mockedStorage, RequestInterface $mockedRequest, ResponseInterface $mockedResponse)
 {
     $mockedClient->createRequest(Argument::type('string'), Argument::type('string'), Argument::type('array'))->willReturn($mockedRequest);
     $mockedClient->send(Argument::any())->willReturn($mockedResponse);
     $mockedResponse->json()->shouldBeCalled()->willReturn('jsonResource');
     $mockedResponse->xml()->shouldBeCalled()->willReturn('xmlResource');
     $mockedStorage->getTokenData()->willReturn(['access_token' => 'abc', 'instance_url' => 'def', 'token_type' => 'bearer']);
     $this->request('uri', [])->shouldReturn('jsonResource');
     $this->request('uri', ['format' => 'xml'])->shouldReturn('xmlResource');
 }
Ejemplo n.º 4
0
 function it_should_format_header_without_compression(ClientInterface $mockedClient, StorageInterface $mockedStorage, RequestInterface $mockedRequest, ResponseInterface $mockedResponse)
 {
     $mockedStorage->getTokenData()->willReturn(array('access_token' => 'accesstoken', 'instance_url' => 'def', 'token_type' => 'bearer'));
     $mockedClient->createRequest("get", "uri", ['headers' => ["Authorization" => "bearer accesstoken", "Accept" => "application/json", "Content-Type" => "application/json"]])->shouldBeCalled()->willReturn($mockedRequest);
     $mockedClient->send(Argument::any())->willReturn($mockedResponse);
     $mockedResponse->json()->shouldBeCalled()->willReturn('jsonResource');
     $this->request('uri', ['compression' => false])->shouldReturn('jsonResource');
 }
Ejemplo n.º 5
0
 public function it_should_format_header_without_compression(ClientInterface $mockedClient, StorageInterface $mockedStorage, RequestInterface $mockedRequest, ResponseInterface $mockedResponse)
 {
     $mockedStorage->getTokenData()->willReturn(['access_token' => 'accesstoken', 'instance_url' => 'def', 'token_type' => 'bearer']);
     $mockedClient->request('get', 'uri', ['headers' => ['Authorization' => 'bearer accesstoken', 'Accept' => 'application/json', 'Content-Type' => 'application/json']])->shouldBeCalled()->willReturn($mockedResponse);
     $mockedResponse->getBody()->shouldBeCalled()->willReturn($this->responseJSON);
     $responseJSON = json_decode($this->responseJSON, true);
     $this->request('uri', ['compression' => false])->shouldReturn($responseJSON);
 }