diff --git a/lib/Nekland/BaseApi/Cache/Provider/FileProvider.php b/lib/Nekland/BaseApi/Cache/Provider/FileProvider.php index 77d008f..7031a1e 100644 --- a/lib/Nekland/BaseApi/Cache/Provider/FileProvider.php +++ b/lib/Nekland/BaseApi/Cache/Provider/FileProvider.php @@ -27,6 +27,7 @@ class FileProvider implements CacheProviderInterface public function setOptions(array $options) { $this->options = array_merge($this->getOptions(), $options); + return $this; } @@ -57,9 +58,13 @@ public function get($key) public function set($key, $value) { $this->cache[$key] = $value; + return $this; } + /** + * @return string + */ protected function getPath() { return $this->options['path']; @@ -74,6 +79,8 @@ protected function getOptions() public function __destruct() { - $this->save(); + if (null !== $this->getPath()) { + $this->save(); + } } } diff --git a/spec/Nekland/BaseApi/Http/ClientAdapter/GuzzleAdapterSpec.php b/spec/Nekland/BaseApi/Http/ClientAdapter/GuzzleAdapterSpec.php index 56961f4..1a6b558 100644 --- a/spec/Nekland/BaseApi/Http/ClientAdapter/GuzzleAdapterSpec.php +++ b/spec/Nekland/BaseApi/Http/ClientAdapter/GuzzleAdapterSpec.php @@ -4,6 +4,7 @@ use GuzzleHttp\Client; use GuzzleHttp\Message\MessageInterface; +use GuzzleHttp\Message\ResponseInterface; use Nekland\BaseApi\Http\Event\RequestEvent; use Nekland\BaseApi\Http\Request; use PhpSpec\ObjectBehavior; @@ -47,10 +48,12 @@ public function it_should_send_real_request_when_event_request_not_completed( EventDispatcher $dispatcher, Request $request, RequestEvent $requestEvent, - MessageInterface $result + ResponseInterface $result ) { $guzzle->get('api.com', Argument::any())->shouldBeCalled(); $guzzle->get('api.com', Argument::any())->willReturn($result); + $result->getHeaders()->willReturn([]); + $result->getBody()->willReturn(''); $requestEvent->requestCompleted()->willReturn(false); $dispatcher diff --git a/spec/fixture/cache_file b/spec/fixture/cache_file index 2173310..f3dd466 100644 --- a/spec/fixture/cache_file +++ b/spec/fixture/cache_file @@ -1 +1 @@ -a:1:{s:9:"something";a:2:{i:0;s:3:"foz";i:1;s:3:"baz";}} +a:1:{s:9:"something";a:2:{i:0;s:3:"foz";i:1;s:3:"baz";}} \ No newline at end of file