mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-05 08:17:47 +02:00
[ticket/15253] Move storage helper to filesystem
PHPBB3-15253
This commit is contained in:
@@ -25,7 +25,7 @@ class extension extends extension_base
|
||||
{
|
||||
protected function load_services(ContainerBuilder $container)
|
||||
{
|
||||
$loader = new YamlFileLoader($container, new FileLocator(\phpbb\storage\helper::realpath($this->ext_path)));
|
||||
$loader = new YamlFileLoader($container, new FileLocator(\phpbb\filesystem\helper::realpath($this->ext_path)));
|
||||
$loader->load('environment.yml');
|
||||
}
|
||||
}
|
||||
|
@@ -43,7 +43,7 @@ class phpbb_path_helper_test extends phpbb_test_case
|
||||
*/
|
||||
public function set_phpbb_root_path()
|
||||
{
|
||||
$this->phpbb_root_path = \phpbb\storage\helper::clean_path(dirname(__FILE__) . '/../../phpBB/');
|
||||
$this->phpbb_root_path = \phpbb\filesystem\helper::clean_path(dirname(__FILE__) . '/../../phpBB/');
|
||||
}
|
||||
|
||||
public function test_get_web_root_path()
|
||||
@@ -72,7 +72,7 @@ class phpbb_path_helper_test extends phpbb_test_case
|
||||
),
|
||||
array(
|
||||
$this->phpbb_root_path . $this->phpbb_root_path . 'test.php',
|
||||
\phpbb\storage\helper::clean_path($this->phpbb_root_path . $this->phpbb_root_path . 'test.php'),
|
||||
\phpbb\filesystem\helper::clean_path($this->phpbb_root_path . $this->phpbb_root_path . 'test.php'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_storage_helper_clean_path_test extends phpbb_test_case
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function clean_path_data()
|
||||
{
|
||||
return array(
|
||||
array('foo', 'foo'),
|
||||
array('foo/bar', 'foo/bar'),
|
||||
array('foo/bar/', 'foo/bar/'),
|
||||
array('foo/./bar', 'foo/bar'),
|
||||
array('foo/./././bar', 'foo/bar'),
|
||||
array('foo/bar/.', 'foo/bar'),
|
||||
array('./foo/bar', './foo/bar'),
|
||||
array('../foo/bar', '../foo/bar'),
|
||||
array('./../foo/bar', './../foo/bar'),
|
||||
array('././../foo/bar', './../foo/bar'),
|
||||
array('one/two/three', 'one/two/three'),
|
||||
array('one/two/../three', 'one/three'),
|
||||
array('one/../two/three', 'two/three'),
|
||||
array('one/two/..', 'one'),
|
||||
array('one/two/../', 'one/'),
|
||||
array('one/two/../three/../four', 'one/four'),
|
||||
array('one/two/three/../../four', 'one/four'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider clean_path_data
|
||||
*/
|
||||
public function test_clean_path($input, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, \phpbb\storage\helper::clean_path($input));
|
||||
}
|
||||
}
|
@@ -1,64 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_storage_helper_is_absolute_test extends phpbb_test_case
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
static public function is_absolute_data()
|
||||
{
|
||||
return array(
|
||||
// Empty
|
||||
array('', false),
|
||||
|
||||
// Absolute unix style
|
||||
array('/etc/phpbb', true),
|
||||
// Unix does not support \ so that is not an absolute path
|
||||
array('\etc\phpbb', false),
|
||||
|
||||
// Absolute windows style
|
||||
array('c:\windows', true),
|
||||
array('C:\Windows', true),
|
||||
array('c:/windows', true),
|
||||
array('C:/Windows', true),
|
||||
|
||||
// Executable
|
||||
array('etc/phpbb', false),
|
||||
array('explorer.exe', false),
|
||||
|
||||
// Relative subdir
|
||||
array('Windows\System32', false),
|
||||
array('Windows\System32\explorer.exe', false),
|
||||
array('Windows/System32', false),
|
||||
array('Windows/System32/explorer.exe', false),
|
||||
|
||||
// Relative updir
|
||||
array('..\Windows\System32', false),
|
||||
array('..\Windows\System32\explorer.exe', false),
|
||||
array('../Windows/System32', false),
|
||||
array('../Windows/System32/explorer.exe', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider is_absolute_data
|
||||
*/
|
||||
public function test_is_absolute($path, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, \phpbb\storage\helper::is_absolute_path($path));
|
||||
}
|
||||
}
|
@@ -1,83 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_storage_helper_realpath_test extends phpbb_test_case
|
||||
{
|
||||
protected static $storage_helper_phpbb_own_realpath;
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$storage_helper_phpbb_own_realpath = new ReflectionMethod('\phpbb\storage\helper', 'phpbb_own_realpath');
|
||||
self::$storage_helper_phpbb_own_realpath->setAccessible(true);
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function realpath_resolve_absolute_without_symlinks_data()
|
||||
{
|
||||
return array(
|
||||
// Constant data
|
||||
array(__DIR__, __DIR__),
|
||||
array(__DIR__ . '/../storage/../storage', __DIR__),
|
||||
array(__DIR__ . '/././', __DIR__),
|
||||
array(__DIR__ . '/non_existent', false),
|
||||
|
||||
array(__FILE__, __FILE__),
|
||||
array(__FILE__ . '../', false),
|
||||
);
|
||||
}
|
||||
|
||||
public function realpath_resolve_relative_without_symlinks_data()
|
||||
{
|
||||
if (!function_exists('getcwd'))
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$relative_path = \phpbb\storage\helper::make_path_relative(__DIR__, getcwd());
|
||||
|
||||
return array(
|
||||
array($relative_path, __DIR__),
|
||||
array($relative_path . '../storage/../storage', __DIR__),
|
||||
array($relative_path . '././', __DIR__),
|
||||
|
||||
array($relative_path . 'helper_realpath_test.php', __FILE__),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider realpath_resolve_absolute_without_symlinks_data
|
||||
*/
|
||||
public function test_realpath_absolute_without_links($path, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, self::$storage_helper_phpbb_own_realpath->invoke(null, $path));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider realpath_resolve_relative_without_symlinks_data
|
||||
*/
|
||||
public function test_realpath_relative_without_links($path, $expected)
|
||||
{
|
||||
if (!function_exists('getcwd'))
|
||||
{
|
||||
$this->markTestSkipped('phpbb_own_realpath() cannot be tested with relative paths: getcwd is not available.');
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, self::$storage_helper_phpbb_own_realpath->invoke(null, $path));
|
||||
}
|
||||
}
|
@@ -40,7 +40,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
|
||||
global $phpbb_root_path;
|
||||
|
||||
$path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc';
|
||||
$this->assertTrue(\phpbb\storage\helper::is_absolute_path($path_to_php));
|
||||
$this->assertTrue(\phpbb\filesystem\helper::is_absolute_path($path_to_php));
|
||||
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
|
||||
|
||||
$cache_dir = $phpbb_root_path . 'cache/';
|
||||
|
Reference in New Issue
Block a user