예제 #1
0
 public function testOverrideSetCorrectlyANewService()
 {
     // Arrange
     $id = 'service_foo';
     $service = new \stdClass();
     // Act.
     Container::set($id, $service);
     //Assert.
     $this->assertEquals($service, Container::get($id));
 }
예제 #2
0
 /**
  * WadifyClient constructor.
  * Valid options:
  *  - apiKey [REQUIRED]
  *  - clientId [REQUIRED]
  *  - clientSecret [REQUIRED]
  *  - version [default: latest stable version]
  *  - sandbox: [default: false]
  *  - token: [
  *      - provider: [default: Wadify\Token\StorageProvider\FileSystemProvider]
  *      - args: [default: [/tmp/wadify/token.json]]
  *    ]
  *
  * @param array $options
  */
 public function __construct(array $options = array())
 {
     $this->validateOptions($options);
     $options = array_merge($this->defaultOptions, $options);
     $this->version = $options['version'];
     $guzzleClientServiceName = false === $options['sandbox'] ? 'guzzle_client' : 'guzzle_client_sandbox';
     $this->tokenStorageProvider = $this->getTokenStorageProviderFromOptions($options['token']);
     $stack = HandlerStack::create();
     $this->client = Container::get($guzzleClientServiceName, ['config' => ['handler' => $stack, 'auth' => 'oauth2', 'headers' => ['Accept' => $this->getAcceptHeader()]]]);
     $this->pushStack($options, $stack);
 }
예제 #3
0
 /**
  * @param array $responses
  */
 protected function setClientWithMockedResponse(array $responses)
 {
     $mock = new MockHandler($responses);
     $handler = HandlerStack::create($mock);
     $this->mockClient = new GuzzleClient(['handler' => $handler]);
     Container::set('guzzle_client', $this->mockClient);
     $this->client = new Client(['apiKey' => 'foo', 'clientId' => 'bar', 'clientSecret' => 'foo-bar', 'token' => ['provider' => FileSystemProvider::class, 'args' => [vfsStream::url('test-wadify-client') . '/token.json']]]);
 }