[ticket/15253] Update imports

PHPBB3-15253
This commit is contained in:
Rubén Calvo 2017-06-27 11:47:25 +02:00
parent 8bbec30748
commit b1755d9dac
20 changed files with 75 additions and 44 deletions

View file

@ -29,6 +29,7 @@ use phpbb\exception\runtime_exception;
use phpbb\filesystem\filesystem; use phpbb\filesystem\filesystem;
use phpbb\request\request; use phpbb\request\request;
use Seld\JsonLint\ParsingException; use Seld\JsonLint\ParsingException;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Class to install packages through composer while freezing core dependencies. * Class to install packages through composer while freezing core dependencies.
@ -108,7 +109,7 @@ class installer
$this->root_path = $root_path; $this->root_path = $root_path;
$this->request = $request; $this->request = $request;
putenv('COMPOSER_HOME=' . \phpbb\filesystem\helper::realpath($root_path) . '/store/composer'); putenv('COMPOSER_HOME=' . filesystem_helper::realpath($root_path) . '/store/composer');
} }
/** /**

View file

@ -24,6 +24,7 @@ use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass;
use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass; use Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass;
use phpbb\filesystem\helper as filesystem_helper;
class container_builder class container_builder
{ {
@ -179,7 +180,7 @@ class container_builder
$this->register_ext_compiler_pass(); $this->register_ext_compiler_pass();
} }
$loader = new YamlFileLoader($this->container, new FileLocator(\phpbb\filesystem\helper::realpath($this->get_config_path()))); $loader = new YamlFileLoader($this->container, new FileLocator(filesystem_helper::realpath($this->get_config_path())));
$loader->load($this->container->getParameter('core.environment') . '/config.yml'); $loader->load($this->container->getParameter('core.environment') . '/config.yml');
$this->inject_custom_parameters(); $this->inject_custom_parameters();

View file

@ -19,6 +19,7 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Container core extension * Container core extension
@ -53,7 +54,7 @@ class core extends Extension
*/ */
public function load(array $configs, ContainerBuilder $container) public function load(array $configs, ContainerBuilder $container)
{ {
$loader = new YamlFileLoader($container, new FileLocator(\phpbb\filesystem\helper::realpath($this->config_path))); $loader = new YamlFileLoader($container, new FileLocator(filesystem_helper::realpath($this->config_path)));
$loader->load($container->getParameter('core.environment') . '/container/environment.yml'); $loader->load($container->getParameter('core.environment') . '/container/environment.yml');
$config = $this->getConfiguration($configs, $container); $config = $this->getConfiguration($configs, $container);

View file

@ -18,6 +18,7 @@ use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension; use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Container core extension * Container core extension
@ -94,7 +95,7 @@ class extension_base extends Extension
if ($services_directory && $services_file) if ($services_directory && $services_file)
{ {
$loader = new YamlFileLoader($container, new FileLocator(\phpbb\filesystem\helper::realpath($services_directory))); $loader = new YamlFileLoader($container, new FileLocator(filesystem_helper::realpath($services_directory)));
$loader->load($services_file); $loader->load($services_file);
} }
} }

View file

