aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMateBartus <mate.bartus@gmail.com>2015-03-12 00:25:00 +0100
committerMateBartus <mate.bartus@gmail.com>2015-04-16 13:24:10 +0200
commit4bdef6fd21a5dcab455b0cd1ee2652de606929c3 (patch)
tree33eae92e90b43770b2c1e2e4508dbcf35d6bd7da /tests
parentf86c5d905bb82967505ef3e07fa429b59c112871 (diff)
downloadforums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.tar
forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.tar.gz
forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.tar.bz2
forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.tar.xz
forums-4bdef6fd21a5dcab455b0cd1ee2652de606929c3.zip
[ticket/13697] Moving filesystem related functions to filesystem service
* Moving filesystem service to \phpbb\filesystem namespace * Wraping Symfony's Filesystem component * Moving filesystem related functions from includes/functions.php into \phpbb\filesystem\filesystem Functions moved (and deprecated): - phpbb_chmod - phpbb_is_writable - phpbb_is_absolute - phpbb_own_realpath - phpbb_realpath * Adding interface for filesystem service PHPBB3-13697
Diffstat (limited to 'tests')
-rw-r--r--tests/avatar/manager_test.php6
-rw-r--r--tests/controller/common_helper_route.php6
-rw-r--r--tests/controller/controller_test.php2
-rw-r--r--tests/dbal/connect_test.php4
-rw-r--r--tests/dbal/migrator_test.php2
-rw-r--r--tests/di/fixtures/ext/vendor/enabled_4/di/extension.php3
-rw-r--r--tests/error_collector_test.php9
-rw-r--r--tests/extension/finder_test.php4
-rw-r--r--tests/extension/manager_test.php2
-rw-r--r--tests/extension/metadata_manager_test.php6
-rw-r--r--tests/filesystem/clean_path_test.php2
-rw-r--r--tests/filesystem/is_absolute_test.php (renamed from tests/functions/is_absolute_test.php)42
-rw-r--r--tests/filesystem/realpath_test.php90
-rw-r--r--tests/functional/fileupload_remote_test.php11
-rw-r--r--tests/functions/build_url_test.php2
-rw-r--r--tests/mock/controller_helper.php2
-rw-r--r--tests/mock/extension_manager.php2
-rw-r--r--tests/pagination/pagination_test.php4
-rw-r--r--tests/path_helper/path_helper_test.php10
-rw-r--r--tests/security/base.php2
-rw-r--r--tests/security/redirect_test.php2
-rw-r--r--tests/session/check_ban_test.php5
-rw-r--r--tests/session/extract_page_test.php2
-rw-r--r--tests/template/includephp_test.php3
-rw-r--r--tests/template/template_allfolder_test.php4
-rw-r--r--tests/template/template_events_test.php4
-rw-r--r--tests/template/template_includecss_test.php4
-rw-r--r--tests/template/template_test_case.php8
-rw-r--r--tests/template/template_test_case_with_tree.php4
-rw-r--r--tests/test_framework/phpbb_database_test_case.php2
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php2
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php2
-rw-r--r--tests/test_framework/phpbb_session_test_case.php2
-rw-r--r--tests/upload/filespec_test.php9
-rw-r--r--tests/upload/fileupload_test.php22
-rw-r--r--tests/viewonline/helper_test.php2
36 files changed, 209 insertions, 79 deletions
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index a109a7b5de..4befbfc1fc 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -35,6 +35,8 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
->method('get')
->will($this->returnArgument(0));
+ $filesystem = new \phpbb\filesystem\filesystem();
+
// Prepare dependencies for avatar manager and driver
$this->config = new \phpbb\config\config(array());
$cache = $this->getMock('\phpbb\cache\driver\driver_interface');
@@ -42,7 +44,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ $filesystem,
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -76,7 +78,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
}
else
{
- $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $guesser, $cache));
+ $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $filesystem, $path_helper, $guesser, $cache));
}
$cur_avatar->expects($this->any())
->method('get_name')
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index 3f98d51f16..91b0cda68d 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -69,7 +69,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$this->symfony_request = new \phpbb\symfony_request(
$this->request
);
- $this->filesystem = new \phpbb\filesystem();
+ $this->filesystem = new \phpbb\filesystem\filesystem();
$this->phpbb_path_helper = new \phpbb\path_helper(
$this->symfony_request,
$this->filesystem,
@@ -84,7 +84,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
- $loader = new \phpbb\template\twig\loader('');
+ $loader = new \phpbb\template\twig\loader($this->filesystem, '');
$twig = new \phpbb\template\twig\environment(
$this->config,
$this->phpbb_path_helper,
@@ -113,7 +113,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
)
);
- $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $this->router = new phpbb_mock_router($this->filesystem, $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
$this->router->find_routing_files($this->extension_manager->all_enabled(false));
$this->router->find(dirname(__FILE__) . '/');
// Set correct current phpBB root path
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 86615fe4dc..a837e25f66 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -40,7 +40,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
public function test_router_find_files()
{
- $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $router = new \phpbb\routing\router(new \phpbb\filesystem\filesystem(), $this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
$router->find_routing_files($this->extension_manager->all_enabled(false));
$routes = $router->find(__DIR__)->get_routes();
diff --git a/tests/dbal/connect_test.php b/tests/dbal/connect_test.php
index 1ae34bd2b6..edf57189cb 100644
--- a/tests/dbal/connect_test.php
+++ b/tests/dbal/connect_test.php
@@ -22,7 +22,9 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case
public function test_failing_connect()
{
- global $phpbb_root_path, $phpEx;
+ global $phpbb_root_path, $phpEx, $phpbb_filesystem;
+
+ $phpbb_filesystem = new phpbb\filesystem\filesystem();
$config = $this->get_database_config();
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index 6416a2fcf7..d550ca55a2 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -69,7 +69,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$container,
$this->db,
$this->config,
- new phpbb\filesystem(),
+ new phpbb\filesystem\filesystem(),
$user,
'phpbb_ext',
dirname(__FILE__) . '/../../phpBB/',
diff --git a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php
index 8342625687..8e5ed6c52c 100644
--- a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php
+++ b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php
@@ -25,7 +25,8 @@ class extension extends extension_base
{
protected function load_services(ContainerBuilder $container)
{
- $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->ext_path)));
+ $filesystem = new \phpbb\filesystem\filesystem();
+ $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->ext_path)));
$loader->load('environment.yml');
}
}
diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php
index b92c4fa6bb..ddbe2e3af1 100644
--- a/tests/error_collector_test.php
+++ b/tests/error_collector_test.php
@@ -15,6 +15,15 @@ require_once dirname(__FILE__) . '/../phpBB/includes/functions.php';
class phpbb_error_collector_test extends phpbb_test_case
{
+ public function setUp()
+ {
+ parent::setUp();
+
+ global $phpbb_filesystem;
+
+ $phpbb_filesystem = new \phpbb\filesystem\filesystem();
+ }
+
public function test_collection()
{
$collector = new \phpbb\error_collector(E_ALL | E_STRICT); // php set_error_handler() default
diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php
index 2116cc057b..463b69e9a9 100644
--- a/tests/extension/finder_test.php
+++ b/tests/extension/finder_test.php
@@ -244,7 +244,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
public function test_get_classes_create_cache()
{
$cache = new phpbb_mock_cache;
- $finder = new \phpbb\finder(new \phpbb\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name');
+ $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name');
$finder->set_extensions(array_keys($this->extension_manager->all_enabled()));
$files = $finder->suffix('_class.php')->get_files();
@@ -284,7 +284,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
);
$finder = new \phpbb\finder(
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
dirname(__FILE__) . '/',
new phpbb_mock_cache(array(
'_ext_finder' => array(
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 0126216701..b76203b32a 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -177,7 +177,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$container,
$db,
$config,
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$user,
'phpbb_ext',
dirname(__FILE__) . '/',
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 8514ed3dbd..db573ae0c3 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -51,12 +51,12 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$container = new phpbb_mock_container_builder();
$cache_path = $this->phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
- $loader = new \phpbb\template\twig\loader('');
+ $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$phpbb_path_helper =new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$this->phpbb_root_path,
$this->phpEx
@@ -98,7 +98,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$container,
$this->db,
$this->config,
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->user,
'phpbb_ext',
$this->phpbb_root_path,
diff --git a/tests/filesystem/clean_path_test.php b/tests/filesystem/clean_path_test.php
index c585b17155..d2dec424b4 100644
--- a/tests/filesystem/clean_path_test.php
+++ b/tests/filesystem/clean_path_test.php
@@ -18,7 +18,7 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case
public function setUp()
{
parent::setUp();
- $this->filesystem = new \phpbb\filesystem();
+ $this->filesystem = new \phpbb\filesystem\filesystem();
}
public function clean_path_data()
diff --git a/tests/functions/is_absolute_test.php b/tests/filesystem/is_absolute_test.php
index afa4b9b59f..7a50989b74 100644
--- a/tests/functions/is_absolute_test.php
+++ b/tests/filesystem/is_absolute_test.php
@@ -1,20 +1,28 @@
<?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.
-*
-*/
-
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-
-class phpbb_functions_is_absolute_test extends phpbb_test_case
+ *
+ * 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_filesystem_is_absolute_test extends phpbb_test_case
{
+ /** @var \phpbb\filesystem\filesystem_interface */
+ protected $filesystem;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->filesystem = new \phpbb\filesystem\filesystem();
+ }
+
static public function is_absolute_data()
{
return array(
@@ -51,10 +59,10 @@ class phpbb_functions_is_absolute_test extends phpbb_test_case
}
/**
- * @dataProvider is_absolute_data
- */
+ * @dataProvider is_absolute_data
+ */
public function test_is_absolute($path, $expected)
{
- $this->assertEquals($expected, phpbb_is_absolute($path));
+ $this->assertEquals($expected, $this->filesystem->is_absolute_path($path));
}
}
diff --git a/tests/filesystem/realpath_test.php b/tests/filesystem/realpath_test.php
new file mode 100644
index 0000000000..d994935f94
--- /dev/null
+++ b/tests/filesystem/realpath_test.php
@@ -0,0 +1,90 @@
+<?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_filesystem_realpath_test extends phpbb_test_case
+{
+ static protected $filesystem_own_realpath;
+
+ /** @var \phpbb\filesystem\filesystem_interface */
+ protected $filesystem;
+
+ static public function setUpBeforeClass()
+ {
+ parent::setUpBeforeClass();
+
+ $reflection_class = new ReflectionClass('\phpbb\filesystem\filesystem');
+ self::$filesystem_own_realpath = $reflection_class->getMethod('phpbb_own_realpath');
+ self::$filesystem_own_realpath->setAccessible(true);
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->filesystem = new \phpbb\filesystem\filesystem();
+ }
+
+ public function realpath_resolve_absolute_without_symlinks_data()
+ {
+ return array(
+ // Constant data
+ array(__DIR__, __DIR__),
+ array(__DIR__ . '/../filesystem/../filesystem', __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();
+ }
+
+ $filesystem = new \phpbb\filesystem\filesystem();
+ $relative_path = $filesystem->make_path_relative(__DIR__, getcwd());
+
+ return array(
+ array($relative_path, __DIR__),
+ array($relative_path . '../filesystem/../filesystem', __DIR__),
+ array($relative_path . '././', __DIR__),
+
+ array($relative_path . 'realpath_test.php', __FILE__),
+ );
+ }
+
+ /**
+ * @dataProvider realpath_resolve_absolute_without_symlinks_data
+ */
+ public function test_realpath_absolute_without_links($path, $expected)
+ {
+ $this->assertEquals($expected, self::$filesystem_own_realpath->invoke($this->filesystem, $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::$filesystem_own_realpath->invoke($this->filesystem, $path));
+ }
+}
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php
index 6ece150b23..4aa1a83b30 100644
--- a/tests/functional/fileupload_remote_test.php
+++ b/tests/functional/fileupload_remote_test.php
@@ -18,6 +18,8 @@ require_once __DIR__ . '/../../phpBB/includes/functions_upload.php';
*/
class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
{
+ protected $filesystem;
+
public function setUp()
{
parent::setUp();
@@ -38,6 +40,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
$user = new phpbb_mock_user();
$user->lang = new phpbb_mock_lang();
+ $this->filesystem = new \phpbb\filesystem\filesystem();
}
public function tearDown()
@@ -49,21 +52,21 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
public function test_invalid_extension()
{
- $upload = new fileupload('', array('jpg'), 100);
+ $upload = new fileupload($this->filesystem, '', array('jpg'), 100);
$file = $upload->remote_upload(self::$root_url . 'develop/blank.gif');
$this->assertEquals('URL_INVALID', $file->error[0]);
}
public function test_empty_file()
{
- $upload = new fileupload('', array('jpg'), 100);
+ $upload = new fileupload($this->filesystem, '', array('jpg'), 100);
$file = $upload->remote_upload(self::$root_url . 'develop/blank.jpg');
$this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]);
}
public function test_successful_upload()
{
- $upload = new fileupload('', array('gif'), 1000);
+ $upload = new fileupload($this->filesystem, '', array('gif'), 1000);
$file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif');
$this->assertEquals(0, sizeof($file->error));
$this->assertTrue(file_exists($file->filename));
@@ -71,7 +74,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
public function test_too_large()
{
- $upload = new fileupload('', array('gif'), 100);
+ $upload = new fileupload($this->filesystem, '', array('gif'), 100);
$file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif');
$this->assertEquals(1, sizeof($file->error));
$this->assertEquals('WRONG_FILESIZE', $file->error[0]);
diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php
index a59b94c744..3e19b51f02 100644
--- a/tests/functions/build_url_test.php
+++ b/tests/functions/build_url_test.php
@@ -29,7 +29,7 @@ class phpbb_build_url_test extends phpbb_test_case
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
'php'
diff --git a/tests/mock/controller_helper.php b/tests/mock/controller_helper.php
index 7e4a808906..1d9f5dc5bf 100644
--- a/tests/mock/controller_helper.php
+++ b/tests/mock/controller_helper.php
@@ -13,7 +13,7 @@
class phpbb_mock_controller_helper extends \phpbb\controller\helper
{
- public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
+ public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem\filesystem_interface $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
{
$this->template = $template;
$this->user = $user;
diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php
index 3b759fbbc2..2ce61c5149 100644
--- a/tests/mock/extension_manager.php
+++ b/tests/mock/extension_manager.php
@@ -18,7 +18,7 @@ class phpbb_mock_extension_manager extends \phpbb\extension\manager
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = 'php';
$this->extensions = $extensions;
- $this->filesystem = new \phpbb\filesystem();
+ $this->filesystem = new \phpbb\filesystem\filesystem();
$this->container = $container;
}
}
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 6679d48c01..c705e67135 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -34,11 +34,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
- $filesystem = new \phpbb\filesystem();
+ $filesystem = new \phpbb\filesystem\filesystem();
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $router = new phpbb_mock_router($filesystem, $manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
$router->find_routing_files($manager->all_enabled(false));
$router->find(dirname(__FILE__) . '/');
diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php
index 73f0e6bafc..007441bc92 100644
--- a/tests/path_helper/path_helper_test.php
+++ b/tests/path_helper/path_helper_test.php
@@ -21,14 +21,14 @@ class phpbb_path_helper_test extends phpbb_test_case
{
parent::setUp();
- $filesystem = new \phpbb\filesystem();
+ $filesystem = new \phpbb\filesystem\filesystem();
$this->set_phpbb_root_path($filesystem);
$this->path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$this->phpbb_root_path,
'php'
@@ -56,7 +56,7 @@ class phpbb_path_helper_test extends phpbb_test_case
public function basic_update_web_root_path_data()
{
- $filesystem = new \phpbb\filesystem();
+ $filesystem = new \phpbb\filesystem\filesystem();
$this->set_phpbb_root_path($filesystem);
return array(
@@ -90,7 +90,7 @@ class phpbb_path_helper_test extends phpbb_test_case
public function update_web_root_path_data()
{
- $this->set_phpbb_root_path(new \phpbb\filesystem());
+ $this->set_phpbb_root_path(new \phpbb\filesystem\filesystem());
return array(
array(
@@ -158,7 +158,7 @@ class phpbb_path_helper_test extends phpbb_test_case
$path_helper = new \phpbb\path_helper(
$symfony_request,
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$this->phpbb_root_path,
'php'
diff --git a/tests/security/base.php b/tests/security/base.php
index 330408b448..5888a2bf2a 100644
--- a/tests/security/base.php
+++ b/tests/security/base.php
@@ -46,7 +46,7 @@ abstract class phpbb_security_test_base extends phpbb_test_case
$request = new phpbb_mock_request(array(), array(), array(), $this->server);
$symfony_request = new \phpbb\symfony_request($request);
- $phpbb_filesystem = new \phpbb\filesystem();
+ $phpbb_filesystem = new \phpbb\filesystem\filesystem();
// Set no user and trick a bit to circumvent errors
$user = new \phpbb\user('\phpbb\datetime');
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index 21fb103ed1..3c67a1e98a 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -62,7 +62,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$this->phpbb_root_path,
'php'
diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php
index 561b7faf49..04da5f08b9 100644
--- a/tests/session/check_ban_test.php
+++ b/tests/session/check_ban_test.php
@@ -42,7 +42,10 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
parent::setUp();
// Get session here so that config is mocked correctly
$this->session = $this->session_factory->get_session($this->db);
- global $cache, $config, $phpbb_root_path, $phpEx;
+ global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem;
+
+ $phpbb_filesystem = new \phpbb\filesystem\filesystem();
+
$this->backup_cache = $cache;
// Change the global cache object for this test because
// the mock cache object does not hit the database as is needed
diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php
index f0d1cdb60e..96445ef9b3 100644
--- a/tests/session/extract_page_test.php
+++ b/tests/session/extract_page_test.php
@@ -145,7 +145,7 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
{
global $symfony_request, $request, $phpbb_filesystem;
- $phpbb_filesystem = new \phpbb\filesystem();
+ $phpbb_filesystem = new \phpbb\filesystem\filesystem();
$server['HTTP_HOST'] = 'localhost';
$server['SERVER_NAME'] = 'localhost';
diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php
index fdddbef4f2..722e10e42d 100644
--- a/tests/template/includephp_test.php
+++ b/tests/template/includephp_test.php
@@ -39,8 +39,9 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
{
global $phpbb_root_path;
+ $filesystem = new \phpbb\filesystem\filesystem();
$path_to_php = str_replace('\\', '/', dirname(__FILE__)) . '/templates/_dummy_include.php.inc';
- $this->assertTrue(phpbb_is_absolute($path_to_php));
+ $this->assertTrue($filesystem->is_absolute_path($path_to_php));
$template_text = "Path is absolute.\n<!-- INCLUDEPHP $path_to_php -->";
$cache_dir = $phpbb_root_path . 'cache/';
diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php
index e87688a57c..f739a78d84 100644
--- a/tests/template/template_allfolder_test.php
+++ b/tests/template/template_allfolder_test.php
@@ -34,7 +34,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -54,7 +54,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
$container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
- $loader = new \phpbb\template\twig\loader('');
+ $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
$path_helper,
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index e8ffea8d11..6d1b7253e3 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -142,7 +142,7 @@ Zeta test event in all',
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -151,7 +151,7 @@ Zeta test event in all',
$container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
- $loader = new \phpbb\template\twig\loader('');
+ $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
$path_helper,
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index 96980e17c6..7a73d1f888 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -32,7 +32,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -43,7 +43,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
- $loader = new \phpbb\template\twig\loader('');
+ $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
$this->phpbb_path_helper,
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index f9ea8cfaba..29ff669efc 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -71,7 +71,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -82,7 +82,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
- $loader = new \phpbb\template\twig\loader('');
+ $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
$path_helper,
@@ -108,6 +108,10 @@ class phpbb_template_template_test_case extends phpbb_test_case
$this->setup_engine();
$this->template->clear_cache();
+
+ global $phpbb_filesystem;
+
+ $phpbb_filesystem = new \phpbb\filesystem\filesystem();
}
protected function tearDown()
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index c634e2051a..eab83f379a 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -26,7 +26,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
new \phpbb\symfony_request(
new phpbb_mock_request()
),
- new \phpbb\filesystem(),
+ new \phpbb\filesystem\filesystem(),
$this->getMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
@@ -38,7 +38,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$container = new phpbb_mock_container_builder();
$cache_path = $phpbb_root_path . 'cache/twig';
$context = new \phpbb\template\context();
- $loader = new \phpbb\template\twig\loader('');
+ $loader = new \phpbb\template\twig\loader(new \phpbb\filesystem\filesystem(), '');
$twig = new \phpbb\template\twig\environment(
$config,
$this->phpbb_path_helper,
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 903158d3c6..4d0460ebeb 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -58,7 +58,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$setup_extensions = static::setup_extensions();
- $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx);
+ $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx);
$finder->core_path('phpbb/db/migration/data/');
if (!empty($setup_extensions))
{
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index 4f38ccc0d8..5136af5ad1 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -365,7 +365,7 @@ class phpbb_database_test_connection_manager
{
global $phpbb_root_path, $phpEx, $table_prefix;
- $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx);
+ $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx);
$classes = $finder->core_path('phpbb/db/migration/data/')
->get_classes();
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 495413593b..daa570caf6 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -254,7 +254,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$container,
$db,
$config,
- new phpbb\filesystem(),
+ new phpbb\filesystem\filesystem(),
$user,
self::$config['table_prefix'] . 'ext',
dirname(__FILE__) . '/',
diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php
index 1bf0277fe0..1c1930e88d 100644
--- a/tests/test_framework/phpbb_session_test_case.php
+++ b/tests/test_framework/phpbb_session_test_case.php
@@ -34,7 +34,7 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case
$symfony_request = new \phpbb\symfony_request(
new phpbb_mock_request()
);
- $phpbb_filesystem = new \phpbb\filesystem();
+ $phpbb_filesystem = new \phpbb\filesystem\filesystem();
$phpbb_path_helper = new \phpbb\path_helper(
$symfony_request,
$phpbb_filesystem,
diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php
index 05547dcd00..8fbb437ef0 100644
--- a/tests/upload/filespec_test.php
+++ b/tests/upload/filespec_test.php
@@ -23,6 +23,7 @@ class phpbb_filespec_test extends phpbb_test_case
const UPLOAD_MAX_FILESIZE = 1000;
private $config;
+ private $filesystem;
public $path;
protected function setUp()
@@ -30,7 +31,7 @@ class phpbb_filespec_test extends phpbb_test_case
// Global $config required by unique_id
// Global $user required by filespec::additional_checks and
// filespec::move_file
- global $config, $user;
+ global $config, $user, $phpbb_filesystem;
if (!is_array($config))
{
@@ -75,6 +76,8 @@ class phpbb_filespec_test extends phpbb_test_case
$guessers[2]->set_priority(-2);
$guessers[3]->set_priority(-2);
$this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers);
+
+ $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem();
}
private function get_filespec($override = array())
@@ -88,7 +91,7 @@ class phpbb_filespec_test extends phpbb_test_case
'error' => '',
);
- return new filespec(array_merge($upload_ary, $override), null, $this->mimetype_guesser);
+ return new filespec(array_merge($upload_ary, $override), null, $this->filesystem, $this->mimetype_guesser);
}
protected function tearDown()
@@ -198,7 +201,7 @@ class phpbb_filespec_test extends phpbb_test_case
$filespec = $this->get_filespec();
$filespec->clean_filename('unique', self::PREFIX);
$name = $filespec->realname;
-
+
$this->assertEquals(strlen($name), 32 + strlen(self::PREFIX));
$this->assertRegExp('#^[A-Za-z0-9]+$#', substr($name, strlen(self::PREFIX)));
$this->assertFalse(isset($filenames[$name]));
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php
index fcfb84125d..9de384b64f 100644
--- a/tests/upload/fileupload_test.php
+++ b/tests/upload/fileupload_test.php
@@ -20,12 +20,14 @@ class phpbb_fileupload_test extends phpbb_test_case
{
private $path;
+ private $filesystem;
+
protected function setUp()
{
// Global $config required by unique_id
// Global $user required by several functions dealing with translations
// Global $request required by form_upload, local_upload and is_valid
- global $config, $user, $request;
+ global $config, $user, $request, $phpbb_filesystem;
if (!is_array($config))
{
@@ -40,6 +42,8 @@ class phpbb_fileupload_test extends phpbb_test_case
$request = new phpbb_mock_request();
+ $this->filesystem = $phpbb_filesystem = new \phpbb\filesystem\filesystem();
+
$this->path = __DIR__ . '/fixture/';
}
@@ -65,7 +69,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_invalid_extension()
{
- $upload = new fileupload('', array('png'), 100);
+ $upload = new fileupload($this->filesystem, '', array('png'), 100);
$file = $this->gen_valid_filespec();
$upload->common_checks($file);
$this->assertEquals('DISALLOWED_EXTENSION', $file->error[0]);
@@ -73,7 +77,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_invalid_filename()
{
- $upload = new fileupload('', array('jpg'), 100);
+ $upload = new fileupload($this->filesystem, '', array('jpg'), 100);
$file = $this->gen_valid_filespec();
$file->realname = 'invalid?';
$upload->common_checks($file);
@@ -82,7 +86,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_too_large()
{
- $upload = new fileupload('', array('jpg'), 100);
+ $upload = new fileupload($this->filesystem, '', array('jpg'), 100);
$file = $this->gen_valid_filespec();
$file->filesize = 1000;
$upload->common_checks($file);
@@ -91,7 +95,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks_valid_file()
{
- $upload = new fileupload('', array('jpg'), 1000);
+ $upload = new fileupload($this->filesystem, '', array('jpg'), 1000);
$file = $this->gen_valid_filespec();
$upload->common_checks($file);
$this->assertEquals(0, sizeof($file->error));
@@ -99,7 +103,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_local_upload()
{
- $upload = new fileupload('', array('jpg'), 1000);
+ $upload = new fileupload($this->filesystem, '', array('jpg'), 1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->local_upload($this->path . 'jpg.jpg');
@@ -109,7 +113,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_move_existent_file()
{
- $upload = new fileupload('', array('jpg'), 1000);
+ $upload = new fileupload($this->filesystem, '', array('jpg'), 1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->local_upload($this->path . 'jpg.jpg');
@@ -121,7 +125,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_move_existent_file_overwrite()
{
- $upload = new fileupload('', array('jpg'), 1000);
+ $upload = new fileupload($this->filesystem, '', array('jpg'), 1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg');
@@ -134,7 +138,7 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_valid_dimensions()
{
- $upload = new fileupload('', false, false, 1, 1, 100, 100);
+ $upload = new fileupload($this->filesystem, '', false, false, 1, 1, 100, 100);
$file1 = $this->gen_valid_filespec();
$file2 = $this->gen_valid_filespec();
diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php
index bbbed59de7..6540d33287 100644
--- a/tests/viewonline/helper_test.php
+++ b/tests/viewonline/helper_test.php
@@ -17,7 +17,7 @@ class phpbb_viewonline_helper_test extends phpbb_test_case
{
parent::setUp();
- $this->viewonline_helper = new \phpbb\viewonline_helper(new \phpbb\filesystem());
+ $this->viewonline_helper = new \phpbb\viewonline_helper(new \phpbb\filesystem\filesystem());
}
public function session_pages_data()