2016-08-04 14:55:37 -04:00
|
|
|
<?php
|
|
|
|
|
2016-08-29 11:34:25 -04:00
|
|
|
namespace Aviat\Ion\Tests\Cache\Driver;
|
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
trait CacheDriverBase {
|
2016-08-29 11:34:25 -04:00
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
protected $foo = [
|
|
|
|
'bar' => [
|
|
|
|
'baz' => 'foobar'
|
|
|
|
]
|
|
|
|
];
|
2016-08-29 11:34:25 -04:00
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
protected $bar = 'secondvalue';
|
2016-08-29 11:34:25 -04:00
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
public function testHasCacheDriver()
|
|
|
|
{
|
|
|
|
$this->assertTrue((bool) $this->driver);
|
|
|
|
}
|
2016-08-29 11:34:25 -04:00
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
public function testDriverGetSet()
|
|
|
|
{
|
|
|
|
$this->driver->set('foo', $this->foo);
|
|
|
|
$this->driver->set('bar', 'baz');
|
|
|
|
$this->assertEquals($this->driver->get('foo'), $this->foo);
|
|
|
|
$this->assertEquals($this->driver->get('bar'), 'baz');
|
|
|
|
}
|
2016-08-29 11:34:25 -04:00
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
public function testInvalidate()
|
|
|
|
{
|
|
|
|
$this->driver->set('foo', $this->foo);
|
|
|
|
$this->driver->invalidate('foo');
|
|
|
|
$this->assertEmpty($this->driver->get('foo'));
|
|
|
|
}
|
2016-08-29 11:34:25 -04:00
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
public function testInvalidateAll()
|
|
|
|
{
|
|
|
|
$this->driver->set('foo', $this->foo);
|
|
|
|
$this->driver->set('bar', $this->bar);
|
2016-08-29 11:34:25 -04:00
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
$this->driver->invalidateAll();
|
2016-08-29 11:34:25 -04:00
|
|
|
|
2016-08-04 14:55:37 -04:00
|
|
|
$this->assertEmpty($this->driver->get('foo'));
|
|
|
|
$this->assertEmpty($this->driver->get('bar'));
|
|
|
|
}
|
|
|
|
}
|