ion/tests/Cache/Driver/CacheDriverBase.php

59 lines
1.3 KiB
PHP
Raw Normal View History

2016-10-13 13:11:22 -04:00
<?php declare(strict_types=1);
/**
* Ion
*
* Building blocks for web development
*
* PHP version 7
*
* @package Ion
* @author Timothy J. Warren <tim@timshomepage.net>
* @copyright 2015 - 2016 Timothy J. Warren
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @version 1.0.0
* @link https://git.timshomepage.net/timw4mail/ion
*/
2016-08-29 11:34:25 -04:00
namespace Aviat\Ion\Tests\Cache\Driver;
trait CacheDriverBase {
2016-08-29 11:34:25 -04:00
protected $foo = [
'bar' => [
'baz' => 'foobar'
]
];
2016-08-29 11:34:25 -04:00
protected $bar = 'secondvalue';
2016-08-29 11:34:25 -04:00
public function testHasCacheDriver()
{
$this->assertTrue((bool) $this->driver);
}
2016-08-29 11:34:25 -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
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
public function testInvalidateAll()
{
$this->driver->set('foo', $this->foo);
$this->driver->set('bar', $this->bar);
2016-08-29 11:34:25 -04:00
$this->driver->invalidateAll();
2016-08-29 11:34:25 -04:00
$this->assertEmpty($this->driver->get('foo'));
$this->assertEmpty($this->driver->get('bar'));
}
}