1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-01 22:40:39 +02:00

[feature/extension-manager] extension finder now saves ext it found a file in

PHPBB3-10323
This commit is contained in:
Nils Adermann
2011-10-13 21:19:35 +02:00
parent 7b12bba95b
commit 724f40f0f4
3 changed files with 16 additions and 13 deletions

View File

@@ -210,7 +210,7 @@ class phpbb_extension_finder
$files = $this->find($cache, false); $files = $this->find($cache, false);
$classes = array(); $classes = array();
foreach ($files as $file) foreach ($files as $file => $ext_name)
{ {
$file = preg_replace('#^includes/#', '', $file); $file = preg_replace('#^includes/#', '', $file);
@@ -253,7 +253,7 @@ class phpbb_extension_finder
$items = $this->find($cache, $is_dir); $items = $this->find($cache, $is_dir);
$result = array(); $result = array();
foreach ($items as $item) foreach ($items as $item => $ext_name)
{ {
$result[] = $this->phpbb_root_path . $item; $result[] = $this->phpbb_root_path . $item;
} }
@@ -289,6 +289,8 @@ class phpbb_extension_finder
foreach ($extensions as $name => $path) foreach ($extensions as $name => $path)
{ {
$ext_name = $name;
if (!file_exists($path)) if (!file_exists($path))
{ {
continue; continue;
@@ -349,7 +351,7 @@ class phpbb_extension_finder
(!$prefix || substr($item_name, 0, strlen($prefix)) === $prefix) && (!$prefix || substr($item_name, 0, strlen($prefix)) === $prefix) &&
(!$directory || preg_match($directory_pattern, $relative_path))) (!$directory || preg_match($directory_pattern, $relative_path)))
{ {
$files[] = str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1)); $files[str_replace(DIRECTORY_SEPARATOR, '/', $location . $name . substr($relative_path, 1))] = $ext_name;
} }
} }
} }

View File

@@ -154,12 +154,10 @@ class phpbb_extension_finder_test extends phpbb_test_case
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', $cache, '.php', '_custom_cache_name'); $finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', $cache, '.php', '_custom_cache_name');
$files = $finder->suffix('_class.php')->get_files(); $files = $finder->suffix('_class.php')->get_files();
sort($files);
$expected_files = array( $expected_files = array(
'ext/bar/my/hidden_class.php', 'ext/bar/my/hidden_class.php' => 'bar',
'ext/foo/a_class.php', 'ext/foo/a_class.php' => 'foo',
'ext/foo/b_class.php', 'ext/foo/b_class.php' => 'foo',
); );
$query = array( $query = array(
@@ -175,7 +173,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
$cache->checkAssociativeVar($this, '_custom_cache_name', array( $cache->checkAssociativeVar($this, '_custom_cache_name', array(
md5(serialize($query)) => $expected_files, md5(serialize($query)) => $expected_files,
)); ), false);
} }
public function test_cached_get_files() public function test_cached_get_files()
@@ -193,7 +191,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
$finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', new phpbb_mock_cache(array( $finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', new phpbb_mock_cache(array(
'_ext_finder' => array( '_ext_finder' => array(
md5(serialize($query)) => array('file_name'), md5(serialize($query)) => array('file_name' => 'extension'),
), ),
))); )));

View File

@@ -59,14 +59,17 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface
$test->assertEquals($data, $this->data[$var_name]); $test->assertEquals($data, $this->data[$var_name]);
} }
public function checkAssociativeVar(PHPUnit_Framework_Assert $test, $var_name, $data) public function checkAssociativeVar(PHPUnit_Framework_Assert $test, $var_name, $data, $sort = true)
{ {
$test->assertTrue(isset($this->data[$var_name])); $test->assertTrue(isset($this->data[$var_name]));
if ($sort)
{
foreach ($this->data[$var_name] as &$content) foreach ($this->data[$var_name] as &$content)
{ {
sort($content); sort($content);
} }
}
$test->assertEquals($data, $this->data[$var_name]); $test->assertEquals($data, $this->data[$var_name]);
} }