@ -13,6 +13,7 @@
namespace phpbb\filesystem; namespace phpbb\filesystem;
use Symfony\Component\Filesystem\Exception\IOException;
use phpbb\filesystem\exception\filesystem_exception; use phpbb\filesystem\exception\filesystem_exception;
/** /**
@ -60,7 +61,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->chgrp($files, $group, $recursive); $this->symfony_filesystem->chgrp($files, $group, $recursive);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
// Try to recover filename // Try to recover filename
// By the time this is written that is at the end of the message // By the time this is written that is at the end of the message
@ -146,7 +147,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->chown($files, $user, $recursive); $this->symfony_filesystem->chown($files, $user, $recursive);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
// Try to recover filename // Try to recover filename
// By the time this is written that is at the end of the message // By the time this is written that is at the end of the message
@ -162,7 +163,7 @@ class filesystem implements filesystem_interface
*/ */
public function clean_path($path) public function clean_path($path)
{ {
return \phpbb\filesystem\helper::clean_path($path); return helper::clean_path($path);
} }
/** /**
@ -174,7 +175,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->copy($origin_file, $target_file, $override); $this->symfony_filesystem->copy($origin_file, $target_file, $override);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
throw new filesystem_exception('CANNOT_COPY_FILES', '', array(), $e); throw new filesystem_exception('CANNOT_COPY_FILES', '', array(), $e);
} }
@ -189,7 +190,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->dumpFile($filename, $content); $this->symfony_filesystem->dumpFile($filename, $content);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
throw new filesystem_exception('CANNOT_DUMP_FILE', $filename, array(), $e); throw new filesystem_exception('CANNOT_DUMP_FILE', $filename, array(), $e);
} }
@ -208,7 +209,7 @@ class filesystem implements filesystem_interface
*/ */
public function is_absolute_path($path) public function is_absolute_path($path)
{ {
return \phpbb\filesystem\helper::is_absolute_path($path); return helper::is_absolute_path($path);
} }
/** /**
@ -286,7 +287,7 @@ class filesystem implements filesystem_interface
*/ */
public function make_path_relative($end_path, $start_path) public function make_path_relative($end_path, $start_path)
{ {
return \phpbb\filesystem\helper::make_path_relative($end_path, $start_path); return helper::make_path_relative($end_path, $start_path);
} }
/** /**
@ -298,7 +299,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->mirror($origin_dir, $target_dir, $iterator, $options); $this->symfony_filesystem->mirror($origin_dir, $target_dir, $iterator, $options);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
$msg = $e->getMessage(); $msg = $e->getMessage();
$filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"'));
@ -316,7 +317,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->mkdir($dirs, $mode); $this->symfony_filesystem->mkdir($dirs, $mode);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
$msg = $e->getMessage(); $msg = $e->getMessage();
$filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"'));
@ -499,7 +500,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->remove($files); $this->symfony_filesystem->remove($files);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
// Try to recover filename // Try to recover filename
// By the time this is written that is at the end of the message // By the time this is written that is at the end of the message
@ -519,7 +520,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->rename($origin, $target, $overwrite); $this->symfony_filesystem->rename($origin, $target, $overwrite);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
$msg = $e->getMessage(); $msg = $e->getMessage();
$filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"')); $filename = substr($msg, strpos($msg, '"'), strrpos($msg, '"'));
@ -537,7 +538,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->symlink($origin_dir, $target_dir, $copy_on_windows); $this->symfony_filesystem->symlink($origin_dir, $target_dir, $copy_on_windows);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
throw new filesystem_exception('CANNOT_CREATE_SYMLINK', $origin_dir, array(), $e); throw new filesystem_exception('CANNOT_CREATE_SYMLINK', $origin_dir, array(), $e);
} }
@ -552,7 +553,7 @@ class filesystem implements filesystem_interface
{ {
$this->symfony_filesystem->touch($files, $time, $access_time); $this->symfony_filesystem->touch($files, $time, $access_time);
} }
catch (\Symfony\Component\Filesystem\Exception\IOException $e) catch (IOException $e)
{ {
// Try to recover filename // Try to recover filename
// By the time this is written that is at the end of the message // By the time this is written that is at the end of the message
@ -759,6 +760,6 @@ class filesystem implements filesystem_interface
*/ */
protected function resolve_path($path, $prefix = '', $absolute = false, $return_array = false) protected function resolve_path($path, $prefix = '', $absolute = false, $return_array = false)
{ {
return \phpbb\filesystem\helper::resolve_path($path, $prefix, $absolute, $return_array); return helper::resolve_path($path, $prefix, $absolute, $return_array);
} }
} }

View file

