1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge pull request #932 from EXreaction/ticket/10875

Ticket/10875
This commit is contained in:
Nils Adermann
2012-08-14 02:30:49 -07:00
18 changed files with 103 additions and 42 deletions

View File

@@ -9,7 +9,7 @@
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_cache_test extends phpbb_test_case
class phpbb_cache_test extends phpbb_database_test_case
{
private $cache_dir;
@@ -18,8 +18,15 @@ class phpbb_cache_test extends phpbb_test_case
$this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
}
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
protected function setUp()
{
parent::setUp();
if (file_exists($this->cache_dir))
{
// cache directory possibly left after aborted
@@ -35,6 +42,8 @@ class phpbb_cache_test extends phpbb_test_case
{
$this->remove_cache_dir();
}
parent::tearDown();
}
private function create_cache_dir()
@@ -67,4 +76,34 @@ class phpbb_cache_test extends phpbb_test_case
'File ACM put and get'
);
}
public function test_cache_sql()
{
$driver = new phpbb_cache_driver_file($this->cache_dir);
global $db, $cache;
$db = $this->new_dbal();
$cache = new phpbb_cache_service($driver);
$sql = "SELECT * FROM phpbb_config
WHERE config_name = 'foo'";
$result = $db->sql_query($sql, 300);
$first_result = $db->sql_fetchrow($result);
$this->assertFileExists($this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php');
$sql = "SELECT * FROM phpbb_config
WHERE config_name = 'foo'";
$result = $db->sql_query($sql, 300);
$this->assertEquals($first_result, $db->sql_fetchrow($result));
$sql = "SELECT * FROM phpbb_config
WHERE config_name = 'bar'";
$result = $db->sql_query($sql, 300);
$this->assertNotEquals($first_result, $db->sql_fetchrow($result));
$db->sql_close();
}
}

18
tests/cache/fixtures/config.xml vendored Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_config">
<column>config_name</column>
<column>config_value</column>
<column>is_dynamic</column>
<row>
<value>foo</value>
<value>23</value>
<value>0</value>
</row>
<row>
<value>bar</value>
<value>42</value>
<value>1</value>
</row>
</table>
</dataset>

View File

@@ -121,7 +121,7 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface
public function sql_load($query)
{
}
public function sql_save($query, &$query_result, $ttl)
public function sql_save($query, $query_result, $ttl)
{
}
public function sql_exists($query_id)