SQLite3CacheTest.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace Doctrine\Tests\Common\Cache;
use Doctrine\Common\Cache\Cache;
use Doctrine\Common\Cache\SQLite3Cache;
use SQLite3;
class SQLite3Test extends CacheTest
{
/**
* @var SQLite3
*/
private $file, $sqlite;
protected function setUp()
{
if ( ! extension_loaded('sqlite3')) {
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of SQLite3');
}
$this->file = tempnam(null, 'doctrine-cache-test-');
unlink($this->file);
$this->sqlite = new SQLite3($this->file);
}
protected function tearDown()
{
$this->sqlite = null; // DB must be closed before
unlink($this->file);
}
public function testGetStats()
{
$this->assertNull($this->_getCacheDriver()->getStats());
}
public function testFetchSingle()
{
$id = uniqid('sqlite3_id_');
$data = "\0"; // produces null bytes in serialized format
$this->_getCacheDriver()->save($id, $data, 30);
$this->assertEquals($data, $this->_getCacheDriver()->fetch($id));
}
protected function _getCacheDriver()
{
return new SQLite3Cache($this->sqlite, 'test_table');
}
}