Skip to content

Commit a8d8413

Browse files
committed
Fixed tests
1 parent 094c2af commit a8d8413

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

lib/Nekland/BaseApi/Cache/Provider/FileProvider.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class FileProvider implements CacheProviderInterface
2727
public function setOptions(array $options)
2828
{
2929
$this->options = array_merge($this->getOptions(), $options);
30+
3031
return $this;
3132
}
3233

@@ -57,9 +58,13 @@ public function get($key)
5758
public function set($key, $value)
5859
{
5960
$this->cache[$key] = $value;
61+
6062
return $this;
6163
}
6264

65+
/**
66+
* @return string
67+
*/
6368
protected function getPath()
6469
{
6570
return $this->options['path'];
@@ -74,6 +79,8 @@ protected function getOptions()
7479

7580
public function __destruct()
7681
{
77-
$this->save();
82+
if (null !== $this->getPath()) {
83+
$this->save();
84+
}
7885
}
7986
}

spec/Nekland/BaseApi/Http/ClientAdapter/GuzzleAdapterSpec.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use GuzzleHttp\Client;
66
use GuzzleHttp\Message\MessageInterface;
7+
use GuzzleHttp\Message\ResponseInterface;
78
use Nekland\BaseApi\Http\Event\RequestEvent;
89
use Nekland\BaseApi\Http\Request;
910
use PhpSpec\ObjectBehavior;
@@ -47,10 +48,12 @@ public function it_should_send_real_request_when_event_request_not_completed(
4748
EventDispatcher $dispatcher,
4849
Request $request,
4950
RequestEvent $requestEvent,
50-
MessageInterface $result
51+
ResponseInterface $result
5152
) {
5253
$guzzle->get('api.com', Argument::any())->shouldBeCalled();
5354
$guzzle->get('api.com', Argument::any())->willReturn($result);
55+
$result->getHeaders()->willReturn([]);
56+
$result->getBody()->willReturn('');
5457

5558
$requestEvent->requestCompleted()->willReturn(false);
5659
$dispatcher

spec/fixture/cache_file

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a:1:{s:9:"something";a:2:{i:0;s:3:"foz";i:1;s:3:"baz";}}
1+
a:1:{s:9:"something";a:2:{i:0;s:3:"foz";i:1;s:3:"baz";}}

0 commit comments

Comments
 (0)