Version 5.1 - All the GraphQL #32
@ -33,17 +33,8 @@ class SQLDriver extends DB implements \Aviat\Ion\Cache\CacheDriverInterface {
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
parent::__construct($container);
|
||||
|
||||
try
|
||||
{
|
||||
$this->db = \Query($this->db_config['collection']);
|
||||
}
|
||||
catch (\PDOException $e)
|
||||
{
|
||||
$this->valid_database = FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retreive a value from the cache backend
|
||||
|
41
tests/Ion/Cache/Driver/CacheDriverBase.php
Normal file
41
tests/Ion/Cache/Driver/CacheDriverBase.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
trait CacheDriverBase {
|
||||
|
||||
protected $foo = [
|
||||
'bar' => [
|
||||
'baz' => 'foobar'
|
||||
]
|
||||
];
|
||||
|
||||
protected $bar = 'secondvalue';
|
||||
|
||||
public function testHasCacheDriver()
|
||||
{
|
||||
$this->assertTrue((bool) $this->driver);
|
||||
}
|
||||
|
||||
public function testDriverGetSet()
|
||||
{
|
||||
$this->driver->set('foo', $this->foo);
|
||||
$this->assertEquals($this->driver->get('foo'), $this->foo);
|
||||
}
|
||||
|
||||
public function testInvalidate()
|
||||
{
|
||||
$this->driver->set('foo', $this->foo);
|
||||
$this->driver->invalidate('foo');
|
||||
$this->assertEmpty($this->driver->get('foo'));
|
||||
}
|
||||
|
||||
public function testInvalidateAll()
|
||||
{
|
||||
$this->driver->set('foo', $this->foo);
|
||||
$this->driver->set('bar', $this->bar);
|
||||
|
||||
$this->driver->invalidateAll();
|
||||
|
||||
$this->assertEmpty($this->driver->get('foo'));
|
||||
$this->assertEmpty($this->driver->get('bar'));
|
||||
}
|
||||
}
|
20
tests/Ion/Cache/Driver/SQLDriverTest.php
Normal file
20
tests/Ion/Cache/Driver/SQLDriverTest.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
require('CacheDriverBase.php');
|
||||
|
||||
use Aviat\Ion\Friend;
|
||||
use Aviat\Ion\Cache\Driver\SQLDriver;
|
||||
|
||||
class CacheSQLDriverTest extends AnimeClient_TestCase {
|
||||
use CacheDriverBase;
|
||||
|
||||
protected $driver;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->driver = new SQLDriver($this->container);
|
||||
$friend = new Friend($this->driver);
|
||||
$friend->db->query('CREATE TABLE IF NOT EXISTS "cache" ("key" TEXT NULL, "value" TEXT NULL, PRIMARY KEY ("key"))');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user