Skip to content

Commit 63c8cbb

Browse files
committed
Added more assertions to CachingConnectorTest::testGetSetCache.
Reordered methods in CachingConnector.
1 parent 1a9c8f2 commit 63c8cbb

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/Connector/CachingConnector.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ public function fetch($source, EncapsulatedOptions $options = null)
4949

5050
abstract public function fetchFreshData($source, EncapsulatedOptions $options = null);
5151

52-
public function enableCache()
52+
public function getCache()
5353
{
54-
$this->cacheEnabled = true;
54+
return $this->cache;
5555
}
5656

57-
public function disableCache()
57+
public function setCache(CacheItemPoolInterface $cache)
5858
{
59-
$this->cacheEnabled = false;
59+
$this->cache = $cache;
6060
}
6161

62-
public function getCache()
62+
public function enableCache()
6363
{
64-
return $this->cache;
64+
$this->cacheEnabled = true;
6565
}
6666

67-
public function setCache(CacheItemPoolInterface $cache)
67+
public function disableCache()
6868
{
69-
$this->cache = $cache;
69+
$this->cacheEnabled = false;
7070
}
7171

7272
public function isCacheEnabled()

test/Integration/Porter/Connector/CachingConnectorTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
55
use Mockery\MockInterface;
6+
use Psr\Cache\CacheItemPoolInterface;
67
use ScriptFUSION\Porter\Cache\MemoryCache;
78
use ScriptFUSION\Porter\Connector\CachingConnector;
89
use ScriptFUSION\Porter\Options\EncapsulatedOptions;
@@ -42,11 +43,12 @@ public function testCacheDisabled()
4243
self::assertSame('bar', $this->connector->fetch('baz', $this->options));
4344
}
4445

45-
public function testCache()
46+
public function testGetSetCache()
4647
{
47-
$cache = new MemoryCache;
48-
$this->connector->setCache($cache);
48+
self::assertInstanceOf(CacheItemPoolInterface::class, $this->connector->getCache());
49+
self::assertNotSame($cache = new MemoryCache, $this->connector->getCache());
4950

51+
$this->connector->setCache($cache);
5052
self::assertSame($cache, $this->connector->getCache());
5153
}
5254

0 commit comments

Comments
 (0)