Skip to content

Commit 1a9c8f2

Browse files
markchallonerBilge
authored andcommitted
Add cache getter/setter to CachingConnector. (#27)
Add cache getter/setter to CachingConnector.
1 parent 536c748 commit 1a9c8f2

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/Connector/CachingConnector.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ public function disableCache()
5959
$this->cacheEnabled = false;
6060
}
6161

62+
public function getCache()
63+
{
64+
return $this->cache;
65+
}
66+
67+
public function setCache(CacheItemPoolInterface $cache)
68+
{
69+
$this->cache = $cache;
70+
}
71+
6272
public function isCacheEnabled()
6373
{
6474
return $this->cacheEnabled;

test/Integration/Porter/Connector/CachingConnectorTest.php

Lines changed: 9 additions & 0 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 ScriptFUSION\Porter\Cache\MemoryCache;
67
use ScriptFUSION\Porter\Connector\CachingConnector;
78
use ScriptFUSION\Porter\Options\EncapsulatedOptions;
89
use ScriptFUSIONTest\Stubs\TestOptions;
@@ -41,6 +42,14 @@ public function testCacheDisabled()
4142
self::assertSame('bar', $this->connector->fetch('baz', $this->options));
4243
}
4344

45+
public function testCache()
46+
{
47+
$cache = new MemoryCache;
48+
$this->connector->setCache($cache);
49+
50+
self::assertSame($cache, $this->connector->getCache());
51+
}
52+
4453
public function testCacheBypassedForDifferentOptions()
4554
{
4655
self::assertSame('foo', $this->connector->fetch('baz', $this->options));

0 commit comments

Comments
 (0)