mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 05:38:52 +00:00
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus: [ticket/12589] Add test searching in a non absolute directory [ticket/12589] Fix tests [ticket/12589] Search directly in $directory if it's an absolute sub-path
This commit is contained in:
commit
93c310f66b
2 changed files with 65 additions and 34 deletions
|
@ -465,6 +465,10 @@ class finder
|
|||
}
|
||||
else if ($directory && $directory[0] === '/')
|
||||
{
|
||||
if (!$is_dir)
|
||||
{
|
||||
$path .= substr($directory, 1);
|
||||
}
|
||||
$directory_pattern = '^' . preg_quote(str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR, '#');
|
||||
}
|
||||
else
|
||||
|
@ -477,6 +481,8 @@ class finder
|
|||
}
|
||||
$directory_pattern = '#' . $directory_pattern . '#';
|
||||
|
||||
if (is_dir($path))
|
||||
{
|
||||
$iterator = new \RecursiveIteratorIterator(
|
||||
new \phpbb\recursive_dot_prefix_filter_iterator(
|
||||
new \RecursiveDirectoryIterator(
|
||||
|
@ -503,7 +509,15 @@ class finder
|
|||
}
|
||||
else
|
||||
{
|
||||
$relative_path = DIRECTORY_SEPARATOR . $iterator->getInnerIterator()->getSubPathname();
|
||||
$relative_path = $iterator->getInnerIterator()->getSubPathname();
|
||||
if ($directory && $directory[0] === '/')
|
||||
{
|
||||
$relative_path = str_replace('/', DIRECTORY_SEPARATOR, $directory) . DIRECTORY_SEPARATOR . $relative_path;
|
||||
}
|
||||
else
|
||||
{
|
||||
$relative_path = DIRECTORY_SEPARATOR . $relative_path;
|
||||
}
|
||||
}
|
||||
|
||||
if ((!$suffix || substr($relative_path, -strlen($suffix)) === $suffix) &&
|
||||
|
@ -520,6 +534,7 @@ class finder
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($cache && $this->cache)
|
||||
{
|
||||
|
|
|
@ -132,6 +132,22 @@ class phpbb_extension_finder_test extends phpbb_test_case
|
|||
);
|
||||
}
|
||||
|
||||
public function test_non_absolute_directory_get_classes()
|
||||
{
|
||||
$classes = $this->finder
|
||||
->directory('type/')
|
||||
->get_classes();
|
||||
|
||||
sort($classes);
|
||||
$this->assertEquals(
|
||||
array(
|
||||
'\vendor2\foo\sub\type\alternative',
|
||||
'\vendor2\foo\type\alternative',
|
||||
),
|
||||
$classes
|
||||
);
|
||||
}
|
||||
|
||||
public function test_sub_directory_get_classes()
|
||||
{
|
||||
$classes = $this->finder
|
||||
|
|
Loading…
Add table
Reference in a new issue