@ -13,6 +13,8 @@
namespace phpbb; namespace phpbb;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* The finder provides a simple way to locate files in the core and a set of extensions * The finder provides a simple way to locate files in the core and a set of extensions
*/ */
@ -241,7 +243,7 @@ class finder
*/ */
protected function sanitise_directory($directory) protected function sanitise_directory($directory)
{ {
$directory = \phpbb\filesystem\helper::clean_path($directory); $directory = filesystem_helper::clean_path($directory);
$dir_len = strlen($directory); $dir_len = strlen($directory);
if ($dir_len > 1 && $directory[$dir_len - 1] === '/') if ($dir_len > 1 && $directory[$dir_len - 1] === '/')

View file

@ -14,6 +14,7 @@
namespace phpbb\install\helper; namespace phpbb\install\helper;
use phpbb\install\exception\invalid_dbms_exception; use phpbb\install\exception\invalid_dbms_exception;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Database related general functionality for installer * Database related general functionality for installer
@ -329,7 +330,7 @@ class database
// Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea
if ($dbms_info['SCHEMA'] === 'sqlite' if ($dbms_info['SCHEMA'] === 'sqlite'
&& stripos(\phpbb\filesystem\helper::realpath($dbhost), \phpbb\filesystem\helper::realpath($this->phpbb_root_path) === 0)) && stripos(filesystem_helper::realpath($dbhost), filesystem_helper::realpath($this->phpbb_root_path) === 0))
{ {
$errors[] = array( $errors[] = array(
'title' =>'INST_ERR_DB_FORUM_PATH', 'title' =>'INST_ERR_DB_FORUM_PATH',

View file

@ -13,6 +13,8 @@
namespace phpbb; namespace phpbb;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* A class with various functions that are related to paths, files and the filesystem * A class with various functions that are related to paths, files and the filesystem
*/ */
@ -112,7 +114,7 @@ class path_helper
$path = substr($path, 8); $path = substr($path, 8);
} }
return \phpbb\filesystem\helper::clean_path($web_root_path . $path); return filesystem_helper::clean_path($web_root_path . $path);
} }
return $path; return $path;
@ -158,7 +160,7 @@ class path_helper
// We do not need to escape $path_info, $request_uri and $script_name because we can not find their content in the result. // We do not need to escape $path_info, $request_uri and $script_name because we can not find their content in the result.
// Path info (e.g. /foo/bar) // Path info (e.g. /foo/bar)
$path_info = \phpbb\filesystem\helper::clean_path($this->symfony_request->getPathInfo()); $path_info = filesystem_helper::clean_path($this->symfony_request->getPathInfo());
// Full request URI (e.g. phpBB/app.php/foo/bar) // Full request URI (e.g. phpBB/app.php/foo/bar)
$request_uri = $this->symfony_request->getRequestUri(); $request_uri = $this->symfony_request->getRequestUri();
@ -173,7 +175,7 @@ class path_helper
*/ */
if ($path_info === '/' && preg_match('/app\.' . $this->php_ext . '\/$/', $request_uri)) if ($path_info === '/' && preg_match('/app\.' . $this->php_ext . '\/$/', $request_uri))
{ {
return $this->web_root_path = \phpbb\filesystem\helper::clean_path('./../' . $this->phpbb_root_path); return $this->web_root_path = filesystem_helper::clean_path('./../' . $this->phpbb_root_path);
} }
/* /*
@ -230,7 +232,7 @@ class path_helper
} }
// Prepend ../ to the phpbb_root_path as many times as / exists in path_info // Prepend ../ to the phpbb_root_path as many times as / exists in path_info
$this->web_root_path = \phpbb\filesystem\helper::clean_path( $this->web_root_path = filesystem_helper::clean_path(
'./' . str_repeat('../', $corrections) . $this->phpbb_root_path './' . str_repeat('../', $corrections) . $this->phpbb_root_path
); );
return $this->web_root_path; return $this->web_root_path;
@ -321,7 +323,7 @@ class path_helper
// Add length of URL delimiter to position // Add length of URL delimiter to position
$path = substr($url, $delimiter_position + 3); $path = substr($url, $delimiter_position + 3);
return $scheme . \phpbb\filesystem\helper::clean_path($path); return $scheme . filesystem_helper::clean_path($path);
} }
/** /**

View file

@ -14,6 +14,7 @@
namespace phpbb\routing; namespace phpbb\routing;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
use phpbb\filesystem\helper as filesystem_helper;
class file_locator extends FileLocator class file_locator extends FileLocator
{ {
@ -24,7 +25,7 @@ class file_locator extends FileLocator
foreach ($paths as $path) foreach ($paths as $path)
{ {
$absolute_paths[] = \phpbb\filesystem\helper::realpath($path); $absolute_paths[] = filesystem_helper::realpath($path);
} }
parent::__construct($absolute_paths); parent::__construct($absolute_paths);

View file

@ -15,6 +15,7 @@ namespace phpbb\routing;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Controller helper class, contains methods that do things for controllers * Controller helper class, contains methods that do things for controllers
@ -133,7 +134,7 @@ class helper
} }
} }
$base_url = $this->request->escape(\phpbb\filesystem\helper::clean_path($base_url), true); $base_url = $this->request->escape(filesystem_helper::clean_path($base_url), true);
$context->setBaseUrl($base_url); $context->setBaseUrl($base_url);

View file

@ -13,6 +13,8 @@
namespace phpbb; namespace phpbb;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Session class * Session class
*/ */
@ -85,15 +87,15 @@ class session
$page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name); $page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name);
$page_name = urlencode(htmlspecialchars($page_name)); $page_name = urlencode(htmlspecialchars($page_name));
$symfony_request_path = \phpbb\filesystem\helper::clean_path($symfony_request->getPathInfo()); $symfony_request_path = filesystem_helper::clean_path($symfony_request->getPathInfo());
if ($symfony_request_path !== '/') if ($symfony_request_path !== '/')
{ {
$page_name .= str_replace('%2F', '/', urlencode($symfony_request_path)); $page_name .= str_replace('%2F', '/', urlencode($symfony_request_path));
} }
// current directory within the phpBB root (for example: adm) // current directory within the phpBB root (for example: adm)
$root_dirs = explode('/', str_replace('\\', '/', \phpbb\filesystem\helper::realpath($root_path))); $root_dirs = explode('/', str_replace('\\', '/', filesystem_helper::realpath($root_path)));
$page_dirs = explode('/', str_replace('\\', '/', \phpbb\filesystem\helper::realpath('./'))); $page_dirs = explode('/', str_replace('\\', '/', filesystem_helper::realpath('./')));
$intersection = array_intersect_assoc($root_dirs, $page_dirs); $intersection = array_intersect_assoc($root_dirs, $page_dirs);
$root_dirs = array_diff_assoc($root_dirs, $intersection); $root_dirs = array_diff_assoc($root_dirs, $intersection);

