diff options
Diffstat (limited to 'tests')
56 files changed, 931 insertions, 142 deletions
diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php index 59669c87e9..26f6d11bfc 100644 --- a/tests/attachment/delete_test.php +++ b/tests/attachment/delete_test.php @@ -21,20 +21,18 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case /** @var \phpbb\db\driver\driver_interface */ protected $db; - /** @var \phpbb\filesystem\filesystem */ - protected $filesystem; - /** @var \phpbb\event\dispatcher_interface */ protected $dispatcher; /** @var \phpbb\attachment\resync */ protected $resync; + /** @var \phpbb\storage\storage */ + protected $storage; + /** @var \phpbb\attachment\delete */ protected $attachment_delete; - protected $phpbb_root_path; - public function getDataSet() { return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml'); @@ -42,24 +40,17 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case public function setUp(): void { - global $phpbb_root_path; - parent::setUp(); $this->config = new \phpbb\config\config(array()); $this->db = $this->new_dbal(); - $db = $this->db; $this->resync = new \phpbb\attachment\resync($this->db); - $this->filesystem = $this->createMock('\phpbb\filesystem\filesystem', array('remove', 'exists')); - $this->filesystem->expects($this->any()) - ->method('remove') - ->willReturn(false); - $this->filesystem->expects($this->any()) + $this->storage = $this->createMock('\phpbb\storage\storage'); + $this->storage->expects($this->any()) ->method('exists') ->willReturn(true); - $this->phpbb_root_path = $phpbb_root_path; $this->dispatcher = new \phpbb_mock_event_dispatcher(); - $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->filesystem, $this->resync, $phpbb_root_path); + $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->resync, $this->storage); } public function data_attachment_delete() @@ -106,25 +97,24 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case */ public function test_attachment_delete_success($remove_success, $exists_success, $expected, $throw_exception = false) { - $this->filesystem = $this->createMock('\phpbb\filesystem\filesystem', array('remove', 'exists')); + $this->storage = $this->createMock('\phpbb\storage\storage', array('delete', 'exists')); if ($throw_exception) { - $this->filesystem->expects($this->any()) - ->method('remove') - ->willThrowException(new \phpbb\filesystem\exception\filesystem_exception);; + $this->storage->expects($this->any()) + ->method('delete') + ->willThrowException(new \phpbb\storage\exception\exception); } else { - $this->filesystem->expects($this->any()) - ->method('remove') + $this->storage->expects($this->any()) + ->method('delete') ->willReturn($remove_success); } - - $this->filesystem->expects($this->any()) + $this->storage->expects($this->any()) ->method('exists') ->willReturn($exists_success); - $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->filesystem, $this->resync, $this->phpbb_root_path); + $this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->resync, $this->storage); $this->assertSame($expected, $this->attachment_delete->unlink_attachment('foobar')); } } diff --git a/tests/attachment/fixtures/resync.xml b/tests/attachment/fixtures/resync.xml index af04701b4a..b06d2db3e2 100644 --- a/tests/attachment/fixtures/resync.xml +++ b/tests/attachment/fixtures/resync.xml @@ -58,7 +58,6 @@ <table name="phpbb_extension_groups"> <column>cat_id</column> <column>group_id</column> - <column>download_mode</column> <column>upload_icon</column> <column>max_filesize</column> <column>allow_group</column> @@ -68,7 +67,6 @@ <row> <value>1</value> <value>1</value> - <value>1</value> <value> </value> <value>1000</value> <value>1</value> diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index a3f51dd34e..eb7067b263 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -39,6 +39,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case /** @var \phpbb\plupload\plupload */ protected $plupload; + /** @var \phpbb\storage\storage */ + protected $storage; + /** @var \phpbb\user */ protected $user; @@ -51,8 +54,12 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case /** @var \phpbb\attachment\upload */ protected $upload; + /** @var \phpbb\filesystem\filesystem */ private $filesystem; + /** @var \phpbb\filesystem\temp */ + protected $temp; + /** @var \Symfony\Component\DependencyInjection\ContainerInterface */ protected $container; @@ -75,7 +82,6 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->auth = new \phpbb\auth\auth(); $this->config = new \phpbb\config\config(array( - 'upload_path' => '', 'img_create_thumbnail' => true, )); $config = $this->config; @@ -96,27 +102,29 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $guessers[3]->set_priority(-2); $this->mimetype_guesser = new \phpbb\mimetype\guesser($guessers); $this->plupload = new \phpbb\plupload\plupload($phpbb_root_path, $this->config, $this->request, new \phpbb\user($this->language, '\phpbb\datetime'), $this->php_ini, $this->mimetype_guesser); + + $this->storage = $this->createMock('\phpbb\storage\storage'); + $this->storage->expects($this->any()) + ->method('free_space') + ->willReturn(1024*1024); // 1gb + $factory_mock = $this->getMockBuilder('\phpbb\files\factory') ->disableOriginalConstructor() ->getMock(); $factory_mock->expects($this->any()) ->method('get') - ->willReturn(new \phpbb\files\filespec( - $this->filesystem, + ->willReturn(new \phpbb\files\filespec_storage( $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), - $this->phpbb_root_path, $this->mimetype_guesser )); $this->container = new phpbb_mock_container_builder($phpbb_root_path, $phpEx); - $this->container->set('files.filespec', new \phpbb\files\filespec( - $this->filesystem, + $this->container->set('files.filespec_storage', new \phpbb\files\filespec_storage( $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), - $phpbb_root_path, new \phpbb\mimetype\guesser(array( 'mimetype.extension_guesser' => new \phpbb\mimetype\extension_guesser(), )))); @@ -127,7 +135,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->plupload, $this->request )); - $this->container->set('files.types.local', new \phpbb\files\types\local( + $this->container->set('files.types.local_storage', new \phpbb\files\types\local_storage( $factory_mock, $this->language, $this->php_ini, @@ -136,9 +144,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->factory = new \phpbb\files\factory($this->container); $this->files_upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $this->temp = new \phpbb\filesystem\temp($this->filesystem, ''); $this->user = new \phpbb\user($this->language, '\phpbb\datetime'); - $this->upload = new \phpbb\attachment\upload( $this->auth, $this->cache, @@ -148,8 +156,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->mimetype_guesser, $this->phpbb_dispatcher, $this->plupload, - $this->user, - $this->phpbb_root_path + $this->storage, + $this->temp, + $this->user ); } @@ -205,7 +214,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case public function test_init_error() { - $filespec = $this->getMockBuilder('\phpbb\files\filespec') + $filespec = $this->getMockBuilder('\phpbb\files\filespec_storage') ->disableOriginalConstructor() ->getMock(); $filespec->expects($this->any()) @@ -217,14 +226,14 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $filespec->expects($this->any()) ->method('set_upload_ary') ->willReturnSelf(); - $this->container->set('files.filespec', $filespec); + $this->container->set('files.filespec_storage', $filespec); $factory_mock = $this->getMockBuilder('\phpbb\files\factory') ->disableOriginalConstructor() ->getMock(); $factory_mock->expects($this->any()) ->method('get') ->willReturn($filespec); - $this->container->set('files.types.local', new \phpbb\files\types\local( + $this->container->set('files.types.local_storage', new \phpbb\files\types\local_storage( $factory_mock, $this->language, $this->php_ini, @@ -240,8 +249,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->mimetype_guesser, $this->phpbb_dispatcher, $this->plupload, - $this->user, - $this->phpbb_root_path + $this->storage, + $this->temp, + $this->user ); $filedata = $this->upload->upload('foobar', 1, true); @@ -336,7 +346,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case */ public function test_image_upload($is_image, $plupload_active, $config_data, $expected) { - $filespec = $this->getMockBuilder('\phpbb\files\filespec') + $filespec = $this->getMockBuilder('\phpbb\files\filespec_storage') ->setMethods(array( 'init_error', 'is_image', @@ -344,11 +354,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case 'is_uploaded', )) ->setConstructorArgs(array( - $this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), - $this->phpbb_root_path, $this->mimetype_guesser, $this->plupload )) @@ -370,14 +378,14 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $filespec->expects($this->any()) ->method('move_file') ->willReturn(false); - $this->container->set('files.filespec', $filespec); + $this->container->set('files.filespec_storage', $filespec); $factory_mock = $this->getMockBuilder('\phpbb\files\factory') ->disableOriginalConstructor() ->getMock(); $factory_mock->expects($this->any()) ->method('get') ->willReturn($filespec); - $this->container->set('files.types.local', new \phpbb\files\types\local( + $this->container->set('files.types.local_storage', new \phpbb\files\types\local_storage( $factory_mock, $this->language, $this->php_ini, @@ -406,8 +414,9 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->mimetype_guesser, $this->phpbb_dispatcher, $plupload, - $this->user, - $this->phpbb_root_path + $this->storage, + $this->temp, + $this->user ); $filedata = $this->upload->upload('foobar', 1, true, '', false, array( diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 81a0655e02..331792ae38 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -35,7 +35,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case ->method('get') ->will($this->returnArgument(0)); - $filesystem = new \phpbb\filesystem\filesystem(); + $storage = $this->createMock('\phpbb\storage\storage'); // Prepare dependencies for avatar manager and driver $this->config = new \phpbb\config\config(array()); @@ -44,7 +44,6 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - $filesystem, $this->createMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -83,6 +82,8 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case $files_factory = new \phpbb\files\factory($phpbb_container); + $php_ini = new \bantu\IniGetWrapper\IniGetWrapper; + foreach ($this->avatar_drivers() as $driver) { if ($driver !== 'upload') @@ -96,7 +97,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case { $cur_avatar = $this->getMockBuilder('\phpbb\avatar\driver\\' . $driver) ->setMethods(array('get_name')) - ->setConstructorArgs(array($this->config, $phpbb_root_path, $phpEx, $filesystem, $path_helper, $dispatcher, $files_factory, $cache)) + ->setConstructorArgs(array($this->config, $phpbb_root_path, $phpEx, $storage, $path_helper, $dispatcher, $files_factory, $php_ini)) ->getMock(); } $cur_avatar->expects($this->any()) diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index 8c7424c50d..69ae53c128 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -97,7 +97,6 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case $mock_router, new \phpbb\symfony_request($request), $request, - new \phpbb\filesystem\filesystem(), $phpbb_root_path, $pathEx ); diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index 8402f9dd3e..16b2548d09 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -73,7 +73,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $mock_router, new \phpbb\symfony_request($request), $request, - new \phpbb\filesystem\filesystem(), $phpbb_root_path, $phpEx ); @@ -149,7 +148,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $mock_router, new \phpbb\symfony_request($request), $request, - new \phpbb\filesystem\filesystem(), $phpbb_root_path, $phpEx ); @@ -192,7 +190,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $mock_router, new \phpbb\symfony_request($request), $request, - new \phpbb\filesystem\filesystem(), $phpbb_root_path, $phpEx ); diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 1c1796a1fc..35a8eedb80 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -298,6 +298,8 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); + $storage = $this->createMock('\phpbb\storage\storage'); + // Create auth mock $auth = $this->createMock('\phpbb\auth\auth'); $auth->expects($this->any()) @@ -309,7 +311,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path); + $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index bdaf8ee682..4575adbfc3 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -91,7 +91,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $this->filesystem = new \phpbb\filesystem\filesystem(); $this->phpbb_path_helper = new \phpbb\path_helper( $this->symfony_request, - $this->filesystem, $this->request, $phpbb_root_path, $phpEx @@ -106,7 +105,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case $container->setParameter('core.environment', PHPBB_ENVIRONMENT); $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader($this->filesystem, ''); + $loader = new \phpbb\template\twig\loader(''); $twig = new \phpbb\template\twig\environment( $this->config, $this->filesystem, @@ -137,7 +136,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case ); $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( - new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/') + new \phpbb\routing\file_locator(dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', false); @@ -185,7 +184,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); } @@ -229,7 +228,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description); } @@ -273,7 +272,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); } @@ -317,7 +316,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); } @@ -361,7 +360,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0')); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } @@ -405,7 +404,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description); } @@ -446,7 +445,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description); } @@ -490,7 +489,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description) { $this->config = new \phpbb\config\config(['enable_mod_rewrite' => '1']); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description); } @@ -522,7 +521,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case 'server_protocol' => $server_protocol, )); - $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $this->router, $this->symfony_request, $this->request, $this->root_path, 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->symfony_request, $this->request, $this->routing_helper); static::assertEquals($expected, $this->helper->route('controller1', array(), false, false, $type)); } diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index ddc1921b0e..89631552af 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -45,7 +45,7 @@ class phpbb_controller_controller_test extends phpbb_test_case $container->setParameter('core.environment', PHPBB_ENVIRONMENT); $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( - new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/') + new \phpbb\routing\file_locator(dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager); $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', false); diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index f025e38cd5..3cfc17fdeb 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -97,7 +97,6 @@ class phpbb_cron_manager_test extends \phpbb_test_case $mock_router, new \phpbb\symfony_request($request), $request, - new \phpbb\filesystem\filesystem(), $phpbb_root_path, $phpEx ); diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 7d6b100449..947da726b3 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -69,6 +69,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case dirname(__FILE__) . '/../../phpBB/', 'php', 'phpbb_', + self::get_core_tables(), $tools, new \phpbb\db\migration\helper() ); @@ -79,7 +80,6 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case $container, $this->db, $this->config, - new phpbb\filesystem\filesystem(), 'phpbb_ext', dirname(__FILE__) . '/../../phpBB/', 'php', diff --git a/tests/di/fixtures/config/production/container/environment.yml b/tests/di/fixtures/config/production/container/environment.yml index 0af08f0849..2792b24162 100644 --- a/tests/di/fixtures/config/production/container/environment.yml +++ b/tests/di/fixtures/config/production/container/environment.yml @@ -22,6 +22,11 @@ services: ext.manager: class: phpbb\extension\manager_mock + config: + class: phpbb\config\config + arguments: + - [] + template.twig.environment: class: Exception arguments: diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml index 0a9e4b5e77..356eb4b008 100644 --- a/tests/di/fixtures/config/test/container/environment.yml +++ b/tests/di/fixtures/config/test/container/environment.yml @@ -19,6 +19,11 @@ services: dispatcher: class: phpbb\db\driver\container_mock + config: + class: phpbb\config\config + arguments: + - [] + template.twig.environment: class: Exception arguments: 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 8e5ed6c52c..2164077d8e 100644 --- a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php +++ b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php @@ -17,6 +17,7 @@ use phpbb\extension\di\extension_base; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; +use phpbb\filesystem\helper as filesystem_helper; /** * Container core extension @@ -25,8 +26,7 @@ class extension extends extension_base { protected function load_services(ContainerBuilder $container) { - $filesystem = new \phpbb\filesystem\filesystem(); - $loader = new YamlFileLoader($container, new FileLocator($filesystem->realpath($this->ext_path))); + $loader = new YamlFileLoader($container, new FileLocator(filesystem_helper::realpath($this->ext_path))); $loader->load('environment.yml'); } } diff --git a/tests/di/fixtures/other_config/production/container/environment.yml b/tests/di/fixtures/other_config/production/container/environment.yml index c0d2f87bab..aeb552eeb7 100644 --- a/tests/di/fixtures/other_config/production/container/environment.yml +++ b/tests/di/fixtures/other_config/production/container/environment.yml @@ -19,6 +19,11 @@ services: ext.manager: class: phpbb\extension\manager_mock + config: + class: phpbb\config\config + arguments: + - [] + template.twig.environment: class: Exception arguments: diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php index 629df9abb6..a7f76d50a2 100644 --- a/tests/email/email_parsing_test.php +++ b/tests/email/email_parsing_test.php @@ -39,7 +39,6 @@ class phpbb_email_parsing_test extends phpbb_test_case $filesystem = new \phpbb\filesystem\filesystem(); $phpbb_path_helper = new \phpbb\path_helper( $symfony_request, - $filesystem, $request, $phpbb_root_path, $phpEx @@ -73,7 +72,7 @@ class phpbb_email_parsing_test extends phpbb_test_case $phpbb_path_helper, $cache_path, null, - new \phpbb\template\twig\loader($filesystem, ''), + new \phpbb\template\twig\loader(''), new \phpbb\event\dispatcher($phpbb_container), array( 'cache' => false, diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 7649b4f19a..c86b81f147 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -243,7 +243,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\filesystem(), dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name'); + $finder = new \phpbb\finder(dirname(__FILE__) . '/', $cache, 'php', '_custom_cache_name'); $finder->set_extensions(array_keys($this->extension_manager->all_enabled())); $files = $finder->suffix('_class.php')->get_files(); @@ -283,7 +283,6 @@ class phpbb_extension_finder_test extends phpbb_test_case ); $finder = new \phpbb\finder( - 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 3ab0f608d1..5eac7d1951 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -167,6 +167,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $phpbb_root_path, $php_ext, $table_prefix, + self::get_core_tables(), array(), new \phpbb\db\migration\helper() ); @@ -176,7 +177,6 @@ class phpbb_extension_manager_test extends phpbb_database_test_case $container, $db, $config, - new \phpbb\filesystem\filesystem(), 'phpbb_ext', dirname(__FILE__) . '/', $php_ext, diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php index a2f0542979..2e1a85a013 100644 --- a/tests/extension/metadata_manager_test.php +++ b/tests/extension/metadata_manager_test.php @@ -52,13 +52,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(new \phpbb\filesystem\filesystem(), ''); + $loader = new \phpbb\template\twig\loader(''); $filesystem = new \phpbb\filesystem\filesystem(); $phpbb_path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - $filesystem, $this->createMock('\phpbb\request\request'), $this->phpbb_root_path, $this->phpEx @@ -88,6 +87,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $this->phpbb_root_path, 'php', $this->table_prefix, + self::get_core_tables(), array(), new \phpbb\db\migration\helper() ); @@ -97,7 +97,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case $container, $this->db, $this->config, - new \phpbb\filesystem\filesystem(), 'phpbb_ext', $this->phpbb_root_path, $this->phpEx, diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php index 3798056f10..df91d8cc5d 100644 --- a/tests/feed/attachments_base_test.php +++ b/tests/feed/attachments_base_test.php @@ -35,7 +35,6 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - $this->filesystem, $this->createMock('\phpbb\request\request'), $phpbb_root_path, 'php' diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php index d42a609fbb..3b3d61acac 100644 --- a/tests/files/types_remote_test.php +++ b/tests/files/types_remote_test.php @@ -15,10 +15,15 @@ require_once dirname(__FILE__) . '/type_foo.php'; class phpbb_files_types_remote_test extends phpbb_test_case { + /** @var string */ private $path; + /** @var \phpbb\filesystem\filesystem */ private $filesystem; + /** @var \phpbb\filesystem\temp */ + private $temp; + /** @var \phpbb\config\config */ protected $config; @@ -49,7 +54,9 @@ class phpbb_files_types_remote_test extends phpbb_test_case $this->config->set('remote_upload_verify', 0); $this->request = $this->createMock('\phpbb\request\request'); + $cache_path = $phpbb_root_path . 'cache/files'; $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->temp = new \phpbb\filesystem\temp($this->filesystem, $cache_path); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; @@ -71,7 +78,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case public function test_upload_fsock_fail() { - $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->temp, $this->language, $this->php_ini, $this->request); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')); $type_remote->set_upload($upload); @@ -106,7 +113,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case $php_ini->expects($this->any()) ->method('getString') ->willReturn($max_file_size); - $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->language, $php_ini, $this->request, $this->phpbb_root_path); + $type_remote = new \phpbb\files\types\remote($this->config, $this->factory, $this->temp, $this->language, $php_ini, $this->request); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')); $type_remote->set_upload($upload); @@ -118,7 +125,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case public function test_upload_wrong_path() { - $type_remote = new \phpbb\files\types\foo($this->config, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); + $type_remote = new \phpbb\files\types\foo($this->config, $this->factory, $this->temp, $this->language, $this->php_ini, $this->request); $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $upload->set_allowed_extensions(array('png')); $type_remote->set_upload($upload); diff --git a/tests/filesystem/helper_clean_path_test.php b/tests/filesystem/helper_clean_path_test.php new file mode 100644 index 0000000000..d1b5a18f02 --- /dev/null +++ b/tests/filesystem/helper_clean_path_test.php @@ -0,0 +1,52 @@ +<?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. +* +*/ + +use phpbb\filesystem\helper as filesystem_helper; + +class phpbb_filesystem_helper_clean_path_test extends phpbb_test_case +{ + + public function setUp(): void + { + parent::setUp(); + } + + public function clean_path_data() + { + yield ['foo', 'foo']; + yield ['foo/bar', 'foo/bar']; + yield ['foo/bar/', 'foo/bar/']; + yield ['foo/./bar', 'foo/bar']; + yield ['foo/./././bar', 'foo/bar']; + yield ['foo/bar/.', 'foo/bar']; + yield ['./foo/bar', './foo/bar']; + yield ['../foo/bar', '../foo/bar']; + yield ['./../foo/bar', './../foo/bar']; + yield ['././../foo/bar', './../foo/bar']; + yield ['one/two/three', 'one/two/three']; + yield ['one/two/../three', 'one/three']; + yield ['one/../two/three', 'two/three']; + yield ['one/two/..', 'one']; + yield ['one/two/../', 'one/']; + yield ['one/two/../three/../four', 'one/four']; + yield ['one/two/three/../../four', 'one/four']; + } + + /** + * @dataProvider clean_path_data + */ + public function test_clean_path($input, $expected) + { + $this->assertEquals($expected, filesystem_helper::clean_path($input)); + } +} diff --git a/tests/filesystem/helper_is_absolute_test.php b/tests/filesystem/helper_is_absolute_test.php new file mode 100644 index 0000000000..16356386d1 --- /dev/null +++ b/tests/filesystem/helper_is_absolute_test.php @@ -0,0 +1,64 @@ +<?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. + * + */ + +use phpbb\filesystem\helper as filesystem_helper; + +class phpbb_filesystem_helper_is_absolute_test extends phpbb_test_case +{ + + public function setUp(): void + { + parent::setUp(); + } + + static public function is_absolute_data() + { + // Empty + yield ['', false]; + + // Absolute unix style + yield ['/etc/phpbb', true]; + // Unix does not support \ so that is not an absolute path + yield ['\etc\phpbb', false]; + + // Absolute windows style + yield ['c:\windows', true]; + yield ['C:\Windows', true]; + yield ['c:/windows', true]; + yield ['C:/Windows', true]; + + // Executable + yield ['etc/phpbb', false]; + yield ['explorer.exe', false]; + + // Relative subdir + yield ['Windows\System32', false]; + yield ['Windows\System32\explorer.exe', false]; + yield ['Windows/System32', false]; + yield ['Windows/System32/explorer.exe', false]; + + // Relative updir + yield ['..\Windows\System32', false]; + yield ['..\Windows\System32\explorer.exe', false]; + yield ['../Windows/System32', false]; + yield ['../Windows/System32/explorer.exe', false]; + } + + /** + * @dataProvider is_absolute_data + */ + public function test_is_absolute($path, $expected) + { + $this->assertEquals($expected, filesystem_helper::is_absolute_path($path)); + } +} diff --git a/tests/filesystem/helper_realpath_test.php b/tests/filesystem/helper_realpath_test.php new file mode 100644 index 0000000000..bfb871384b --- /dev/null +++ b/tests/filesystem/helper_realpath_test.php @@ -0,0 +1,83 @@ +<?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. + * + */ + +use phpbb\filesystem\helper as filesystem_helper; + +class phpbb_filesystem_helper_realpath_test extends phpbb_test_case +{ + protected static $filesystem_helper_phpbb_own_realpath; + + static public function setUpBeforeClass() + { + parent::setUpBeforeClass(); + + self::$filesystem_helper_phpbb_own_realpath = new ReflectionMethod('\phpbb\filesystem\helper', 'phpbb_own_realpath'); + self::$filesystem_helper_phpbb_own_realpath->setAccessible(true); + } + + public function setUp(): void + { + parent::setUp(); + } + + public function realpath_resolve_absolute_without_symlinks_data() + { + // Constant data + yield [__DIR__, __DIR__]; + yield [__DIR__ . '/../filesystem/../filesystem', __DIR__]; + yield [__DIR__ . '/././', __DIR__]; + yield [__DIR__ . '/non_existent', false]; + + yield [__FILE__, __FILE__]; + yield [__FILE__ . '../', false]; + } + + public function realpath_resolve_relative_without_symlinks_data() + { + if (!function_exists('getcwd')) + { + yield []; + } + else + { + $relative_path = filesystem_helper::make_path_relative(__DIR__, getcwd()); + + yield [$relative_path, __DIR__]; + yield [$relative_path . '../filesystem/../filesystem', __DIR__]; + yield [$relative_path . '././', __DIR__]; + + yield [$relative_path . 'helper_realpath_test.php', __FILE__]; + } + } + + /** + * @dataProvider realpath_resolve_absolute_without_symlinks_data + */ + public function test_realpath_absolute_without_links($path, $expected) + { + $this->assertEquals($expected, self::$filesystem_helper_phpbb_own_realpath->invoke(null, $path)); + } + + /** + * @dataProvider realpath_resolve_relative_without_symlinks_data + */ + public function test_realpath_relative_without_links($path, $expected) + { + if (!function_exists('getcwd')) + { + $this->markTestSkipped('phpbb_own_realpath() cannot be tested with relative paths: getcwd is not available.'); + } + + $this->assertEquals($expected, self::$filesystem_helper_phpbb_own_realpath->invoke(null, $path)); + } +} diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 25fc9f0508..f327981960 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -19,6 +19,9 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var \phpbb\filesystem\filesystem_interface */ protected $filesystem; + /** @var \phpbb\filesystem\temp */ + protected $temp; + /** @var \phpbb\files\factory */ protected $factory; @@ -53,6 +56,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $config['remote_upload_verify'] = 0; $this->filesystem = new \phpbb\filesystem\filesystem(); + $this->temp = new \phpbb\filesystem\temp($this->filesystem, ''); $this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->request = $this->createMock('\phpbb\request\request'); $this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper; @@ -61,7 +65,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $container->set('files.filespec', new \phpbb\files\filespec($this->filesystem, $this->language, $this->php_ini, new \FastImageSize\FastImageSize(), $this->phpbb_root_path)); $this->factory = new \phpbb\files\factory($container); $container->set('files.factory', $this->factory); - $container->set('files.types.remote', new \phpbb\files\types\remote($config, $this->factory, $this->language, $this->php_ini, $this->request, $phpbb_root_path)); + $container->set('files.types.remote', new \phpbb\files\types\remote($config, $this->factory, $this->temp, $this->language, $this->php_ini, $this->request)); $this->phpbb_root_path = $phpbb_root_path; } diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index 91fc962846..4ca1d4b637 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -77,12 +77,12 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case $crawler = self::request('GET', 'ucp.php?i=ucp_notifications'); // At least one notification should exist - $this->assertGreaterThan(0, $crawler->filter('#notification_list_button strong')->text()); + $this->assertGreaterThan(0, $crawler->filter('#notification-button strong')->text()); // Get form token $link = $crawler->selectLink($this->lang('NOTIFICATIONS_MARK_ALL_READ'))->link()->getUri(); $crawler = self::request('GET', substr($link, strpos($link, 'ucp.'))); - $this->assertCount(1, $crawler->filter('#notification_list_button strong.badge.hidden')); - $this->assertEquals("0", $crawler->filter('#notification_list_button strong.badge.hidden')->text()); + $this->assertCount(1, $crawler->filter('#notification-button strong.badge.hidden')); + $this->assertEquals("0", $crawler->filter('#notification-button strong.badge.hidden')->text()); } } diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 1519549d3e..d1e3481b38 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -27,7 +27,6 @@ class phpbb_build_url_test extends phpbb_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), $this->createMock('\phpbb\request\request'), $phpbb_root_path, 'php' diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index 7e414dad86..52fb4f3d42 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -39,8 +39,11 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + + $storage = $this->createMock('\phpbb\storage\storage'); + // Works as a workaround for tests - $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); + $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage)); $phpbb_container->set( 'auth.provider.db', new phpbb_mock_auth_provider() diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php index 4bb0aec34f..5bb8d7ab93 100644 --- a/tests/migrator/convert_timezones_test.php +++ b/tests/migrator/convert_timezones_test.php @@ -64,7 +64,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case $factory->get($this->db), $phpbb_root_path, $phpEx, - 'phpbb_' + 'phpbb_', + self::get_core_tables() ); } diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php index b0abb6199c..809b977d57 100644 --- a/tests/migrator/get_callable_from_step_test.php +++ b/tests/migrator/get_callable_from_step_test.php @@ -43,6 +43,7 @@ class get_callable_from_step_test extends phpbb_database_test_case $phpbb_root_path, $php_ext, $table_prefix, + self::get_core_tables(), array($module_tools), new \phpbb\db\migration\helper() ); diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php index 1349b98953..dd7158cbfd 100644 --- a/tests/migrator/schema_generator_test.php +++ b/tests/migrator/schema_generator_test.php @@ -41,7 +41,7 @@ class schema_generator_test extends phpbb_test_case protected function get_schema_generator(array $class_names) { - $this->generator = new \phpbb\db\migration\schema_generator($class_names, $this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix); + $this->generator = new \phpbb\db\migration\schema_generator($class_names, $this->config, $this->db, $this->db_tools, $this->phpbb_root_path, $this->php_ext, $this->table_prefix, phpbb_database_test_case::get_core_tables()); return $this->generator; } diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php index d4a33ff537..d1707cc70f 100644 --- a/tests/notification/convert_test.php +++ b/tests/notification/convert_test.php @@ -36,7 +36,8 @@ class phpbb_notification_convert_test extends phpbb_database_test_case $factory->get($this->db), $phpbb_root_path, $phpEx, - 'phpbb_' + 'phpbb_', + self::get_core_tables() ); } diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index b935b180d9..f5f0013770 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -60,7 +60,6 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), $this->getMockBuilder('\phpbb\request\request')->disableOriginalConstructor()->getMock(), $phpbb_root_path, $phpEx diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 466d3ec07f..fe0e937837 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -91,6 +91,9 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c // Language $lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); + // Storage + $storage = $this->createMock('\phpbb\storage\storage'); + // User $user = $this->createMock('\phpbb\user', array(), array( $lang, @@ -125,6 +128,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c $phpbb_container->set('cache', $cache); $phpbb_container->set('text_formatter.utils', new \phpbb\textformatter\s9e\utils()); $phpbb_container->set('dispatcher', $phpbb_dispatcher); + $phpbb_container->set('storage.attachment', $storage); $phpbb_container->setParameter('core.root_path', $phpbb_root_path); $phpbb_container->setParameter('core.php_ext', $phpEx); $phpbb_container->setParameter('tables.notifications', 'phpbb_notifications'); diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 073ba1d5cd..cd7420a0eb 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -39,12 +39,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1')); - $filesystem = new \phpbb\filesystem\filesystem(); $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $loader = new \Symfony\Component\Routing\Loader\YamlFileLoader( - new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/') + new \phpbb\routing\file_locator(dirname(__FILE__) . '/') ); $resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager); $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php', false); @@ -58,7 +57,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case $request ); - $this->routing_helper = new \phpbb\routing\helper($this->config, $router, $symfony_request, $request, $filesystem, '', 'php'); + $this->routing_helper = new \phpbb\routing\helper($this->config, $router, $symfony_request, $request, '', 'php'); $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $symfony_request, $request, $this->routing_helper); $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher); } diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 31182c2daf..bca0f0eb07 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -11,6 +11,8 @@ * */ +use phpbb\filesystem\helper as filesystem_helper; + class phpbb_path_helper_test extends phpbb_test_case { /** @var \phpbb\path_helper */ @@ -21,14 +23,12 @@ class phpbb_path_helper_test extends phpbb_test_case { parent::setUp(); - $filesystem = new \phpbb\filesystem\filesystem(); - $this->set_phpbb_root_path($filesystem); + $this->set_phpbb_root_path(); $this->path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), $this->createMock('\phpbb\request\request'), $this->phpbb_root_path, 'php' @@ -43,9 +43,9 @@ class phpbb_path_helper_test extends phpbb_test_case * any time we wish to use it in one of these functions (and * also in general for everything else) */ - public function set_phpbb_root_path($filesystem) + public function set_phpbb_root_path() { - $this->phpbb_root_path = $filesystem->clean_path(dirname(__FILE__) . '/../../phpBB/'); + $this->phpbb_root_path = filesystem_helper::clean_path(dirname(__FILE__) . '/../../phpBB/'); } public function test_get_web_root_path() @@ -56,8 +56,7 @@ class phpbb_path_helper_test extends phpbb_test_case public function basic_update_web_root_path_data() { - $filesystem = new \phpbb\filesystem\filesystem(); - $this->set_phpbb_root_path($filesystem); + $this->set_phpbb_root_path(); return array( array( @@ -75,7 +74,7 @@ class phpbb_path_helper_test extends phpbb_test_case ), array( $this->phpbb_root_path . $this->phpbb_root_path . 'test.php', - $filesystem->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'), ), ); } @@ -90,7 +89,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\filesystem()); + $this->set_phpbb_root_path(); return array( array( @@ -181,7 +180,6 @@ class phpbb_path_helper_test extends phpbb_test_case $path_helper = new \phpbb\path_helper( $symfony_request, - new \phpbb\filesystem\filesystem(), $this->createMock('\phpbb\request\request'), $this->phpbb_root_path, 'php' diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php index 9d6ba7a917..f1d717f03c 100644 --- a/tests/privmsgs/delete_user_pms_test.php +++ b/tests/privmsgs/delete_user_pms_test.php @@ -91,8 +91,11 @@ class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case $phpbb_container = new phpbb_mock_container_builder(); $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); + + $storage = $this->createMock('\phpbb\storage\storage'); + // Works as a workaround for tests - $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path)); + $phpbb_container->set('attachment.manager', new \phpbb\attachment\delete(new \phpbb\config\config(array()), $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage)); phpbb_delete_user_pms($delete_user); diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 8bde1488d8..4630bc8dc5 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -68,7 +68,6 @@ class phpbb_security_redirect_test extends phpbb_security_test_base new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), $this->createMock('\phpbb\request\request'), $phpbb_root_path, 'php' diff --git a/tests/storage/adapter/local_subfolders_test.php b/tests/storage/adapter/local_subfolders_test.php new file mode 100644 index 0000000000..de02fceefa --- /dev/null +++ b/tests/storage/adapter/local_subfolders_test.php @@ -0,0 +1,136 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + + class phpbb_storage_adapter_local_subfolders_test extends phpbb_test_case + { + protected $adapter; + + protected $path; + + protected $filesystem; + + public function setUp(): void + { + parent::setUp(); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + $phpbb_root_path = getcwd() . DIRECTORY_SEPARATOR; + + $this->adapter = new \phpbb\storage\adapter\local($this->filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path); + $this->adapter->configure(['path' => 'test_path', 'subfolders' => true]); + + $this->path = $phpbb_root_path . 'test_path/'; + mkdir($this->path); + } + + public function tearDown(): void + { + $this->adapter = null; + rmdir($this->path); + } + + public function test_put_contents() + { + $this->adapter->put_contents('file.txt', 'abc'); + $this->assertTrue(file_exists($this->path . '3d/8e/file.txt')); + $this->assertEquals(file_get_contents($this->path . '3d/8e/file.txt'), 'abc'); + unlink($this->path . '3d/8e/file.txt'); + rmdir($this->path . '3d/8e'); + rmdir($this->path . '3d'); + } + + public function test_get_contents() + { + mkdir($this->path . '3d/8e', 0777, true); + file_put_contents($this->path . '3d/8e/file.txt', 'abc'); + $this->assertEquals($this->adapter->get_contents('file.txt'), 'abc'); + unlink($this->path . '3d/8e/file.txt'); + rmdir($this->path . '3d/8e'); + rmdir($this->path . '3d'); + } + + public function test_exists() + { + mkdir($this->path . '3d/8e', 0777, true); + touch($this->path . '3d/8e/file.txt'); + $this->assertTrue($this->adapter->exists('file.txt')); + $this->assertFalse($this->adapter->exists('3d/8e/file.txt')); + unlink($this->path . '3d/8e/file.txt'); + rmdir($this->path . '3d/8e'); + rmdir($this->path . '3d'); + } + + public function test_delete_file() + { + mkdir($this->path . '3d/8e', 0777, true); + touch($this->path . '3d/8e/file.txt'); + $this->assertTrue(file_exists($this->path . '3d/8e/file.txt')); + $this->adapter->delete('file.txt'); + $this->assertFalse(file_exists($this->path . '3d/8e/file.txt')); + $this->assertFalse(file_exists($this->path . '3d')); + } + + public function test_rename() + { + mkdir($this->path . '3d/8e', 0777, true); + touch($this->path . '3d/8e/file.txt'); + $this->adapter->rename('file.txt', 'file2.txt'); + $this->assertFalse(file_exists($this->path . '3d/8e/file.txt')); + $this->assertTrue(file_exists($this->path . '27/36/file2.txt')); + $this->assertFalse(file_exists($this->path . '3d')); + unlink($this->path . '27/36/file2.txt'); + rmdir($this->path . '27/36'); + rmdir($this->path . '27'); + } + + public function test_copy() + { + mkdir($this->path . '3d/8e', 0777, true); + file_put_contents($this->path . '3d/8e/file.txt', 'abc'); + $this->adapter->copy('file.txt', 'file2.txt'); + $this->assertEquals(file_get_contents($this->path . '3d/8e/file.txt'), 'abc'); + $this->assertEquals(file_get_contents($this->path . '27/36/file2.txt'), 'abc'); + unlink($this->path . '3d/8e/file.txt'); + rmdir($this->path . '3d/8e'); + rmdir($this->path . '3d'); + unlink($this->path . '27/36/file2.txt'); + rmdir($this->path . '27/36'); + rmdir($this->path . '27'); + } + + public function test_read_stream() + { + mkdir($this->path . '3d/8e', 0777, true); + touch($this->path . '3d/8e/file.txt'); + $stream = $this->adapter->read_stream('file.txt'); + $this->assertTrue(is_resource($stream)); + fclose($stream); + unlink($this->path . '3d/8e/file.txt'); + rmdir($this->path . '3d/8e'); + rmdir($this->path . '3d'); + } + + public function test_write_stream() + { + file_put_contents($this->path . 'file.txt', 'abc'); + $stream = fopen($this->path . 'file.txt', 'rb'); + $this->adapter->write_stream('file2.txt', $stream); + fclose($stream); + $this->assertEquals(file_get_contents($this->path . '27/36/file2.txt'), 'abc'); + unlink($this->path . 'file.txt'); + unlink($this->path . '27/36/file2.txt'); + rmdir($this->path . '27/36'); + rmdir($this->path . '27'); + } + + } diff --git a/tests/storage/adapter/local_test.php b/tests/storage/adapter/local_test.php new file mode 100644 index 0000000000..e44f0e2023 --- /dev/null +++ b/tests/storage/adapter/local_test.php @@ -0,0 +1,113 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + + class phpbb_storage_adapter_local_test extends phpbb_test_case + { + protected $adapter; + + protected $path; + + protected $filesystem; + + public function setUp(): void + { + parent::setUp(); + + $this->filesystem = new \phpbb\filesystem\filesystem(); + $phpbb_root_path = getcwd() . DIRECTORY_SEPARATOR; + + $this->adapter = new \phpbb\storage\adapter\local($this->filesystem, new \FastImageSize\FastImageSize(), new \phpbb\mimetype\guesser(array(new \phpbb\mimetype\extension_guesser)), $phpbb_root_path); + $this->adapter->configure(['path' => 'test_path', 'subfolders' => false]); + + $this->path = $phpbb_root_path . 'test_path/'; + mkdir($this->path); + } + + public function tearDown(): void + { + $this->adapter = null; + rmdir($this->path); + } + + public function test_put_contents() + { + $this->adapter->put_contents('file.txt', 'abc'); + $this->assertTrue(file_exists($this->path . 'file.txt')); + $this->assertEquals(file_get_contents($this->path . 'file.txt'), 'abc'); + unlink($this->path . 'file.txt'); + } + + public function test_get_contents() + { + file_put_contents($this->path . 'file.txt', 'abc'); + $this->assertEquals($this->adapter->get_contents('file.txt'), 'abc'); + unlink($this->path . 'file.txt'); + } + + public function test_exists() + { + touch($this->path . 'file.txt'); + $this->assertTrue($this->adapter->exists('file.txt')); + $this->assertFalse($this->adapter->exists('noexist.txt')); + unlink($this->path . 'file.txt'); + } + + public function test_delete_file() + { + touch($this->path . 'file.txt'); + $this->assertTrue(file_exists($this->path . 'file.txt')); + $this->adapter->delete('file.txt'); + $this->assertFalse(file_exists($this->path . 'file.txt')); + } + + public function test_rename() + { + touch($this->path . 'file.txt'); + $this->adapter->rename('file.txt', 'file2.txt'); + $this->assertFalse(file_exists($this->path . 'file.txt')); + $this->assertTrue(file_exists($this->path . 'file2.txt')); + $this->assertFalse(file_exists($this->path . 'file.txt')); + unlink($this->path . 'file2.txt'); + } + + public function test_copy() + { + file_put_contents($this->path . 'file.txt', 'abc'); + $this->adapter->copy('file.txt', 'file2.txt'); + $this->assertEquals(file_get_contents($this->path . 'file.txt'), 'abc'); + $this->assertEquals(file_get_contents($this->path . 'file2.txt'), 'abc'); + unlink($this->path . 'file.txt'); + unlink($this->path . 'file2.txt'); + } + + public function test_read_stream() + { + touch($this->path . 'file.txt'); + $stream = $this->adapter->read_stream('file.txt'); + $this->assertTrue(is_resource($stream)); + fclose($stream); + unlink($this->path . 'file.txt'); + } + + public function test_write_stream() + { + file_put_contents($this->path . 'file.txt', 'abc'); + $stream = fopen($this->path . 'file.txt', 'rb'); + $this->adapter->write_stream('file2.txt', $stream); + fclose($stream); + $this->assertEquals(file_get_contents($this->path . 'file2.txt'), 'abc'); + unlink($this->path . 'file.txt'); + unlink($this->path . 'file2.txt'); + } + + } diff --git a/tests/template/extension_test.php b/tests/template/extension_test.php index d633001060..5d73aed91e 100644 --- a/tests/template/extension_test.php +++ b/tests/template/extension_test.php @@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/template_test_case.php'; class phpbb_template_extension_test extends phpbb_template_template_test_case { - protected function setup_engine(array $new_config = array()) + protected function setup_engine(array $new_config = []) { global $config, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; @@ -28,6 +28,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $this->lang = $lang = new \phpbb\language\language($lang_loader); $this->user = new \phpbb\user($lang, '\phpbb\datetime'); + $this->user->style['style_path'] = 'chameleon'; global $auth, $request, $symfony_request, $user; $user = new phpbb_mock_user(); @@ -39,23 +40,33 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case $auth->method('acl_get') ->willReturn(true); - $filesystem = new \phpbb\filesystem\filesystem(); + $filesystem = $this->createMock('\phpbb\filesystem\filesystem'); + $filesystem->expects($this->any()) + ->method('exists') + ->with($this->stringContains('theme/png/')) + ->will($this->returnValueMap([ + ['phpBB/styles/chameleon/theme/png/phone.png', true], + ['phpBB/styles/chameleon/theme/png/pencil.png', true], + ['phpBB/styles/chameleon/theme/png/user.png', false], + ])); $request = new phpbb_mock_request; $symfony_request = new \phpbb\symfony_request( $request ); $phpbb_path_helper = new \phpbb\path_helper( $symfony_request, - $filesystem, $request, $phpbb_root_path, $phpEx ); + $storage = $this->getMockBuilder('\phpbb\storage\storage') + ->disableOriginalConstructor() + ->getMock(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $files = new phpbb\files\factory($phpbb_container); - $upload_avatar_driver = new phpbb\avatar\driver\upload($config, $phpbb_root_path, $phpEx, $filesystem, $phpbb_path_helper, $phpbb_dispatcher, $files); + $upload_avatar_driver = new phpbb\avatar\driver\upload($config, $phpbb_root_path, $phpEx, $storage, $phpbb_path_helper, $phpbb_dispatcher, $files, new \bantu\IniGetWrapper\IniGetWrapper()); $upload_avatar_driver->set_name('avatar.driver.upload'); $phpbb_container->set('avatar.manager', new \phpbb\avatar\manager($config, $phpbb_dispatcher, [ $upload_avatar_driver, @@ -71,7 +82,7 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case $cache_path = $phpbb_root_path . 'cache/twig'; $context = new \phpbb\template\context(); - $loader = new \phpbb\template\twig\loader($filesystem); + $loader = new \phpbb\template\twig\loader([]); $twig = new \phpbb\template\twig\environment( $config, $filesystem, @@ -80,12 +91,12 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case null, $loader, new \phpbb\event\dispatcher($phpbb_container), - array( + [ 'cache' => false, 'debug' => false, 'auto_reload' => true, 'autoescape' => false, - ) + ] ); $this->template = new phpbb\template\twig\twig( $phpbb_path_helper, @@ -98,11 +109,17 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case new \phpbb\template\twig\extension($context, $twig, $this->lang), new \phpbb\template\twig\extension\avatar(), new \phpbb\template\twig\extension\config($config), + new \phpbb\template\twig\extension\icon($this->user), new \phpbb\template\twig\extension\username(), ] ); $twig->setLexer(new \phpbb\template\twig\lexer($twig)); - $this->template->set_custom_style('tests', $this->template_path); + + $this->template->set_custom_style('tests', [ + $this->template_path, + $phpbb_root_path . 'styles/all/imgs', + $phpbb_root_path . 'styles/all/template', + ]); } public function data_template_extensions() @@ -251,8 +268,287 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case /** * @dataProvider data_template_extensions */ - public function test_get_user_avatar($file, $vars, $block_vars, $destroy_array, $expected, $lang_vars = []) + public function test_template_extensions($file, $vars, $block_vars, $destroy_array, $expected, $lang_vars = []) { $this->run_template($file, $vars, $block_vars, $destroy_array, $expected, $lang_vars); } + + public function data_template_icon_extension() + { + return [ + /** Font: default */ + [ + [ + 'type' => 'font', + 'icon' => 'phone', + 'title' => 'ICON_PHONE', + 'hidden' => false, + 'classes' => '', + 'attributes' => [], + ], + [ + 'ICON_PHONE' => 'Phone icon', + ], + '<i class="o-icon o-icon-font fa-phone"></i><span>Phone icon</span>', + + ], + /** Font: all options */ + [ + [ + 'type' => 'font', + 'icon' => 'pencil', + 'title' => 'ICON_PENCIL', + 'hidden' => true, + 'classes' => 'a-class another-class', + 'attributes' => [ + 'data-attr-1' => 'true', + 'data-attr-2' => 'two', + ], + ], + [ + 'ICON_PENCIL' => 'Pencil icon', + ], + '<i class="o-icon o-icon-font fa-pencil a-class another-class" title="Pencil icon" aria-hidden="true" data-attr-1="true" data-attr-2="two"></i> + <span class="sr-only">Pencil icon</span>' + ], + /** Font: icons array */ + [ + [ + 'type' => 'font', + 'icon' => [ + 'bullhorn' => false, + 'star' => false, + 'lock' => true, + 'fire' => false, + 'file' => true, + ], + 'title' => 'ICON_TOPIC', + 'hidden' => false, + 'classes' => '', + 'attributes' => [], + ], + [ + 'ICON_TOPIC' => 'Topic icon', + ], + '<i class="o-icon o-icon-font fa-lock"></i> + <span>Topic icon</span>', + ], + /** Font: icons array with no key for the default */ + [ + [ + 'type' => 'font', + 'icon' => [ + 'bullhorn' => false, + 'star' => false, + 'lock' => false, + 'fire' => false, + 'file', + ], + 'title' => 'ICON_TOPIC', + 'hidden' => false, + 'classes' => '', + 'attributes' => [], + ], + [ + 'ICON_TOPIC' => 'Topic icon', + ], + '<i class="o-icon o-icon-font fa-file"></i> + <span>Topic icon</span>', + ], + /** Iconify: default */ + [ + [ + 'type' => 'iconify', + 'icon' => 'fa:phone', + 'title' => '', + 'hidden' => false, + 'classes' => '', + 'attributes' => [], + ], + [], + '<i class="iconify o-icon-src-fa o-icon" data-icon="fa:phone" data-inline="true"></i>', + ], + /** Iconify: all options */ + [ + [ + 'type' => 'iconify', + 'icon' => 'mdi:pencil', + 'title' => 'ICON_PENCIL', + 'hidden' => true, + 'classes' => 'icon-lg', + 'attributes' => [ + 'style' => 'color: #12a3eb;', + ], + ], + [ + 'ICON_PENCIL' => 'Pencil icon', + ], + '<i class="iconify o-icon-src-mdi o-icon icon-lg" title="Pencil icon" aria-hidden="true" data-icon="mdi:pencil" data-inline="true" style="color: #12a3eb;"></i> + <span class="sr-only">Pencil icon</span>', + ], + /** PNG: default */ + [ + [ + 'type' => 'png', + 'icon' => 'phone', + 'title' => 'ICON_PHONE', + 'hidden' => false, + 'classes' => '', + 'attributes' => [], + ], + [ + 'ICON_PHONE' => 'Phone icon', + ], + '<img class="o-icon o-icon-png png-phone" src="phpBB/styles/chameleon/theme/png/phone.png" alt="Phone icon" />', + ], + /** PNG: all options */ + [ + [ + 'type' => 'png', + 'icon' => 'pencil', + 'title' => 'ICON_PENCIL', + 'hidden' => true, + 'classes' => 'my-class', + 'attributes' => [ + 'data-url' => 'my-test-url/test-page.php?u=2', + ], + ], + [ + 'ICON_PENCIL' => 'Pencil icon', + ], + '<img class="o-icon o-icon-png png-pencil my-class" src="phpBB/styles/chameleon/theme/png/pencil.png" alt="Pencil icon" data-url="my-test-url/test-page.php?u=2" />', + ], + /** PNG: Not found */ + [ + [ + 'type' => 'png', + 'icon' => 'user', + 'title' => 'ICON_USER', + 'hidden' => false, + 'classes' => 'my-class', + 'attributes' => [], + ], + [ + 'ICON_USER' => 'User icon', + ], + '<svg class="o-icon o-icon-svg svg-404 my-class" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" aria-labelledby="icon_user-123456789" role="img"> + <title id="icon_user-123456789">User icon</title> + <g fill="none" fill-rule="evenodd"> + <path fill="#D8D8D8" d="M0 0h512v512H0z"></path> + <path fill="#979797" fill-rule="nonzero" d="M8 6.586l496 496v2.828L8 9.414z"></path> + <path fill="#979797" fill-rule="nonzero" d="M504 7.586v2.828l-496 496v-2.828z"></path> + </g> + </svg>', + ], + /** SVG: default */ + [ + [ + 'type' => 'svg', + 'icon' => 'phone', + 'title' => 'ICON_PHONE', + 'hidden' => false, + 'classes' => '', + 'attributes' => [], + ], + [ + 'ICON_PHONE' => 'Phone icon', + ], + '<svg class="o-icon o-icon-svg svg-phone" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-labelledby="icon_phone-123456789" role="img"> + <title id="icon_phone-123456789">Phone icon</title> + <path fill="none" d="M0 0h24v24H0z"></path> + <path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"></path> + </svg>', + ], + /** SVG: all options */ + [ + [ + 'type' => 'svg', + 'icon' => 'pencil', + 'title' => 'ICON_PENCIL', + 'hidden' => true, + 'classes' => 'my-svg-class', + 'attributes' => [ + 'data-ajax' => 'my_ajax_callback', + ], + ], + [ + 'ICON_PENCIL' => 'Pencil icon', + ], + '<svg class="o-icon o-icon-svg svg-pencil my-svg-class" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" aria-labelledby="icon_pencil-123456789" role="img" data-ajax="my_ajax_callback"> + <title id="icon_pencil-123456789">Pencil icon</title> + <path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"></path> + <path d="M0 0h24v24H0z" fill="none"></path> + </svg>', + ], + /** SVG: Not found */ + [ + [ + 'type' => 'svg', + 'icon' => 'not-existent', + 'title' => 'Just a title', + 'hidden' => false, + 'classes' => '', + 'attributes' => [], + ], + [], + '<svg class="o-icon o-icon-svg svg-404" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" aria-labelledby="just_a_title-123456789" role="img"> + <title id="just_a_title-123456789">Just a title</title> + <g fill="none" fill-rule="evenodd"> + <path fill="#D8D8D8" d="M0 0h512v512H0z"></path> + <path fill="#979797" fill-rule="nonzero" d="M8 6.586l496 496v2.828L8 9.414z"></path> + <path fill="#979797" fill-rule="nonzero" d="M504 7.586v2.828l-496 496v-2.828z"></path> + </g> + </svg>', + ], + /** SVG: Sanitization */ + [ + [ + 'type' => 'svg', + 'icon' => 'dirty', + 'title' => '', + 'hidden' => false, + 'classes' => '', + 'attributes' => [], + ], + [], + '<svg class="o-icon o-icon-svg svg-dirty" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 728 242" role="img"> + <path fill-rule="evenodd" d="M139.05,117.4938 C139.05,129.1958 137.603,139.9498 134.718,149.7578 C131.832,159.5708 127.634,168.0768 122.129,175.2728 C116.623,182.4748 109.764,188.0558 101.554,192.0128 C93.344,195.9698 83.915,197.9538 73.267,197.9538 C65.142,197.9538 57.877,195.9278 51.473,191.8788 C45.064,187.8288 40.057,182.6558 36.45,176.3528 L36.45,240.6138 L25.194,240.6138 C21.976,240.6138 18.85,240.0268 15.811,238.8578 C12.774,237.6858 10.091,236.0228 7.77,233.8638 C5.446,231.7038 3.569,229.0918 2.144,226.0338 C0.713,222.9698 0,219.4608 0,215.5038 L0,127.4828 C0,115.4258 1.393,104.3558 4.185,94.2728 C6.974,84.1948 11.34,75.5548 17.28,68.3538 C23.22,61.1558 30.78,55.5748 39.96,51.6128 C49.14,47.6558 60.117,45.6728 72.9,45.6728 C82.62,45.6728 91.53,47.6978 99.63,51.7488 C107.729,55.7978 114.703,61.1558 120.555,67.8138 C126.402,74.4748 130.95,82.1238 134.19,90.7628 C137.43,99.4038 139.05,108.3128 139.05,117.4938 Z M101.79,126.9438 C101.79,109.6638 98.942,97.1548 93.247,89.4138 C87.552,81.6758 78.831,77.8028 67.087,77.8028 C56.966,77.8028 49.241,81.7178 43.909,89.5478 C38.576,97.3788 35.91,107.5958 35.91,120.1938 C35.91,134.7728 39.205,146.0248 45.803,153.9438 C52.401,161.8658 61.121,165.8238 71.968,165.8238 C80.823,165.8238 88.007,162.2708 93.521,155.1588 C99.031,148.0488 101.79,138.6458 101.79,126.9438 Z M267.5684,194.7134 C260.0084,194.7134 254.0224,192.6464 249.6134,188.5034 C245.2014,184.3644 242.9994,178.3364 242.9994,170.4134 L242.9994,111.0134 C242.9994,105.0734 242.2264,99.9894 240.6914,95.7584 C239.1554,91.5304 237.0754,88.1094 234.4514,85.4984 C231.8274,82.8914 228.7524,80.9544 225.2244,79.6934 C221.6984,78.4364 217.9434,77.8034 213.9644,77.8034 C211.0714,77.8034 208.0844,78.3894 205.0124,79.5584 C201.9374,80.7314 199.0894,82.6634 196.4654,85.3634 C193.8414,88.0634 191.7194,91.5734 190.0904,95.8934 C188.4634,100.2134 187.6484,105.6134 187.6484,112.0934 L187.6484,194.7134 L175.8574,194.7134 C167.2764,194.7134 161.0244,192.5534 157.0914,188.2334 C153.1604,183.9134 151.1984,177.9734 151.1984,170.4134 L151.1984,0.3134 L162.4544,0.3134 C171.0314,0.3134 177.4184,2.4734 181.6204,6.7934 C185.8174,11.1134 187.9194,16.6944 187.9194,23.5334 L188.1884,65.1134 C189.4454,62.9534 191.2014,60.7514 193.4534,58.4984 C195.7024,56.2504 198.1784,54.1784 200.8794,52.2884 C203.5784,50.3984 206.5484,48.8244 209.7894,47.5634 C213.0284,46.3064 216.3574,45.6734 219.7784,45.6734 C238.6784,45.6734 253.3474,51.1194 263.7894,62.0084 C274.2254,72.9014 279.4484,88.6954 279.4484,109.3934 L279.4484,194.7134 L267.5684,194.7134 Z M436.0442,117.4938 C436.0442,129.1958 434.5982,139.9498 431.7122,149.7578 C428.8272,159.5708 424.6282,168.0768 419.1242,175.2728 C413.6182,182.4748 406.7582,188.0558 398.5482,192.0128 C390.3392,195.9698 380.9102,197.9538 370.2622,197.9538 C362.1372,197.9538 354.8722,195.9278 348.4682,191.8788 C342.0592,187.8288 337.0522,182.6558 333.4442,176.3528 L333.4442,240.6138 L322.1882,240.6138 C318.9702,240.6138 315.8442,240.0268 312.8062,238.8578 C309.7682,237.6858 307.0862,236.0228 304.7652,233.8638 C302.4412,231.7038 300.5632,229.0918 299.1382,226.0338 C297.7082,222.9698 296.9942,219.4608 296.9942,215.5038 L296.9942,127.4828 C296.9942,115.4258 298.3872,104.3558 301.1802,94.2728 C303.9682,84.1948 308.3352,75.5548 314.2742,68.3538 C320.2152,61.1558 327.7742,55.5748 336.9542,51.6128 C346.1352,47.6558 357.1112,45.6728 369.8942,45.6728 C379.6142,45.6728 388.5242,47.6978 396.6252,51.7488 C404.7242,55.7978 411.6982,61.1558 417.5502,67.8138 C423.3972,74.4748 427.9442,82.1238 431.1842,90.7628 C434.4252,99.4038 436.0442,108.3128 436.0442,117.4938 Z M398.7842,126.9438 C398.7842,109.6638 395.9362,97.1548 390.2412,89.4138 C384.5462,81.6758 375.8262,77.8028 364.0812,77.8028 C353.9602,77.8028 346.2352,81.7178 340.9032,89.5478 C335.5712,97.3788 332.9042,107.5958 332.9042,120.1938 C332.9042,134.7728 336.1992,146.0248 342.7982,153.9438 C349.3952,161.8658 358.1162,165.8238 368.9622,165.8238 C377.8172,165.8238 385.0022,162.2708 390.5152,155.1588 C396.0252,148.0488 398.7842,138.6458 398.7842,126.9438 Z M581.5745,137.4732 C581.5745,146.8342 579.8615,155.1152 576.4445,162.3132 C573.0225,169.5152 568.3855,175.5892 562.5395,180.5382 C556.6875,185.4912 549.9375,189.2252 542.2895,191.7432 C534.6355,194.2662 526.5835,195.5232 518.1245,195.5232 L498.1435,195.5232 C463.7605,195.5232 446.5745,180.8552 446.5745,151.5132 L446.5745,17.3232 C448.7345,16.6062 451.7925,15.7502 455.7535,14.7582 C459.7105,13.7712 463.9895,12.8262 468.5795,11.9232 C473.1685,11.0252 477.8475,10.3032 482.6195,9.7632 C487.3855,9.2232 491.6645,8.9532 495.4445,8.9532 L517.8535,8.9532 C526.6705,8.9532 534.7715,10.0792 542.1545,12.3282 C549.5325,14.5812 555.9235,17.8212 561.3245,22.0482 C566.7235,26.2802 570.9095,31.4092 573.8785,37.4382 C576.8485,43.4712 578.3345,50.2632 578.3345,57.8232 C578.3345,68.0832 575.7225,76.5002 570.5035,83.0692 C565.2815,89.6412 558.0845,94.2732 548.9045,96.9732 C553.5835,98.2352 557.9025,100.3062 561.8645,103.1832 C565.8215,106.0652 569.2895,109.3512 572.2585,113.0382 C575.2285,116.7302 577.5245,120.7332 579.1435,125.0532 C580.7635,129.3732 581.5745,133.5162 581.5745,137.4732 Z M544.3135,138.5532 C544.3135,128.4752 541.7495,121.5432 536.6195,117.7632 C531.4895,113.9832 523.5245,112.0932 512.7235,112.0932 L483.2935,112.0932 L483.2935,150.1632 C483.2935,153.4042 484.8215,156.1502 487.8835,158.3982 C490.9425,160.6512 494.8115,161.7732 499.4945,161.7732 L514.6145,161.7732 C524.6925,161.7732 532.1645,159.6592 537.0245,155.4282 C541.8835,151.2012 544.3135,145.5742 544.3135,138.5532 Z M541.3435,61.0632 C541.3435,57.1062 540.4875,53.7312 538.7795,50.9382 C537.0665,48.1502 534.8645,45.9432 532.1645,44.3232 C529.4635,42.7032 526.4015,41.5342 522.9845,40.8132 C519.5625,40.0962 516.1415,39.7332 512.7235,39.7332 L498.9545,39.7332 C496.6125,39.7332 494.0005,39.9612 491.1245,40.4082 C488.2425,40.8602 485.5425,41.2642 483.0245,41.6232 L483.0245,83.4732 L511.3745,83.4732 C519.6515,83.4732 526.7175,81.7182 532.5695,78.2082 C538.4165,74.6982 541.3435,68.9862 541.3435,61.0632 Z M727.3733,137.4732 C727.3733,146.8342 725.6603,155.1152 722.2433,162.3132 C718.8213,169.5152 714.1843,175.5892 708.3383,180.5382 C702.4863,185.4912 695.7363,189.2252 688.0883,191.7432 C680.4343,194.2662 672.3823,195.5232 663.9233,195.5232 L643.9423,195.5232 C609.5593,195.5232 592.3733,180.8552 592.3733,151.5132 L592.3733,17.3232 C594.5333,16.6062 597.5913,15.7502 601.5523,14.7582 C605.5093,13.7712 609.7883,12.8262 614.3783,11.9232 C618.9673,11.0252 623.6463,10.3032 628.4183,9.7632 C633.1843,9.2232 637.4633,8.9532 641.2433,8.9532 L663.6523,8.9532 C672.4693,8.9532 680.5703,10.0792 687.9533,12.3282 C695.3313,14.5812 701.7223,17.8212 707.1233,22.0482 C712.5223,26.2802 716.7083,31.4092 719.6773,37.4382 C722.6473,43.4712 724.1333,50.2632 724.1333,57.8232 C724.1333,68.0832 721.5213,76.5002 716.3023,83.0692 C711.0803,89.6412 703.8833,94.2732 694.7033,96.9732 C699.3823,98.2352 703.7013,100.3062 707.6633,103.1832 C711.6203,106.0652 715.0883,109.3512 718.0573,113.0382 C721.0273,116.7302 723.3233,120.7332 724.9423,125.0532 C726.5623,129.3732 727.3733,133.5162 727.3733,137.4732 Z M690.1123,138.5532 C690.1123,128.4752 687.5483,121.5432 682.4183,117.7632 C677.2883,113.9832 669.3233,112.0932 658.5223,112.0932 L629.0923,112.0932 L629.0923,150.1632 C629.0923,153.4042 630.6203,156.1502 633.6823,158.3982 C636.7413,160.6512 640.6103,161.7732 645.2933,161.7732 L660.4133,161.7732 C670.4913,161.7732 677.9633,159.6592 682.8233,155.4282 C687.6823,151.2012 690.1123,145.5742 690.1123,138.5532 Z M687.1423,61.0632 C687.1423,57.1062 686.2863,53.7312 684.5783,50.9382 C682.8653,48.1502 680.6633,45.9432 677.9633,44.3232 C675.2623,42.7032 672.2003,41.5342 668.7833,40.8132 C665.3613,40.0962 661.9403,39.7332 658.5223,39.7332 L644.7533,39.7332 C642.4113,39.7332 639.7993,39.9612 636.9233,40.4082 C634.0413,40.8602 631.3413,41.2642 628.8233,41.6232 L628.8233,83.4732 L657.1733,83.4732 C665.4503,83.4732 672.5163,81.7182 678.3683,78.2082 C684.2153,74.6982 687.1423,68.9862 687.1423,61.0632z"></path> + </svg>', + ], + ]; + } + + /** + * @dataProvider data_template_icon_extension + */ + public function test_template_icon_extension($vars, $lang_vars, $expected) + { + $file = 'extension_icon_test.html'; + + $this->template->set_filenames(['test' => $file]); + $this->template->assign_vars($vars); + + foreach ($lang_vars as $name => $value) + { + self::$language_reflection_lang->setValue($this->lang, array_merge( + self::$language_reflection_lang->getValue($this->lang), + [$name => $value] + )); + } + + $expected = str_replace(["\n", "\r", "\t"], '', $expected); + $output = str_replace(["\n", "\r", "\t"], '', $this->display('test')); + + /** + * SVGs need their random identifier replaced (normalized). + * The 'user' is a PNG, but not existent, so it returns a 404 SVG. + */ + if ($vars['type'] === 'svg' || $vars['icon'] === 'user') + { + $prefix = strtolower(str_replace(' ', '_', $vars['title'])) . '-'; + $output = preg_replace('/' . $prefix . '\d+/', $prefix . '123456789', $output); + } + + $this->assertEquals($expected, $output, "Testing {$file}"); + } } diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php index 722e10e42d..baf2eed11b 100644 --- a/tests/template/includephp_test.php +++ b/tests/template/includephp_test.php @@ -11,6 +11,8 @@ * */ +use phpbb\filesystem\helper as filesystem_helper; + require_once dirname(__FILE__) . '/template_test_case.php'; class phpbb_template_includephp_test extends phpbb_template_template_test_case @@ -39,9 +41,8 @@ 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($filesystem->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 -->"; $cache_dir = $phpbb_root_path . 'cache/'; diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php index a9a8ecc287..de4d663fb8 100644 --- a/tests/template/template_allfolder_test.php +++ b/tests/template/template_allfolder_test.php @@ -39,7 +39,6 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - $filesystem, $this->createMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -59,7 +58,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(new \phpbb\filesystem\filesystem(), ''); + $loader = new \phpbb\template\twig\loader(''); $twig = new \phpbb\template\twig\environment( $config, $filesystem, diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php index 9243390937..7693e84db9 100644 --- a/tests/template/template_events_test.php +++ b/tests/template/template_events_test.php @@ -144,7 +144,6 @@ Zeta test event in all', new \phpbb\symfony_request( new phpbb_mock_request() ), - new \phpbb\filesystem\filesystem(), $this->createMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -153,7 +152,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(new \phpbb\filesystem\filesystem(), ''); + $loader = new \phpbb\template\twig\loader(''); $twig = new \phpbb\template\twig\environment( $config, $filesystem, diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php index 5f9875a556..9f90a00b1a 100644 --- a/tests/template/template_includecss_test.php +++ b/tests/template/template_includecss_test.php @@ -34,7 +34,6 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te new \phpbb\symfony_request( new phpbb_mock_request() ), - $filesystem, $this->createMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -45,7 +44,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(new \phpbb\filesystem\filesystem(), ''); + $loader = new \phpbb\template\twig\loader(''); $twig = new \phpbb\template\twig\environment( $config, $filesystem, diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 0389088ec8..3a64d70f30 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -86,7 +86,6 @@ class phpbb_template_template_test_case extends phpbb_test_case new \phpbb\symfony_request( new phpbb_mock_request() ), - $filesystem, $this->createMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -97,7 +96,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(new \phpbb\filesystem\filesystem(), ''); + $loader = new \phpbb\template\twig\loader(''); $twig = new \phpbb\template\twig\environment( $config, $filesystem, diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index c0238b6f03..d21baa3fd4 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -28,7 +28,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat new \phpbb\symfony_request( new phpbb_mock_request() ), - $filesystem, $this->createMock('\phpbb\request\request'), $phpbb_root_path, $phpEx @@ -40,7 +39,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(new \phpbb\filesystem\filesystem(), ''); + $loader = new \phpbb\template\twig\loader(''); $twig = new \phpbb\template\twig\environment( $config, $filesystem, diff --git a/tests/template/templates/extension_icon_test.html b/tests/template/templates/extension_icon_test.html new file mode 100644 index 0000000000..4ea6eb0410 --- /dev/null +++ b/tests/template/templates/extension_icon_test.html @@ -0,0 +1 @@ +{{ Icon(type, icon, title, hidden, classes, attributes) }} diff --git a/tests/template/templates/svg/dirty.svg b/tests/template/templates/svg/dirty.svg new file mode 100644 index 0000000000..29c1500ffe --- /dev/null +++ b/tests/template/templates/svg/dirty.svg @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" > +<svg viewBox="0 0 728 242" xmlns="http://www.w3.org/2000/svg" class="c-hero-logo t-hero-logo" aria-labelledby="site_title"> + <title id="site_title">phpBB</title> + <path fill-rule="evenodd" d="M139.05,117.4938 C139.05,129.1958 137.603,139.9498 134.718,149.7578 C131.832,159.5708 127.634,168.0768 122.129,175.2728 C116.623,182.4748 109.764,188.0558 101.554,192.0128 C93.344,195.9698 83.915,197.9538 73.267,197.9538 C65.142,197.9538 57.877,195.9278 51.473,191.8788 C45.064,187.8288 40.057,182.6558 36.45,176.3528 L36.45,240.6138 L25.194,240.6138 C21.976,240.6138 18.85,240.0268 15.811,238.8578 C12.774,237.6858 10.091,236.0228 7.77,233.8638 C5.446,231.7038 3.569,229.0918 2.144,226.0338 C0.713,222.9698 0,219.4608 0,215.5038 L0,127.4828 C0,115.4258 1.393,104.3558 4.185,94.2728 C6.974,84.1948 11.34,75.5548 17.28,68.3538 C23.22,61.1558 30.78,55.5748 39.96,51.6128 C49.14,47.6558 60.117,45.6728 72.9,45.6728 C82.62,45.6728 91.53,47.6978 99.63,51.7488 C107.729,55.7978 114.703,61.1558 120.555,67.8138 C126.402,74.4748 130.95,82.1238 134.19,90.7628 C137.43,99.4038 139.05,108.3128 139.05,117.4938 Z M101.79,126.9438 C101.79,109.6638 98.942,97.1548 93.247,89.4138 C87.552,81.6758 78.831,77.8028 67.087,77.8028 C56.966,77.8028 49.241,81.7178 43.909,89.5478 C38.576,97.3788 35.91,107.5958 35.91,120.1938 C35.91,134.7728 39.205,146.0248 45.803,153.9438 C52.401,161.8658 61.121,165.8238 71.968,165.8238 C80.823,165.8238 88.007,162.2708 93.521,155.1588 C99.031,148.0488 101.79,138.6458 101.79,126.9438 Z M267.5684,194.7134 C260.0084,194.7134 254.0224,192.6464 249.6134,188.5034 C245.2014,184.3644 242.9994,178.3364 242.9994,170.4134 L242.9994,111.0134 C242.9994,105.0734 242.2264,99.9894 240.6914,95.7584 C239.1554,91.5304 237.0754,88.1094 234.4514,85.4984 C231.8274,82.8914 228.7524,80.9544 225.2244,79.6934 C221.6984,78.4364 217.9434,77.8034 213.9644,77.8034 C211.0714,77.8034 208.0844,78.3894 205.0124,79.5584 C201.9374,80.7314 199.0894,82.6634 196.4654,85.3634 C193.8414,88.0634 191.7194,91.5734 190.0904,95.8934 C188.4634,100.2134 187.6484,105.6134 187.6484,112.0934 L187.6484,194.7134 L175.8574,194.7134 C167.2764,194.7134 161.0244,192.5534 157.0914,188.2334 C153.1604,183.9134 151.1984,177.9734 151.1984,170.4134 L151.1984,0.3134 L162.4544,0.3134 C171.0314,0.3134 177.4184,2.4734 181.6204,6.7934 C185.8174,11.1134 187.9194,16.6944 187.9194,23.5334 L188.1884,65.1134 C189.4454,62.9534 191.2014,60.7514 193.4534,58.4984 C195.7024,56.2504 198.1784,54.1784 200.8794,52.2884 C203.5784,50.3984 206.5484,48.8244 209.7894,47.5634 C213.0284,46.3064 216.3574,45.6734 219.7784,45.6734 C238.6784,45.6734 253.3474,51.1194 263.7894,62.0084 C274.2254,72.9014 279.4484,88.6954 279.4484,109.3934 L279.4484,194.7134 L267.5684,194.7134 Z M436.0442,117.4938 C436.0442,129.1958 434.5982,139.9498 431.7122,149.7578 C428.8272,159.5708 424.6282,168.0768 419.1242,175.2728 C413.6182,182.4748 406.7582,188.0558 398.5482,192.0128 C390.3392,195.9698 380.9102,197.9538 370.2622,197.9538 C362.1372,197.9538 354.8722,195.9278 348.4682,191.8788 C342.0592,187.8288 337.0522,182.6558 333.4442,176.3528 L333.4442,240.6138 L322.1882,240.6138 C318.9702,240.6138 315.8442,240.0268 312.8062,238.8578 C309.7682,237.6858 307.0862,236.0228 304.7652,233.8638 C302.4412,231.7038 300.5632,229.0918 299.1382,226.0338 C297.7082,222.9698 296.9942,219.4608 296.9942,215.5038 L296.9942,127.4828 C296.9942,115.4258 298.3872,104.3558 301.1802,94.2728 C303.9682,84.1948 308.3352,75.5548 314.2742,68.3538 C320.2152,61.1558 327.7742,55.5748 336.9542,51.6128 C346.1352,47.6558 357.1112,45.6728 369.8942,45.6728 C379.6142,45.6728 388.5242,47.6978 396.6252,51.7488 C404.7242,55.7978 411.6982,61.1558 417.5502,67.8138 C423.3972,74.4748 427.9442,82.1238 431.1842,90.7628 C434.4252,99.4038 436.0442,108.3128 436.0442,117.4938 Z M398.7842,126.9438 C398.7842,109.6638 395.9362,97.1548 390.2412,89.4138 C384.5462,81.6758 375.8262,77.8028 364.0812,77.8028 C353.9602,77.8028 346.2352,81.7178 340.9032,89.5478 C335.5712,97.3788 332.9042,107.5958 332.9042,120.1938 C332.9042,134.7728 336.1992,146.0248 342.7982,153.9438 C349.3952,161.8658 358.1162,165.8238 368.9622,165.8238 C377.8172,165.8238 385.0022,162.2708 390.5152,155.1588 C396.0252,148.0488 398.7842,138.6458 398.7842,126.9438 Z M581.5745,137.4732 C581.5745,146.8342 579.8615,155.1152 576.4445,162.3132 C573.0225,169.5152 568.3855,175.5892 562.5395,180.5382 C556.6875,185.4912 549.9375,189.2252 542.2895,191.7432 C534.6355,194.2662 526.5835,195.5232 518.1245,195.5232 L498.1435,195.5232 C463.7605,195.5232 446.5745,180.8552 446.5745,151.5132 L446.5745,17.3232 C448.7345,16.6062 451.7925,15.7502 455.7535,14.7582 C459.7105,13.7712 463.9895,12.8262 468.5795,11.9232 C473.1685,11.0252 477.8475,10.3032 482.6195,9.7632 C487.3855,9.2232 491.6645,8.9532 495.4445,8.9532 L517.8535,8.9532 C526.6705,8.9532 534.7715,10.0792 542.1545,12.3282 C549.5325,14.5812 555.9235,17.8212 561.3245,22.0482 C566.7235,26.2802 570.9095,31.4092 573.8785,37.4382 C576.8485,43.4712 578.3345,50.2632 578.3345,57.8232 C578.3345,68.0832 575.7225,76.5002 570.5035,83.0692 C565.2815,89.6412 558.0845,94.2732 548.9045,96.9732 C553.5835,98.2352 557.9025,100.3062 561.8645,103.1832 C565.8215,106.0652 569.2895,109.3512 572.2585,113.0382 C575.2285,116.7302 577.5245,120.7332 579.1435,125.0532 C580.7635,129.3732 581.5745,133.5162 581.5745,137.4732 Z M544.3135,138.5532 C544.3135,128.4752 541.7495,121.5432 536.6195,117.7632 C531.4895,113.9832 523.5245,112.0932 512.7235,112.0932 L483.2935,112.0932 L483.2935,150.1632 C483.2935,153.4042 484.8215,156.1502 487.8835,158.3982 C490.9425,160.6512 494.8115,161.7732 499.4945,161.7732 L514.6145,161.7732 C524.6925,161.7732 532.1645,159.6592 537.0245,155.4282 C541.8835,151.2012 544.3135,145.5742 544.3135,138.5532 Z M541.3435,61.0632 C541.3435,57.1062 540.4875,53.7312 538.7795,50.9382 C537.0665,48.1502 534.8645,45.9432 532.1645,44.3232 C529.4635,42.7032 526.4015,41.5342 522.9845,40.8132 C519.5625,40.0962 516.1415,39.7332 512.7235,39.7332 L498.9545,39.7332 C496.6125,39.7332 494.0005,39.9612 491.1245,40.4082 C488.2425,40.8602 485.5425,41.2642 483.0245,41.6232 L483.0245,83.4732 L511.3745,83.4732 C519.6515,83.4732 526.7175,81.7182 532.5695,78.2082 C538.4165,74.6982 541.3435,68.9862 541.3435,61.0632 Z M727.3733,137.4732 C727.3733,146.8342 725.6603,155.1152 722.2433,162.3132 C718.8213,169.5152 714.1843,175.5892 708.3383,180.5382 C702.4863,185.4912 695.7363,189.2252 688.0883,191.7432 C680.4343,194.2662 672.3823,195.5232 663.9233,195.5232 L643.9423,195.5232 C609.5593,195.5232 592.3733,180.8552 592.3733,151.5132 L592.3733,17.3232 C594.5333,16.6062 597.5913,15.7502 601.5523,14.7582 C605.5093,13.7712 609.7883,12.8262 614.3783,11.9232 C618.9673,11.0252 623.6463,10.3032 628.4183,9.7632 C633.1843,9.2232 637.4633,8.9532 641.2433,8.9532 L663.6523,8.9532 C672.4693,8.9532 680.5703,10.0792 687.9533,12.3282 C695.3313,14.5812 701.7223,17.8212 707.1233,22.0482 C712.5223,26.2802 716.7083,31.4092 719.6773,37.4382 C722.6473,43.4712 724.1333,50.2632 724.1333,57.8232 C724.1333,68.0832 721.5213,76.5002 716.3023,83.0692 C711.0803,89.6412 703.8833,94.2732 694.7033,96.9732 C699.3823,98.2352 703.7013,100.3062 707.6633,103.1832 C711.6203,106.0652 715.0883,109.3512 718.0573,113.0382 C721.0273,116.7302 723.3233,120.7332 724.9423,125.0532 C726.5623,129.3732 727.3733,133.5162 727.3733,137.4732 Z M690.1123,138.5532 C690.1123,128.4752 687.5483,121.5432 682.4183,117.7632 C677.2883,113.9832 669.3233,112.0932 658.5223,112.0932 L629.0923,112.0932 L629.0923,150.1632 C629.0923,153.4042 630.6203,156.1502 633.6823,158.3982 C636.7413,160.6512 640.6103,161.7732 645.2933,161.7732 L660.4133,161.7732 C670.4913,161.7732 677.9633,159.6592 682.8233,155.4282 C687.6823,151.2012 690.1123,145.5742 690.1123,138.5532 Z M687.1423,61.0632 C687.1423,57.1062 686.2863,53.7312 684.5783,50.9382 C682.8653,48.1502 680.6633,45.9432 677.9633,44.3232 C675.2623,42.7032 672.2003,41.5342 668.7833,40.8132 C665.3613,40.0962 661.9403,39.7332 658.5223,39.7332 L644.7533,39.7332 C642.4113,39.7332 639.7993,39.9612 636.9233,40.4082 C634.0413,40.8602 631.3413,41.2642 628.8233,41.6232 L628.8233,83.4732 L657.1733,83.4732 C665.4503,83.4732 672.5163,81.7182 678.3683,78.2082 C684.2153,74.6982 687.1423,68.9862 687.1423,61.0632z"></path> +</svg> diff --git a/tests/template/templates/svg/pencil.svg b/tests/template/templates/svg/pencil.svg new file mode 100644 index 0000000000..c9c021d811 --- /dev/null +++ b/tests/template/templates/svg/pencil.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><title>My fake title!</title><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/><path d="M0 0h24v24H0z" fill="none"/></svg> diff --git a/tests/template/templates/svg/phone.svg b/tests/template/templates/svg/phone.svg new file mode 100644 index 0000000000..5fbfe196ba --- /dev/null +++ b/tests/template/templates/svg/phone.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"/></svg> diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 9b873fbf68..5ef545781c 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -60,7 +60,7 @@ abstract class phpbb_database_test_case extends TestCase $setup_extensions = static::setup_extensions(); - $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx); + $finder = new \phpbb\finder($phpbb_root_path, null, $phpEx); $finder->core_path('phpbb/db/migration/data/'); if (!empty($setup_extensions)) { @@ -75,14 +75,13 @@ abstract class phpbb_database_test_case extends TestCase if (!file_exists(self::$schema_file)) { - global $table_prefix; $db = new \phpbb\db\driver\sqlite3(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($db, true); - $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix); + $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix, self::get_core_tables()); file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema())); } @@ -353,4 +352,23 @@ abstract class phpbb_database_test_case extends TestCase $this->assertTrue(true); } } + + static public function get_core_tables() : array + { + global $phpbb_root_path, $table_prefix; + + static $core_tables = []; + + if (empty($tables)) + { + $tables_yml_data = \Symfony\Component\Yaml\Yaml::parseFile($phpbb_root_path . '/config/default/container/tables.yml'); + + foreach ($tables_yml_data['parameters'] as $parameter => $table) + { + $core_tables[str_replace('tables.', '', $parameter)] = str_replace('%core.table_prefix%', $table_prefix, $table); + } + } + + return $core_tables; + } } diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index fec4709fbd..e4c1a194cc 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -365,15 +365,16 @@ class phpbb_database_test_connection_manager { global $phpbb_root_path, $phpEx, $table_prefix; - $finder = new \phpbb\finder(new \phpbb\filesystem\filesystem(), $phpbb_root_path, null, $phpEx); + $finder = new \phpbb\finder($phpbb_root_path, null, $phpEx); $classes = $finder->core_path('phpbb/db/migration/data/') ->get_classes(); $db = new \phpbb\db\driver\sqlite3(); $factory = new \phpbb\db\tools\factory(); $db_tools = $factory->get($db, true); + $tables = phpbb_database_test_case::get_core_tables(); - $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix); + $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, $db_tools, $phpbb_root_path, $phpEx, $table_prefix, $tables); $db_table_schema = $schema_generator->get_schema(); } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 19062aa148..4f7271e313 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -249,6 +249,7 @@ class phpbb_functional_test_case extends phpbb_test_case $phpbb_root_path, $phpEx, self::$config['table_prefix'], + phpbb_database_test_case::get_core_tables(), array(), new \phpbb\db\migration\helper() ); @@ -259,7 +260,6 @@ class phpbb_functional_test_case extends phpbb_test_case $container, $db, $config, - new phpbb\filesystem\filesystem(), self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', $phpEx, diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php index 530d8c6b48..18da5e9b08 100644 --- a/tests/test_framework/phpbb_session_test_case.php +++ b/tests/test_framework/phpbb_session_test_case.php @@ -29,14 +29,12 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case { parent::setUp(); - global $symfony_request, $phpbb_filesystem, $phpbb_path_helper, $request, $phpbb_root_path, $phpEx; + global $symfony_request, $phpbb_path_helper, $request, $phpbb_root_path, $phpEx; $symfony_request = new \phpbb\symfony_request( new phpbb_mock_request() ); - $phpbb_filesystem = new \phpbb\filesystem\filesystem(); $phpbb_path_helper = new \phpbb\path_helper( $symfony_request, - $phpbb_filesystem, $this->createMock('\phpbb\request\request'), $phpbb_root_path, $phpEx diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php index 243db39d69..1fbfd22dbe 100644 --- a/tests/test_framework/phpbb_ui_test_case.php +++ b/tests/test_framework/phpbb_ui_test_case.php @@ -486,6 +486,7 @@ class phpbb_ui_test_case extends phpbb_test_case $phpbb_root_path, $phpEx, self::$config['table_prefix'], + phpbb_database_test_case::get_core_tables(), array(), new \phpbb\db\migration\helper() ); @@ -497,7 +498,6 @@ class phpbb_ui_test_case extends phpbb_test_case $container, $db, $config, - new phpbb\filesystem(), $user, self::$config['table_prefix'] . 'ext', dirname(__FILE__) . '/', |