1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-27 20:10:18 +02:00

Merge pull request #3487 from MateBartus/ticket/13697

[ticket/13697] Moving filesystem related functions to filesystem service
This commit is contained in:
Tristan Darricau
2015-04-16 20:44:02 +02:00
82 changed files with 1859 additions and 657 deletions

View File

@@ -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')

View File

@@ -74,7 +74,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,
@@ -89,7 +89,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,
@@ -118,7 +118,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

View File

@@ -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();

View File

@@ -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();

View File

@@ -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/',

View File

@@ -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');
}
}

View File

@@ -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

View File

@@ -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(

View File

@@ -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__) . '/',

View File

@@ -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,

View File

@@ -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()

View File

@@ -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.
*
*/
*
* 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
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));
}
}

View File

@@ -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));
}
}

View File

@@ -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]);

View File

@@ -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'

View File

@@ -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;

View File

@@ -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;
}
}

View File

@@ -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__) . '/');

View File

@@ -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'

View File

@@ -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');

View File

@@ -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'

View File

@@ -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

View File

@@ -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';

View File

@@ -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/';

View File

@@ -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,

View File

@@ -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,

View File

@@ -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,

View File

@@ -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()

View File

@@ -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,

View File

@@ -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))
{

View File

@@ -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();

View File

@@ -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__) . '/',

View File

@@ -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,

View File

@@ -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]));

View File

@@ -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();

View File

@@ -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()