2016-09-05 16:43:37 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Aviat\Banker\Tests\Driver;
|
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class DriverTestBase extends TestCase {
|
|
|
|
|
|
|
|
protected $driver;
|
2016-09-06 20:26:28 -04:00
|
|
|
|
2016-09-06 17:03:43 -04:00
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
$this->driver->__destruct();
|
|
|
|
}
|
2016-09-05 16:43:37 -04:00
|
|
|
|
|
|
|
public function testGetSet()
|
|
|
|
{
|
|
|
|
$this->driver->set('foo', 'bar');
|
|
|
|
$this->assertEquals('bar', $this->driver->get('foo'));
|
|
|
|
|
|
|
|
$bar = [
|
|
|
|
'foo' => [
|
|
|
|
'apple' => 'orange'
|
|
|
|
],
|
|
|
|
'bar' => 'baz'
|
|
|
|
];
|
|
|
|
|
|
|
|
$this->driver->set('bar', $bar);
|
|
|
|
$this->assertEquals($bar, $this->driver->get('bar'));
|
|
|
|
}
|
2016-09-06 20:26:28 -04:00
|
|
|
|
|
|
|
public function testGetMultiple()
|
|
|
|
{
|
|
|
|
$this->driver->set('foo', ['bar']);
|
|
|
|
$this->driver->set('bar', (object) [
|
|
|
|
'foo' => [
|
|
|
|
'bar' => 'baz'
|
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
|
|
|
// Intentionally set the same key with different values
|
|
|
|
$this->driver->set('baz', 34);
|
|
|
|
$this->driver->set('baz', 42);
|
|
|
|
|
|
|
|
$expected = [
|
|
|
|
'foo' => ['bar'],
|
|
|
|
'bar' => (object) [
|
|
|
|
'foo' => [
|
|
|
|
'bar' => 'baz'
|
|
|
|
]
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$actual = $this->driver->getMultiple(['foo', 'bar']);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $actual);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testSetWithExpires()
|
|
|
|
{
|
|
|
|
$this->driver->set('foo', 'bar', 30);
|
|
|
|
$this->assertEquals('bar', $this->driver->get('foo'));
|
|
|
|
}
|
2016-09-05 16:43:37 -04:00
|
|
|
}
|