1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/tests/CacheQuerySqliteTestCase.php

40 lines
1.4 KiB
PHP
Raw Normal View History

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-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();
}
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
}
}