1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-13 20:28:44 +01:00

[feature/extension-manager] Test creation of new extension finder cache

PHPBB3-10323
This commit is contained in:
Nils Adermann 2011-08-29 18:43:45 -04:00
parent 34f11a1039
commit 64827a6623
3 changed files with 42 additions and 6 deletions

View File

@ -283,11 +283,6 @@ class phpbb_extension_finder
if ($cache && $this->cache)
{
if ($this->cached_queries === false)
{
$this->cached_queries = array();
}
$this->cached_queries[$query] = $files;
$this->cache->put('_extension_finder', $this->cached_queries);
}

View File

@ -122,6 +122,36 @@ class phpbb_extension_finder_test extends phpbb_test_case
);
}
public function test_get_classes_create_cache()
{
$cache = new phpbb_mock_cache;
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/includes/', $cache);
$files = $finder->suffix('_class.php')->get_files();
sort($files);
$expected_files = array(
'ext/bar/my/hidden_class.php',
'ext/foo/a_class.php',
'ext/foo/b_class.php',
);
$query = array(
'default_path' => false,
'default_suffix' => '_class.php',
'default_prefix' => false,
'default_directory' => false,
'suffix' => '_class.php',
'prefix' => false,
'directory' => false,
);
$this->assertEquals($expected_files, $files);
$cache->checkAssociativeVar($this, '_extension_finder', array(
md5(serialize($query)) => $expected_files,
));
}
public function test_cached_get_files()
{
$query = array(
@ -134,7 +164,6 @@ class phpbb_extension_finder_test extends phpbb_test_case
'directory' => false,
);
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/includes/', new phpbb_mock_cache(array(
'_extension_finder' => array(
md5(serialize($query)) => array('file_name'),

View File

@ -59,6 +59,18 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface
$test->assertEquals($data, $this->data[$var_name]);
}
public function checkAssociativeVar(PHPUnit_Framework_Assert $test, $var_name, $data)
{
$test->assertTrue(isset($this->data[$var_name]));
foreach ($this->data[$var_name] as &$content)
{
sort($content);
}
$test->assertEquals($data, $this->data[$var_name]);
}
public function checkVarUnset(PHPUnit_Framework_Assert $test, $var_name)
{
$test->assertFalse(isset($this->data[$var_name]));