aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2011-08-29 18:43:45 -0400
committerNils Adermann <naderman@naderman.de>2011-09-29 15:42:48 +0200
commit64827a6623c9a916d41c2ef5bf2c2092a3008722 (patch)
tree64ce834b557ac76d2f0a78f3bad2f8cc07942312
parent34f11a1039745ee1de48f1818f781ae1ee2b85ac (diff)
downloadforums-64827a6623c9a916d41c2ef5bf2c2092a3008722.tar
forums-64827a6623c9a916d41c2ef5bf2c2092a3008722.tar.gz
forums-64827a6623c9a916d41c2ef5bf2c2092a3008722.tar.bz2
forums-64827a6623c9a916d41c2ef5bf2c2092a3008722.tar.xz
forums-64827a6623c9a916d41c2ef5bf2c2092a3008722.zip
[feature/extension-manager] Test creation of new extension finder cache
PHPBB3-10323
-rw-r--r--phpBB/includes/extension/finder.php5
-rw-r--r--tests/extension/finder_test.php31
-rw-r--r--tests/mock/cache.php12
3 files changed, 42 insertions, 6 deletions
diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php
index d25823ca43..b3cdbd6ab9 100644
--- a/phpBB/includes/extension/finder.php
+++ b/phpBB/includes/extension/finder.php
@@ -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);
}
diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php
index 4acfe53937..fb2faaf5c0 100644
--- a/tests/extension/finder_test.php
+++ b/tests/extension/finder_test.php
@@ -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'),
diff --git a/tests/mock/cache.php b/tests/mock/cache.php
index 989180c256..b745123801 100644
--- a/tests/mock/cache.php
+++ b/tests/mock/cache.php
@@ -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]));