Пример #1
0
 function let(HttpAdapter $httpAdapter, Cache $cache)
 {
     $this->tempDir = vfsStream::setup('path');
     $httpAdapter->setUrl('http://api.doc.build/')->shouldBeCalled();
     $cache->contains('token')->willReturn(true);
     $cache->fetch('token')->willReturn('myapitoken');
     $this->beConstructedWith('myid', 'mysecret', [], $httpAdapter, $cache);
 }
Пример #2
0
 /**
  * @param null $clientId
  * @param null $clientSecret
  * @param array $options
  * @param HttpAdapter $http
  * @param Cache $cache
  */
 public function __construct($clientId, $clientSecret, array $options = [], HttpAdapter $http = null, Cache $cache = null)
 {
     $this->optionsResolver = new OptionsResolver();
     $this->setOptions($options);
     if ($http) {
         $this->http = $http;
     } else {
         $this->http = new GuzzleAdapter();
     }
     if ($cache) {
         $this->cache = $cache;
     } else {
         $this->cache = new FilesystemCache(sys_get_temp_dir());
     }
     $this->clientId = $clientId;
     $this->clientSecret = $clientSecret;
     $this->http->setUrl($this->options['url']);
 }