View file

@ -13,6 +13,8 @@
namespace phpbb\template; namespace phpbb\template;
use phpbb\filesystem\helper as filesystem_helper;
class asset class asset
{ {
protected $components = array(); protected $components = array();
@ -153,7 +155,7 @@ class asset
public function set_path($path, $urlencode = false) public function set_path($path, $urlencode = false)
{ {
// Since 1.7.0 Twig returns the real path of the file. We need it to be relative. // Since 1.7.0 Twig returns the real path of the file. We need it to be relative.
$real_root_path = \phpbb\filesystem\helper::realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR; $real_root_path = filesystem_helper::realpath($this->path_helper->get_phpbb_root_path()) . DIRECTORY_SEPARATOR;
// If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path // If the asset is under the phpBB root path we need to remove its path and then prepend $phpbb_root_path
if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path)
@ -163,7 +165,7 @@ class asset
else else
{ {
// Else we make the path relative to the current working directory // Else we make the path relative to the current working directory
$real_root_path = \phpbb\filesystem\helper::realpath('.') . DIRECTORY_SEPARATOR; $real_root_path = filesystem_helper::realpath('.') . DIRECTORY_SEPARATOR;
if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path) if ($real_root_path && substr($path . DIRECTORY_SEPARATOR, 0, strlen($real_root_path)) === $real_root_path)
{ {
$path = str_replace('\\', '/', substr($path, strlen($real_root_path))); $path = str_replace('\\', '/', substr($path, strlen($real_root_path)));

View file

@ -13,6 +13,8 @@
namespace phpbb\template\twig; namespace phpbb\template\twig;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Twig Template loader * Twig Template loader
*/ */
@ -49,7 +51,7 @@ class loader extends \Twig_Loader_Filesystem
*/ */
public function addSafeDirectory($directory) public function addSafeDirectory($directory)
{ {
$directory = \phpbb\filesystem\helper::realpath($directory); $directory = filesystem_helper::realpath($directory);
if ($directory !== false) if ($directory !== false)
{ {
@ -89,7 +91,7 @@ class loader extends \Twig_Loader_Filesystem
*/ */
public function addPath($path, $namespace = self::MAIN_NAMESPACE) public function addPath($path, $namespace = self::MAIN_NAMESPACE)
{ {
return parent::addPath(\phpbb\filesystem\helper::realpath($path), $namespace); return parent::addPath(filesystem_helper::realpath($path), $namespace);
} }
/** /**
@ -129,7 +131,7 @@ class loader extends \Twig_Loader_Filesystem
// can now check if we're within a "safe" directory // can now check if we're within a "safe" directory
// Find the real path of the directory the file is in // Find the real path of the directory the file is in
$directory = \phpbb\filesystem\helper::realpath(dirname($file)); $directory = filesystem_helper::realpath(dirname($file));
if ($directory === false) if ($directory === false)
{ {

View file

@ -13,6 +13,8 @@
namespace phpbb; namespace phpbb;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Class to handle viewonline related tasks * Class to handle viewonline related tasks
*/ */
@ -33,7 +35,7 @@ class viewonline_helper
*/ */
public function get_user_page($session_page) public function get_user_page($session_page)
{ {
$session_page = \phpbb\filesystem\helper::clean_path($session_page); $session_page = filesystem_helper::clean_path($session_page);
if (strpos($session_page, './') === 0) if (strpos($session_page, './') === 0)
{ {
$session_page = substr($session_page, 2); $session_page = substr($session_page, 2);

View file

@ -17,6 +17,7 @@ use phpbb\extension\di\extension_base;
use Symfony\Component\Config\FileLocator; use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use phpbb\filesystem\helper as filesystem_helper;
/** /**
* Container core extension * Container core extension
@ -25,7 +26,7 @@ class extension extends extension_base
{ {
protected function load_services(ContainerBuilder $container) protected function load_services(ContainerBuilder $container)
{ {
$loader = new YamlFileLoader($container, new FileLocator(\phpbb\filesystem\helper::realpath($this->ext_path))); $loader = new YamlFileLoader($container, new FileLocator(filesystem_helper::realpath($this->ext_path)));
$loader->load('environment.yml'); $loader->load('environment.yml');
} }
} }

View file

@ -11,6 +11,8 @@
* *
*/ */
use phpbb\filesystem\helper as filesystem_helper;
class phpbb_filesystem_helper_clean_path_test extends phpbb_test_case class phpbb_filesystem_helper_clean_path_test extends phpbb_test_case
{ {
@ -47,6 +49,6 @@ class phpbb_filesystem_helper_clean_path_test extends phpbb_test_case
*/ */
public function test_clean_path($input, $expected) public function test_clean_path($input, $expected)
{ {
$this->assertEquals($expected, \phpbb\filesystem\helper::clean_path($input)); $this->assertEquals($expected, filesystem_helper::clean_path($input));
} }
} }

View file

@ -11,6 +11,8 @@
* *
*/ */
use phpbb\filesystem\helper as filesystem_helper;
class phpbb_filesystem_helper_is_absolute_test extends phpbb_test_case class phpbb_filesystem_helper_is_absolute_test extends phpbb_test_case
{ {
@ -59,6 +61,6 @@ class phpbb_filesystem_helper_is_absolute_test extends phpbb_test_case
*/ */
public function test_is_absolute($path, $expected) public function test_is_absolute($path, $expected)
{ {
$this->assertEquals($expected, \phpbb\filesystem\helper::is_absolute_path($path)); $this->assertEquals($expected, filesystem_helper::is_absolute_path($path));
} }
} }

View file

@ -11,6 +11,8 @@
* *
*/ */
use phpbb\filesystem\helper as filesystem_helper;
class phpbb_filesystem_helper_realpath_test extends phpbb_test_case class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
{ {
protected static $filesystem_helper_phpbb_own_realpath; protected static $filesystem_helper_phpbb_own_realpath;
@ -19,7 +21,7 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
{ {
parent::setUpBeforeClass(); parent::setUpBeforeClass();
self::$filesystem_helper_phpbb_own_realpath = new ReflectionMethod('\phpbb\filesystem\helper', 'phpbb_own_realpath'); self::$filesystem_helper_phpbb_own_realpath = new ReflectionMethod('filesystem_helper', 'phpbb_own_realpath');
self::$filesystem_helper_phpbb_own_realpath->setAccessible(true); self::$filesystem_helper_phpbb_own_realpath->setAccessible(true);
} }
@ -49,7 +51,7 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
return array(); return array();
} }
$relative_path = \phpbb\filesystem\helper::make_path_relative(__DIR__, getcwd()); $relative_path = filesystem_helper::make_path_relative(__DIR__, getcwd());
return array( return array(
array($relative_path, __DIR__), array($relative_path, __DIR__),

View file

@ -11,6 +11,8 @@
* *
*/ */
use phpbb\filesystem\helper as filesystem_helper;
class phpbb_path_helper_test extends phpbb_test_case class phpbb_path_helper_test extends phpbb_test_case
{ {
/** @var \phpbb\path_helper */ /** @var \phpbb\path_helper */
@ -43,7 +45,7 @@ class phpbb_path_helper_test extends phpbb_test_case
*/ */
public function set_phpbb_root_path() public function set_phpbb_root_path()
{ {
$this->phpbb_root_path = \phpbb\filesystem\helper::clean_path(dirname(__FILE__) . '/../../phpBB/'); $this->phpbb_root_path = filesystem_helper::clean_path(dirname(__FILE__) . '/../../phpBB/');
} }
public function test_get_web_root_path() public function test_get_web_root_path()
@ -72,7 +74,7 @@ class phpbb_path_helper_test extends phpbb_test_case
), ),
array( array(
$this->phpbb_root_path . $this->phpbb_root_path . 'test.php', $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'), filesystem_helper::clean_path($this->phpbb_root_path . $this->phpbb_root_path . 'test.php'),
), ),
); );
} }

View file

@ -11,6 +11,8 @@
* *
*/ */
use phpbb\filesystem\helper as filesystem_helper;
require_once dirname(__FILE__) . '/template_test_case.php'; require_once dirname(__FILE__) . '/template_test_case.php';
class phpbb_template_includephp_test extends phpbb_template_template_test_case class phpbb_template_includephp_test extends phpbb_template_template_test_case
@ -40,7 +42,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
global $phpbb_root_path; global $phpbb_root_path;
$path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc'; $path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc';
$this->assertTrue(\phpbb\filesystem\helper::is_absolute_path($path_to_php)); $this->assertTrue(filesystem_helper::is_absolute_path($path_to_php));
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->"; $template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
$cache_dir = $phpbb_root_path . 'cache/'; $cache_dir = $phpbb_root_path . 'cache/';