2006-06-13 22:04:04 +04:00
|
|
|
<?php
|
|
|
|
require_once("UnitTestCase.php");
|
|
|
|
|
|
|
|
class Doctrine_Cache_Query_SqliteTestCase extends Doctrine_UnitTestCase {
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2006-09-21 01:07:13 +04:00
|
|
|
|
2006-08-22 03:20:33 +04:00
|
|
|
$dir = $this->connection->getAttribute(Doctrine::ATTR_CACHE_DIR);
|
2006-06-13 22:04:04 +04:00
|
|
|
|
|
|
|
if(file_exists($dir.DIRECTORY_SEPARATOR."stats.cache"))
|
|
|
|
unlink($dir.DIRECTORY_SEPARATOR."stats.cache");
|
|
|
|
|
2006-08-22 03:20:33 +04:00
|
|
|
$this->cache = new Doctrine_Cache_Query_Sqlite($this->connection);
|
2006-06-13 22:04:04 +04:00
|
|
|
$this->cache->deleteAll();
|
|
|
|
}
|
2006-06-14 23:17:38 +04:00
|
|
|
public function testStore() {
|
|
|
|
|
|
|
|
$this->cache->store("SELECT * FROM user", array(array('name' => 'Jack Daniels')), 60);
|
|
|
|
$this->assertEqual($this->cache->count(), 1);
|
|
|
|
|
|
|
|
$this->cache->store("SELECT * FROM group", array(array('name' => 'Drinkers club')), 60);
|
|
|
|
|
|
|
|
$md5 = md5("SELECT * FROM user");
|
|
|
|
$result = $this->cache->fetch($md5);
|
|
|
|
$this->assertEqual($result, array(array('name' => 'Jack Daniels')));
|
|
|
|
|
|
|
|
$md5 = md5("SELECT * FROM group");
|
|
|
|
$result = $this->cache->fetch($md5);
|
|
|
|
$this->assertEqual($result, array(array('name' => 'Drinkers club')));
|
|
|
|
|
|
|
|
$this->assertEqual($this->cache->count(), 2);
|
|
|
|
|
|
|
|
$this->cache->delete($md5);
|
|
|
|
$this->assertEqual($this->cache->count(), 1);
|
|
|
|
|
|
|
|
$this->cache->deleteAll();
|
|
|
|
$this->assertEqual($this->cache->count(), 0);
|
2006-06-13 22:04:04 +04:00
|
|
|
}
|
|
|
|
}
|