aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/RUNNING_TESTS.md5
-rw-r--r--tests/avatar/driver/barfoo.php52
-rw-r--r--tests/avatar/driver/foobar.php52
-rw-r--r--tests/bootstrap.php2
-rw-r--r--tests/console/cron/run_test.php1
-rw-r--r--tests/content_visibility/delete_post_test.php10
-rw-r--r--tests/controller/common_helper_route.php82
-rw-r--r--tests/controller/config/test/routing/environment.yml (renamed from tests/controller/config/routing.yml)0
-rw-r--r--tests/controller/controller_test.php16
-rw-r--r--tests/controller/ext/vendor2/bar/config/services.yml3
-rw-r--r--tests/controller/ext/vendor2/bar/config/test/routing/environment.yml3
-rw-r--r--tests/controller/ext/vendor2/bar/controller.php18
-rw-r--r--tests/dbal/auto_increment_test.php3
-rw-r--r--tests/dbal/db_tools_test.php9
-rw-r--r--tests/dbal/migrator_test.php3
-rw-r--r--tests/dbal/migrator_tool_module_test.php2
-rw-r--r--tests/di/create_container_test.php8
-rw-r--r--tests/di/fixtures/config/test/config.yml2
-rw-r--r--tests/di/fixtures/config/test/container/environment.yml (renamed from tests/di/fixtures/config/services.yml)0
-rw-r--r--tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml (renamed from tests/di/fixtures/ext/vendor/disabled/config/services.yml)0
-rw-r--r--tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml2
-rw-r--r--tests/di/fixtures/ext/vendor/enabled-3/config/services.yml2
-rw-r--r--tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml (renamed from tests/di/fixtures/ext/vendor/enabled/config/services.yml)0
-rw-r--r--tests/di/fixtures/ext/vendor/enabled_4/di/extension.php31
-rw-r--r--tests/di/fixtures/ext/vendor/enabled_4/environment.yml2
-rw-r--r--tests/di/fixtures/other_config/test/config.yml2
-rw-r--r--tests/di/fixtures/other_config/test/container/environment.yml (renamed from tests/di/fixtures/other_config/services.yml)0
-rw-r--r--tests/event/md_exporter_test.php1
-rw-r--r--tests/extension/ext/vendor2/bar/acp/a_info.php1
-rw-r--r--tests/extension/ext/vendor2/foo/acp/a_info.php1
-rw-r--r--tests/extension/ext/vendor2/foo/acp/fail_info.php1
-rw-r--r--tests/extension/ext/vendor2/foo/mcp/a_info.php1
-rw-r--r--tests/extension/includes/acp/info/acp_foobar.php1
-rw-r--r--tests/extension/manager_test.php3
-rw-r--r--tests/extension/metadata_manager_test.php40
-rw-r--r--tests/extension/modules_test.php10
-rw-r--r--tests/functional/fixtures/ext/foo/bar/acp/main_info.php1
-rw-r--r--tests/functional/fixtures/ext/foo/bar/ucp/main_info.php1
-rw-r--r--tests/functions/get_remote_file_test.php2
-rw-r--r--tests/functions_user/delete_user_test.php2
-rw-r--r--tests/lock/db_test.php1
-rw-r--r--tests/log/function_add_log_test.php2
-rw-r--r--tests/migrator/convert_timezones_test.php9
-rw-r--r--tests/migrator/schema_generator_test.php3
-rw-r--r--tests/mock/controller_helper.php5
-rw-r--r--tests/mock/router.php27
-rw-r--r--tests/notification/convert_test.php3
-rw-r--r--tests/notification/group_request_test.php2
-rw-r--r--tests/notification/submit_post_base.php2
-rw-r--r--tests/notification/user_list_trim_test.php2
-rw-r--r--tests/pagination/config/test/routing/environment.yml (renamed from tests/pagination/config/routing.yml)0
-rw-r--r--tests/pagination/pagination_test.php14
-rw-r--r--tests/request/request_var_test.php2
-rw-r--r--tests/session/testable_factory.php3
-rw-r--r--tests/template/template_allfolder_test.php22
-rw-r--r--tests/template/template_events_test.php23
-rw-r--r--tests/template/template_includecss_test.php41
-rw-r--r--tests/template/template_test.php157
-rw-r--r--tests/template/template_test_case.php22
-rw-r--r--tests/template/template_test_case_with_tree.php22
-rw-r--r--tests/template/templates/loop_advanced_twig.html19
-rw-r--r--tests/template/templates/loop_expressions.html4
-rw-r--r--tests/template/templates/loop_expressions_twig.html11
-rw-r--r--tests/template/templates/loop_expressions_twig2.html11
-rw-r--r--tests/template/templates/loop_include1_twig.html1
-rw-r--r--tests/template/templates/loop_include_twig.html4
-rw-r--r--tests/template/templates/loop_nested2_twig.html6
-rw-r--r--tests/template/templates/loop_nested_deep_multilevel_ref_twig.html13
-rw-r--r--tests/template/templates/loop_nested_include1_twig.html5
-rw-r--r--tests/template/templates/loop_nested_include_twig.html4
-rw-r--r--tests/template/templates/loop_nested_multilevel_ref_twig.html10
-rw-r--r--tests/template/templates/loop_nested_twig.html6
-rw-r--r--tests/template/templates/loop_reuse_twig.html6
-rw-r--r--tests/template/templates/loop_size_twig.html39
-rw-r--r--tests/template/templates/loop_twig.html21
-rw-r--r--tests/template/templates/loop_underscore_twig.html21
-rw-r--r--tests/template/templates/loop_vars_twig.html13
-rw-r--r--tests/test_framework/phpbb_database_test_case.php5
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php8
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php18
-rw-r--r--tests/tree/nestedset_forum_base.php1
-rw-r--r--tests/utf/normalizer_test.php327
82 files changed, 772 insertions, 518 deletions
diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md
index afd7caa709..b082197166 100644
--- a/tests/RUNNING_TESTS.md
+++ b/tests/RUNNING_TESTS.md
@@ -120,8 +120,9 @@ directory (above phpBB):
Slow tests
--------------
-Certain tests, such as the UTF-8 normalizer or the DNS tests tend to be slow.
-Thus these tests are in the `slow` group, which is excluded by default. If you
+Certain tests, such as the DNS tests tend to be slow.
+Thus these tests are in the `slow` group, which is excluded by default. You can
+enable slow tests by copying the phpunit.xml.all file to phpunit.xml. If you
only want the slow tests, run:
$ phpBB/vendor/bin/phpunit --group slow
diff --git a/tests/avatar/driver/barfoo.php b/tests/avatar/driver/barfoo.php
index 0bf30b8a91..067bb3ef97 100644
--- a/tests/avatar/driver/barfoo.php
+++ b/tests/avatar/driver/barfoo.php
@@ -1,26 +1,26 @@
-<?php
-
-namespace phpbb\avatar\driver;
-
-class barfoo extends \phpbb\avatar\driver\driver
-{
- public function get_data($row)
- {
- return array();
- }
-
- public function prepare_form($request, $template, $user, $row, &$error)
- {
- return false;
- }
-
- public function process_form($request, $template, $user, $row, &$error)
- {
- return false;
- }
-
- public function get_template_name()
- {
- return 'barfoo.html';
- }
-}
+<?php
+
+namespace phpbb\avatar\driver;
+
+class barfoo extends \phpbb\avatar\driver\driver
+{
+ public function get_data($row)
+ {
+ return array();
+ }
+
+ public function prepare_form($request, $template, $user, $row, &$error)
+ {
+ return false;
+ }
+
+ public function process_form($request, $template, $user, $row, &$error)
+ {
+ return false;
+ }
+
+ public function get_template_name()
+ {
+ return 'barfoo.html';
+ }
+}
diff --git a/tests/avatar/driver/foobar.php b/tests/avatar/driver/foobar.php
index aabdaf5ac4..16d50ccad4 100644
--- a/tests/avatar/driver/foobar.php
+++ b/tests/avatar/driver/foobar.php
@@ -1,26 +1,26 @@
-<?php
-
-namespace phpbb\avatar\driver;
-
-class foobar extends \phpbb\avatar\driver\driver
-{
- public function get_data($row)
- {
- return array();
- }
-
- public function prepare_form($request, $template, $user, $row, &$error)
- {
- return false;
- }
-
- public function process_form($request, $template, $user, $row, &$error)
- {
- return false;
- }
-
- public function get_template_name()
- {
- return 'foobar.html';
- }
-}
+<?php
+
+namespace phpbb\avatar\driver;
+
+class foobar extends \phpbb\avatar\driver\driver
+{
+ public function get_data($row)
+ {
+ return array();
+ }
+
+ public function prepare_form($request, $template, $user, $row, &$error)
+ {
+ return false;
+ }
+
+ public function process_form($request, $template, $user, $row, &$error)
+ {
+ return false;
+ }
+
+ public function get_template_name()
+ {
+ return 'foobar.html';
+ }
+}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 0e81f4372a..ace48ea035 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -12,6 +12,8 @@
*/
define('IN_PHPBB', true);
+define('PHPBB_ENVIRONMENT', 'test');
+
$phpbb_root_path = 'phpBB/';
$phpEx = 'php';
require_once $phpbb_root_path . 'includes/startup.php';
diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php
index f76e967484..8638648898 100644
--- a/tests/console/cron/run_test.php
+++ b/tests/console/cron/run_test.php
@@ -39,7 +39,6 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$db = $this->db = $this->new_dbal();
$config = $this->config = new \phpbb\config\config(array('cron_lock' => '0'));
- set_config(null, null, null, $this->config);
$this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db);
$this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php
index 6ad6351a0c..dc966c37ae 100644
--- a/tests/content_visibility/delete_post_test.php
+++ b/tests/content_visibility/delete_post_test.php
@@ -292,12 +292,14 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
- $config['search_type'] = 'phpbb_mock_search';
+ $config = new \phpbb\config\config(array(
+ 'num_posts' => 3,
+ 'num_topics' => 1,
+ 'search_type' => 'phpbb_mock_search',
+ ));
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- set_config_count(null, null, null, $phpbb_config);
// Create auth mock
$auth = $this->getMock('\phpbb\auth\auth');
@@ -313,7 +315,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
- $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
+ $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason);
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index 6723e3bc52..3f98d51f16 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -35,10 +35,6 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
);
$this->generate_route_objects();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
- $this->user = new \phpbb\user('\phpbb\datetime');
-
- $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
- $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context());
}
protected function get_phpbb_root_path()
@@ -82,15 +78,44 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
$phpEx
);
- $finder = new \phpbb\finder(
- new \phpbb\filesystem(),
+ $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
+ $this->user = new \phpbb\user('\phpbb\datetime');
+
+ $container = new phpbb_mock_container_builder();
+ $cache_path = $phpbb_root_path . 'cache/twig';
+ $context = new \phpbb\template\context();
+ $loader = new \phpbb\template\twig\loader('');
+ $twig = new \phpbb\template\twig\environment(
+ $this->config,
+ $this->phpbb_path_helper,
+ $container,
+ $cache_path,
+ null,
+ $loader,
+ array(
+ 'cache' => false,
+ 'debug' => false,
+ 'auto_reload' => true,
+ 'autoescape' => false,
+ )
+ );
+ $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
+
+ $this->extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
- new phpbb_mock_cache()
+ array(
+ 'vendor2/foo' => array(
+ 'ext_name' => 'vendor2/foo',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/vendor2/foo/',
+ ),
+ )
);
- $finder->set_extensions(array_keys($this->extension_manager->all_enabled()));
- $this->provider = new \phpbb\controller\provider();
- $this->provider->find_routing_files($finder);
- $this->provider->find(dirname(__FILE__) . '/');
+
+ $this->router = new phpbb_mock_router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $this->router->find_routing_files($this->extension_manager->all_enabled(false));
+ $this->router->find(dirname(__FILE__) . '/');
// Set correct current phpBB root path
$this->root_path = $this->get_phpbb_root_path();
}
@@ -130,8 +155,9 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
+ $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
}
public function helper_url_data_with_rewrite()
@@ -170,8 +196,8 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
}
public function helper_url_data_absolute()
@@ -210,8 +236,8 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL));
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
}
public function helper_url_data_relative_path()
@@ -250,8 +276,8 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH));
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
}
public function helper_url_data_network()
@@ -290,10 +316,10 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH));
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
}
-//TODO
+
public function helper_url_data_absolute_with_rewrite()
{
return array(
@@ -330,8 +356,8 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL));
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
}
public function helper_url_data_relative_path_with_rewrite()
@@ -370,8 +396,8 @@ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH));
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
}
public function helper_url_data_network_with_rewrite()
@@ -410,7 +436,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(array('enable_mod_rewrite' => '1'));
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
- $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH));
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->router, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
}
}
diff --git a/tests/controller/config/routing.yml b/tests/controller/config/test/routing/environment.yml
index 1e7df02684..1e7df02684 100644
--- a/tests/controller/config/routing.yml
+++ b/tests/controller/config/test/routing/environment.yml
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 62feee3fed..86615fe4dc 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -30,14 +30,19 @@ class phpbb_controller_controller_test extends phpbb_test_case
'ext_active' => '1',
'ext_path' => 'ext/vendor2/foo/',
),
+ 'vendor2/bar' => array(
+ 'ext_name' => 'vendor2/bar',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/vendor2/bar/',
+ ),
));
}
- public function test_provider()
+ public function test_router_find_files()
{
- $provider = new \phpbb\controller\provider();
- $provider->find_routing_files($this->extension_manager->get_finder());
- $routes = $provider->find(__DIR__)->get_routes();
+ $router = new \phpbb\routing\router($this->extension_manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $router->find_routing_files($this->extension_manager->all_enabled(false));
+ $routes = $router->find(__DIR__)->get_routes();
// This will need to be updated if any new routes are defined
$this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('core_controller'));
@@ -49,6 +54,9 @@ class phpbb_controller_controller_test extends phpbb_test_case
$this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller2'));
$this->assertEquals('/foo/bar', $routes->get('controller2')->getPath());
+ $this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('controller3'));
+ $this->assertEquals('/bar', $routes->get('controller3')->getPath());
+
$this->assertNull($routes->get('controller_noroute'));
}
diff --git a/tests/controller/ext/vendor2/bar/config/services.yml b/tests/controller/ext/vendor2/bar/config/services.yml
new file mode 100644
index 0000000000..05a8a1994d
--- /dev/null
+++ b/tests/controller/ext/vendor2/bar/config/services.yml
@@ -0,0 +1,3 @@
+services:
+ bar.controller:
+ class: bar\controller
diff --git a/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml
new file mode 100644
index 0000000000..5696ecb180
--- /dev/null
+++ b/tests/controller/ext/vendor2/bar/config/test/routing/environment.yml
@@ -0,0 +1,3 @@
+controller3:
+ path: /bar
+ defaults: { _controller: bar.controller:handle }
diff --git a/tests/controller/ext/vendor2/bar/controller.php b/tests/controller/ext/vendor2/bar/controller.php
new file mode 100644
index 0000000000..ad35f5a051
--- /dev/null
+++ b/tests/controller/ext/vendor2/bar/controller.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace bar;
+
+use Symfony\Component\HttpFoundation\Response;
+
+class controller
+{
+ /**
+ * Handle method
+ *
+ * @return null
+ */
+ public function handle()
+ {
+ return new Response('Test', 200);
+ }
+}
diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php
index 1ed8ea29e3..39eb6835ff 100644
--- a/tests/dbal/auto_increment_test.php
+++ b/tests/dbal/auto_increment_test.php
@@ -30,7 +30,8 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
parent::setUp();
$this->db = $this->new_dbal();
- $this->tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $this->tools = $factory->get($this->db);
$this->table_data = array(
'COLUMNS' => array(
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index 5832b966d8..aa0b6ccf48 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -17,7 +17,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
{
/** @var \phpbb\db\driver\driver_interface */
protected $db;
- /** @var \phpbb\db\tools */
+ /** @var \phpbb\db\tools\tools_interface */
protected $tools;
protected $table_exists;
protected $table_data;
@@ -32,7 +32,8 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
parent::setUp();
$this->db = $this->new_dbal();
- $this->tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $this->tools = $factory->get($this->db);
$this->table_data = array(
'COLUMNS' => array(
@@ -340,7 +341,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_perform_schema_changes_drop_tables()
{
- $db_tools = $this->getMock('\phpbb\db\tools', array(
+ $db_tools = $this->getMock('\phpbb\db\tools\tools', array(
'sql_table_exists',
'sql_table_drop',
), array(&$this->db));
@@ -366,7 +367,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_perform_schema_changes_drop_columns()
{
- $db_tools = $this->getMock('\phpbb\db\tools', array(
+ $db_tools = $this->getMock('\phpbb\db\tools\tools', array(
'sql_column_exists',
'sql_column_remove',
), array(&$this->db));
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index 4c4306888c..6416a2fcf7 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -38,7 +38,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
parent::setUp();
$this->db = $this->new_dbal();
- $this->db_tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $this->db_tools = $factory->get($this->db);
$this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config');
diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php
index 08c3e979b8..fa2a8c33df 100644
--- a/tests/dbal/migrator_tool_module_test.php
+++ b/tests/dbal/migrator_tool_module_test.php
@@ -27,7 +27,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
parent::setup();
- // Force add_log function to not be used
+ // Disable the logs
$skip_add_log = true;
$db = $this->db = $this->new_dbal();
diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php
index 4ae6017989..d52fb6b085 100644
--- a/tests/di/create_container_test.php
+++ b/tests/di/create_container_test.php
@@ -14,6 +14,7 @@
namespace
{
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+ require_once dirname(__FILE__) . '/fixtures/ext/vendor/enabled_4/di/extension.php';
class phpbb_di_container_test extends \phpbb_test_case
{
@@ -57,6 +58,9 @@ namespace
// Checks use_extensions
$this->assertTrue($container->hasParameter('enabled'));
+ $this->assertTrue($container->hasParameter('enabled_2'));
+ $this->assertTrue($container->hasParameter('enabled_3'));
+ $this->assertTrue($container->hasParameter('enabled_4'));
$this->assertFalse($container->hasParameter('disabled'));
$this->assertFalse($container->hasParameter('available'));
@@ -142,7 +146,6 @@ namespace
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
$this->assertTrue($container->hasParameter('my_parameter'));
- $this->assertFalse($container->hasParameter('core.root_path'));
}
}
}
@@ -199,6 +202,9 @@ namespace phpbb\db\driver
{
return array(
array('ext_name' => 'vendor/enabled'),
+ array('ext_name' => 'vendor/enabled-2'),
+ array('ext_name' => 'vendor/enabled-3'),
+ array('ext_name' => 'vendor/enabled_4'),
);
}
}
diff --git a/tests/di/fixtures/config/test/config.yml b/tests/di/fixtures/config/test/config.yml
new file mode 100644
index 0000000000..fcfa84f68b
--- /dev/null
+++ b/tests/di/fixtures/config/test/config.yml
@@ -0,0 +1,2 @@
+core:
+ require_dev_dependencies: true
diff --git a/tests/di/fixtures/config/services.yml b/tests/di/fixtures/config/test/container/environment.yml
index f2a22ae109..f2a22ae109 100644
--- a/tests/di/fixtures/config/services.yml
+++ b/tests/di/fixtures/config/test/container/environment.yml
diff --git a/tests/di/fixtures/ext/vendor/disabled/config/services.yml b/tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml
index 31ada384bf..31ada384bf 100644
--- a/tests/di/fixtures/ext/vendor/disabled/config/services.yml
+++ b/tests/di/fixtures/ext/vendor/disabled/config/test/container/environment.yml
diff --git a/tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml b/tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml
new file mode 100644
index 0000000000..feeb5a7a2d
--- /dev/null
+++ b/tests/di/fixtures/ext/vendor/enabled-2/config/test/container/environment.yml
@@ -0,0 +1,2 @@
+parameters:
+ enabled_2: true
diff --git a/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml b/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml
new file mode 100644
index 0000000000..0dae35d2bd
--- /dev/null
+++ b/tests/di/fixtures/ext/vendor/enabled-3/config/services.yml
@@ -0,0 +1,2 @@
+parameters:
+ enabled_3: true
diff --git a/tests/di/fixtures/ext/vendor/enabled/config/services.yml b/tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml
index 88a7919ed1..88a7919ed1 100644
--- a/tests/di/fixtures/ext/vendor/enabled/config/services.yml
+++ b/tests/di/fixtures/ext/vendor/enabled/config/default/container/environment.yml
diff --git a/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php
new file mode 100644
index 0000000000..8342625687
--- /dev/null
+++ b/tests/di/fixtures/ext/vendor/enabled_4/di/extension.php
@@ -0,0 +1,31 @@
+<?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.
+*
+*/
+
+namespace vendor\enabled_4\di;
+
+use phpbb\extension\di\extension_base;
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
+/**
+* Container core extension
+*/
+class extension extends extension_base
+{
+ protected function load_services(ContainerBuilder $container)
+ {
+ $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($this->ext_path)));
+ $loader->load('environment.yml');
+ }
+}
diff --git a/tests/di/fixtures/ext/vendor/enabled_4/environment.yml b/tests/di/fixtures/ext/vendor/enabled_4/environment.yml
new file mode 100644
index 0000000000..d0affe4fd6
--- /dev/null
+++ b/tests/di/fixtures/ext/vendor/enabled_4/environment.yml
@@ -0,0 +1,2 @@
+parameters:
+ enabled_4: true
diff --git a/tests/di/fixtures/other_config/test/config.yml b/tests/di/fixtures/other_config/test/config.yml
new file mode 100644
index 0000000000..fcfa84f68b
--- /dev/null
+++ b/tests/di/fixtures/other_config/test/config.yml
@@ -0,0 +1,2 @@
+core:
+ require_dev_dependencies: true
diff --git a/tests/di/fixtures/other_config/services.yml b/tests/di/fixtures/other_config/test/container/environment.yml
index c299bfc648..c299bfc648 100644
--- a/tests/di/fixtures/other_config/services.yml
+++ b/tests/di/fixtures/other_config/test/container/environment.yml
diff --git a/tests/event/md_exporter_test.php b/tests/event/md_exporter_test.php
index 0f9d855caa..28649e4f21 100644
--- a/tests/event/md_exporter_test.php
+++ b/tests/event/md_exporter_test.php
@@ -41,7 +41,6 @@ class phpbb_event_md_exporter_test extends phpbb_test_case
$styles = array(
'adm/style/' => 'adm',
'styles/prosilver/template/' => 'styles',
- 'styles/subsilver2/template/' => 'styles',
);
foreach ($styles as $path => $filter)
{
diff --git a/tests/extension/ext/vendor2/bar/acp/a_info.php b/tests/extension/ext/vendor2/bar/acp/a_info.php
index 8132df587f..8268006f9f 100644
--- a/tests/extension/ext/vendor2/bar/acp/a_info.php
+++ b/tests/extension/ext/vendor2/bar/acp/a_info.php
@@ -9,7 +9,6 @@ class a_info
return array(
'filename' => 'vendor2\\bar\\acp\\a_module',
'title' => 'Bar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')),
),
diff --git a/tests/extension/ext/vendor2/foo/acp/a_info.php b/tests/extension/ext/vendor2/foo/acp/a_info.php
index e1eaa340b7..48ab4cf8e7 100644
--- a/tests/extension/ext/vendor2/foo/acp/a_info.php
+++ b/tests/extension/ext/vendor2/foo/acp/a_info.php
@@ -9,7 +9,6 @@ class a_info
return array(
'filename' => 'vendor2\\foo\\acp\\a_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')),
),
diff --git a/tests/extension/ext/vendor2/foo/acp/fail_info.php b/tests/extension/ext/vendor2/foo/acp/fail_info.php
index d9b4353957..78479fee70 100644
--- a/tests/extension/ext/vendor2/foo/acp/fail_info.php
+++ b/tests/extension/ext/vendor2/foo/acp/fail_info.php
@@ -13,7 +13,6 @@ class foo_info
return array(
'filename' => 'vendor2\foo\acp\fail_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')),
),
diff --git a/tests/extension/ext/vendor2/foo/mcp/a_info.php b/tests/extension/ext/vendor2/foo/mcp/a_info.php
index b5599fde65..2532e44b12 100644
--- a/tests/extension/ext/vendor2/foo/mcp/a_info.php
+++ b/tests/extension/ext/vendor2/foo/mcp/a_info.php
@@ -9,7 +9,6 @@ class a_info
return array(
'filename' => 'vendor2\\foo\\mcp\\a_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')),
),
diff --git a/tests/extension/includes/acp/info/acp_foobar.php b/tests/extension/includes/acp/info/acp_foobar.php
index 870225ba4f..8ca1afa1c6 100644
--- a/tests/extension/includes/acp/info/acp_foobar.php
+++ b/tests/extension/includes/acp/info/acp_foobar.php
@@ -18,7 +18,6 @@ class acp_foobar_info
return array(
'filename' => 'acp_foobar',
'title' => 'ACP Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')),
),
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 0eeb060936..0126216701 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -150,7 +150,8 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$config = new \phpbb\config\config(array('version' => PHPBB_VERSION));
$db = $this->new_dbal();
- $db_tools = new \phpbb\db\tools($db);
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($db);
$phpbb_root_path = __DIR__ . './../../phpBB/';
$php_ext = 'php';
$table_prefix = 'phpbb_';
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 2a746d3792..8514ed3dbd 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -41,26 +41,42 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
'version' => '3.1.0',
));
$this->db = $this->new_dbal();
- $this->db_tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $this->db_tools = $factory->get($this->db);
$this->phpbb_root_path = dirname(__FILE__) . '/';
$this->phpEx = 'php';
$this->user = new \phpbb\user('\phpbb\datetime');
$this->table_prefix = 'phpbb_';
- $this->template = new \phpbb\template\twig\twig(
- new \phpbb\path_helper(
- new \phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- new \phpbb\filesystem(),
- $this->getMock('\phpbb\request\request'),
- $this->phpbb_root_path,
- $this->phpEx
+ $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('');
+ $phpbb_path_helper =new \phpbb\path_helper(
+ new \phpbb\symfony_request(
+ new phpbb_mock_request()
),
+ new \phpbb\filesystem(),
+ $this->getMock('\phpbb\request\request'),
+ $this->phpbb_root_path,
+ $this->phpEx
+ );
+ $twig = new \phpbb\template\twig\environment(
$this->config,
- $this->user,
- new \phpbb\template\context()
+ $phpbb_path_helper,
+ $container,
+ $cache_path,
+ null,
+ $loader,
+ array(
+ 'cache' => false,
+ 'debug' => false,
+ 'auto_reload' => true,
+ 'autoescape' => false,
+ )
);
+ $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$container = new phpbb_mock_container_builder();
diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php
index 21f1c6aca5..cbcfdfb787 100644
--- a/tests/extension/modules_test.php
+++ b/tests/extension/modules_test.php
@@ -62,7 +62,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'vendor2\\foo\\acp\\a_module' => array(
'filename' => 'vendor2\\foo\\acp\\a_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')),
),
@@ -70,7 +69,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'acp_foobar' => array(
'filename' => 'acp_foobar',
'title' => 'ACP Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')),
),
@@ -84,7 +82,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'vendor2\\foo\\mcp\\a_module' => array(
'filename' => 'vendor2\\foo\\mcp\\a_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')),
),
@@ -98,7 +95,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'vendor2\\foo\\mcp\\a_module' => array(
'filename' => 'vendor2\\foo\\mcp\\a_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')),
),
@@ -112,7 +108,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'vendor2\\foo\\mcp\\a_module' => array(
'filename' => 'vendor2\\foo\\mcp\\a_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('MCP_MAIN')),
),
@@ -136,7 +131,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'vendor2\\foo\\acp\\a_module' => array (
'filename' => 'vendor2\\foo\\acp\\a_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array (
'config' => array ('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array ('ACP_MODS')),
),
@@ -160,7 +154,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'vendor2\\foo\\acp\\a_module' => array(
'filename' => 'vendor2\\foo\\acp\\a_module',
'title' => 'Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => 'ext_vendor2/foo', 'cat' => array('ACP_MODS')),
),
@@ -168,7 +161,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'acp_foobar' => array(
'filename' => 'acp_foobar',
'title' => 'ACP Foobar',
- 'version' => '3.1.0-dev',
'modes' => array(
'test' => array('title' => 'Test', 'auth' => '', 'cat' => array('ACP_GENERAL')),
),
@@ -176,7 +168,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'vendor2\\bar\\acp\\a_module' => array(
'filename' => 'vendor2\\bar\\acp\\a_module',
'title' => 'Bar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')),
),
@@ -189,7 +180,6 @@ class phpbb_extension_modules_test extends phpbb_test_case
'vendor2\\bar\\acp\\a_module' => array(
'filename' => 'vendor2\\bar\\acp\\a_module',
'title' => 'Bar',
- 'version' => '3.1.0-dev',
'modes' => array(
'config' => array('title' => 'Config', 'auth' => '', 'cat' => array('ACP_MODS')),
),
diff --git a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php
index ec378e0e75..371ab7c967 100644
--- a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php
+++ b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php
@@ -28,7 +28,6 @@ class main_info
return array(
'filename' => 'foo\bar\acp\main_module',
'title' => 'ACP_FOOBAR_TITLE',
- 'version' => '1.0.0',
'modes' => array(
'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')),
),
diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php
index d34244f800..4c74442639 100644
--- a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php
+++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php
@@ -20,7 +20,6 @@ class main_info
return array(
'filename' => '\foo\bar\ucp\main_module',
'title' => 'ACP_FOOBAR_TITLE',
- 'version' => '1.0.0',
'modes' => array(
'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')),
),
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
index 612d82273e..781a73a462 100644
--- a/tests/functions/get_remote_file_test.php
+++ b/tests/functions/get_remote_file_test.php
@@ -12,7 +12,7 @@
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php';
/**
* @group slow
diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php
index d5c78c64ad..0cb171c885 100644
--- a/tests/functions_user/delete_user_test.php
+++ b/tests/functions_user/delete_user_test.php
@@ -32,8 +32,6 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
'load_online_time' => 5,
'search_type' => '\phpbb\search\fulltext_mysql',
));
- set_config(false, false, false, $config);
- set_config_count(false, false, false, $config);
$cache = new phpbb_mock_null_cache();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = new phpbb_mock_container_builder();
diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php
index 6fc813cb38..389eab4152 100644
--- a/tests/lock/db_test.php
+++ b/tests/lock/db_test.php
@@ -30,7 +30,6 @@ class phpbb_lock_db_test extends phpbb_database_test_case
$db = $this->db = $this->new_dbal();
$config = $this->config = new \phpbb\config\config(array('rand_seed' => '', 'rand_seed_last_update' => '0'));
- set_config(null, null, null, $this->config);
$this->lock = new \phpbb\lock\db('test_lock', $this->config, $this->db);
}
diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php
index 63e468498e..78949734a9 100644
--- a/tests/log/function_add_log_test.php
+++ b/tests/log/function_add_log_test.php
@@ -11,7 +11,7 @@
*
*/
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php';
class phpbb_log_function_add_log_test extends phpbb_database_test_case
{
diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php
index 7501ed2ed0..f8d780da0c 100644
--- a/tests/migrator/convert_timezones_test.php
+++ b/tests/migrator/convert_timezones_test.php
@@ -18,7 +18,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
public function getDataSet()
{
$this->db = $this->new_dbal();
- $db_tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($this->db);
// user_dst doesn't exist anymore, must re-add it to test this
$db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1));
@@ -55,11 +56,12 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
global $phpbb_root_path, $phpEx;
$this->db = $this->new_dbal();
+ $factory = new \phpbb\db\tools\factory();
$this->migration = new \phpbb\db\migration\data\v310\timezone(
new \phpbb\config\config(array()),
$this->db,
- new \phpbb\db\tools($this->db),
+ $factory->get($this->db),
$phpbb_root_path,
$phpEx,
'phpbb_'
@@ -90,7 +92,8 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
}
$this->db->sql_freeresult($result);
- $db_tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($this->db);
// Remove the user_dst field again
$db_tools->sql_column_remove('phpbb_users', 'user_dst');
diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php
index 9adf518a5d..40a8343e22 100644
--- a/tests/migrator/schema_generator_test.php
+++ b/tests/migrator/schema_generator_test.php
@@ -30,7 +30,8 @@ class schema_generator_test extends phpbb_test_case
$this->config = new \phpbb\config\config(array());
$this->db = new \phpbb\db\driver\sqlite();
- $this->db_tools = new \phpbb\db\tools($this->db);
+ $factory = new \phpbb\db\tools\factory();
+ $this->db_tools = $factory->get($this->db);
$this->table_prefix = 'phpbb_';
}
diff --git a/tests/mock/controller_helper.php b/tests/mock/controller_helper.php
index ae3e7bf432..7e4a808906 100644
--- a/tests/mock/controller_helper.php
+++ b/tests/mock/controller_helper.php
@@ -13,7 +13,7 @@
class phpbb_mock_controller_helper extends \phpbb\controller\helper
{
- public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
+ public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\routing\router $router, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
{
$this->template = $template;
$this->user = $user;
@@ -23,8 +23,7 @@ class phpbb_mock_controller_helper extends \phpbb\controller\helper
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
- $provider->find_routing_files($manager->get_finder());
- $this->route_collection = $provider->find($phpbb_root_path_ext)->get_routes();
+ $this->router = $router;
}
public function get_current_url()
diff --git a/tests/mock/router.php b/tests/mock/router.php
new file mode 100644
index 0000000000..01faa338c5
--- /dev/null
+++ b/tests/mock/router.php
@@ -0,0 +1,27 @@
+<?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_mock_router extends \phpbb\routing\router
+{
+ public function get_matcher()
+ {
+ $this->create_new_url_matcher();
+ return parent::get_matcher();
+ }
+
+ public function get_generator()
+ {
+ $this->create_new_url_generator();
+ return parent::get_generator();
+ }
+}
diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php
index 32ab34c9bc..4a7fd89409 100644
--- a/tests/notification/convert_test.php
+++ b/tests/notification/convert_test.php
@@ -28,11 +28,12 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
global $phpbb_root_path, $phpEx;
$this->db = $this->new_dbal();
+ $factory = new \phpbb\db\tools\factory();
$this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert(
new \phpbb\config\config(array()),
$this->db,
- new \phpbb\db\tools($this->db),
+ $factory->get($this->db),
$phpbb_root_path,
$phpEx,
'phpbb_'
diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index 0d1bda95ce..0d532882c6 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -40,8 +40,6 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
include_once($phpbb_root_path . 'includes/functions_user.' . $phpEx);
include_once($phpbb_root_path . 'includes/functions_content.' . $phpEx);
- set_config(false, false, false, $this->config);
-
$this->container->set('groupposition.legend', new \phpbb\groupposition\legend(
$this->db,
$this->user
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 5e770f71c9..2d621f82d3 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -70,8 +70,6 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
// Config
$config = new \phpbb\config\config(array('num_topics' => 1,'num_posts' => 1,));
- set_config(null, null, null, $config);
- set_config_count(null, null, null, $config);
$cache = new \phpbb\cache\service(
new \phpbb\cache\driver\null(),
diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php
index c43eff729c..5886c49512 100644
--- a/tests/notification/user_list_trim_test.php
+++ b/tests/notification/user_list_trim_test.php
@@ -33,8 +33,6 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
$db = $this->new_dbal();
$config = new \phpbb\config\config(array());
- set_config(null, null, null, $config);
- set_config_count(null, null, null, $config);
$cache = new \phpbb\cache\service(
new \phpbb\cache\driver\null(),
diff --git a/tests/pagination/config/routing.yml b/tests/pagination/config/test/routing/environment.yml
index 2ce082c9d1..2ce082c9d1 100644
--- a/tests/pagination/config/routing.yml
+++ b/tests/pagination/config/test/routing/environment.yml
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index ea6dd999c3..6679d48c01 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -36,17 +36,11 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$filesystem = new \phpbb\filesystem();
$manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array());
- $finder = new \phpbb\finder(
- $filesystem,
- dirname(__FILE__) . '/',
- new phpbb_mock_cache()
- );
- $finder->set_extensions(array_keys($manager->all_enabled()));
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $provider = new \phpbb\controller\provider();
- $provider->find_routing_files($finder);
- $provider->find(dirname(__FILE__) . '/');
+ $router = new phpbb_mock_router($manager, dirname(__FILE__) . '/', 'php', PHPBB_ENVIRONMENT);
+ $router->find_routing_files($manager->all_enabled(false));
+ $router->find(dirname(__FILE__) . '/');
$request = new phpbb_mock_request();
$request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER);
@@ -57,7 +51,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$request
);
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $router, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/');
$this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher);
}
diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php
index 67712eb6c8..b409e5ef25 100644
--- a/tests/request/request_var_test.php
+++ b/tests/request/request_var_test.php
@@ -11,7 +11,7 @@
*
*/
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
class phpbb_request_var_test extends phpbb_test_case
diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php
index 3e25286480..7819063505 100644
--- a/tests/session/testable_factory.php
+++ b/tests/session/testable_factory.php
@@ -81,10 +81,8 @@ class phpbb_session_testable_factory
$this->cookies,
$this->server_data
);
- request_var(null, null, null, null, $request);
$config = $this->config = new \phpbb\config\config($this->get_config_data());
- set_config(null, null, null, $config);
$db = $dbal;
@@ -96,6 +94,7 @@ class phpbb_session_testable_factory
'auth.provider.db',
new phpbb_mock_auth_provider()
);
+ $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT);
$provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config);
$provider_collection->add('auth.provider.db');
$phpbb_container->set(
diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php
index b4ad84e9c3..e87688a57c 100644
--- a/tests/template/template_allfolder_test.php
+++ b/tests/template/template_allfolder_test.php
@@ -51,9 +51,29 @@ 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('');
+ $twig = new \phpbb\template\twig\environment(
+ $config,
+ $path_helper,
+ $container,
+ $cache_path,
+ $this->extension_manager,
+ $loader,
+ array(
+ 'cache' => false,
+ 'debug' => false,
+ 'auto_reload' => true,
+ 'autoescape' => false,
+ )
+ );
+ $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
+ $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
+
$this->template_path = $this->test_path . '/templates';
$this->ext_template_path = 'tests/extension/ext/vendor4/bar/styles/all/template';
- $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context(), $this->extension_manager);
$this->template->set_custom_style('all', array($this->template_path, $this->ext_template_path));
}
}
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index c415c969fe..e8ffea8d11 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -147,7 +147,28 @@ Zeta test event in all',
$phpbb_root_path,
$phpEx
);
- $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, new \phpbb\template\context, $this->extension_manager);
+
+ $container = new phpbb_mock_container_builder();
+ $cache_path = $phpbb_root_path . 'cache/twig';
+ $context = new \phpbb\template\context();
+ $loader = new \phpbb\template\twig\loader('');
+ $twig = new \phpbb\template\twig\environment(
+ $config,
+ $path_helper,
+ $container,
+ $cache_path,
+ $this->extension_manager,
+ $loader,
+ array(
+ 'cache' => false,
+ 'debug' => false,
+ 'auto_reload' => true,
+ 'autoescape' => false,
+ )
+ );
+ $this->template = new \phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
+ $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
+
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
}
}
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index 49bd9dec8b..96980e17c6 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -15,6 +15,12 @@ require_once dirname(__FILE__) . '/template_test_case_with_tree.php';
class phpbb_template_template_includecss_test extends phpbb_template_template_test_case_with_tree
{
+ /** @var \phpbb\path_helper */
+ protected $phpbb_path_helper;
+
+ /** @var string */
+ protected $parent_template_path;
+
protected function setup_engine(array $new_config = array())
{
global $phpbb_root_path, $phpEx, $user;
@@ -34,11 +40,32 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$this->template_path = $this->test_path . '/templates';
$this->parent_template_path = $this->test_path . '/parent_templates';
+ $container = new phpbb_mock_container_builder();
+ $cache_path = $phpbb_root_path . 'cache/twig';
+ $context = new \phpbb\template\context();
+ $loader = new \phpbb\template\twig\loader('');
+ $twig = new \phpbb\template\twig\environment(
+ $config,
+ $this->phpbb_path_helper,
+ $container,
+ $cache_path,
+ null,
+ $loader,
+ array(
+ 'cache' => false,
+ 'debug' => false,
+ 'auto_reload' => true,
+ 'autoescape' => false,
+ )
+ );
$this->template = new phpbb\template\twig\twig(
$this->phpbb_path_helper,
$config,
$user,
- new phpbb\template\context(),
+ $context,
+ $twig,
+ $cache_path,
+ array(new \phpbb\template\twig\extension($context, $this->user)),
new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
array(
@@ -50,18 +77,12 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
)
)
);
+ $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
}
public function template_data()
{
- $url_base = explode('/', dirname(__FILE__));
- foreach ($url_base as &$dir)
- {
- $dir = rawurlencode($dir);
- }
- $url_base = implode('/', $url_base);
-
return array(
/*
array(
@@ -79,11 +100,11 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
),
array(
array('TEST' => 3),
- '<link href="' . $url_base . '/ext/include/css/styles/all/theme/test.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
+ '<link href="tests/template/ext/include/css/styles/all/theme/test.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
),
array(
array('TEST' => 4),
- '<link href="' . $url_base . '/ext/include/css/styles/all/theme/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
+ '<link href="tests/template/ext/include/css/styles/all/theme/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
),
);
}
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 0bbfe3848d..33dc4ca551 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -130,6 +130,34 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1",
),
array(
+ 'loop_twig.html',
+ array(),
+ array(),
+ array(),
+ "noloop\nnoloop",
+ ),
+ array(
+ 'loop_twig.html',
+ array(),
+ array('test_loop' => array(array())),
+ array(),
+ "loop\nloop",
+ ),
+ array(
+ 'loop_twig.html',
+ array(),
+ array('test_loop' => array(array(), array()), 'test_loop.block' => array(array())),
+ array(),
+ "loop\nloop\nloop\nloop",
+ ),
+ array(
+ 'loop_twig.html',
+ array(),
+ array('test_loop' => array(array(), array()), 'test_loop.block' => array(array()), 'block' => array(array(), array())),
+ array(),
+ "loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1",
+ ),
+ array(
'loop_vars.html',
array(),
array('test_loop' => array(array('VARIABLE' => 'x'))),
@@ -151,6 +179,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner",
),
array(
+ 'loop_vars_twig.html',
+ array(),
+ array('test_loop' => array(array('VARIABLE' => 'x'))),
+ array(),
+ "first\n0 - a\nx - b\nset\nlast",
+ ),
+ array(
+ 'loop_vars_twig.html',
+ array(),
+ array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y'))),
+ array(),
+ "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast",
+ ),
+ array(
+ 'loop_vars_twig.html',
+ array(),
+ array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())),
+ array(),
+ "first\n0 - a\nx - b\nset\n1 - a\ny - b\nset\nlast\n0 - c\n1 - c\nlast inner",
+ ),
+ array(
'loop_advanced.html',
array(),
array('test_loop' => array(array(), array(), array(), array(), array(), array(), array())),
@@ -158,6 +207,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561",
),
array(
+ 'loop_advanced_twig.html',
+ array(),
+ array('test_loop' => array(array(), array(), array(), array(), array(), array(), array())),
+ array(),
+ "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561",
+ ),
+ array(
'loop_nested2.html',
array(),
array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())),
@@ -165,6 +221,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"o0o1m01m11",
),
array(
+ 'loop_nested2_twig.html',
+ array(),
+ array('outer' => array(array(), array()), 'outer.middle' => array(array(), array())),
+ array(),
+ "o0o1m01m11",
+ ),
+ array(
'define.html',
array(),
array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
@@ -244,6 +307,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
'',
),
array(
+ 'loop_vars_twig.html',
+ array(),
+ array('test_loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'test_loop.inner' => array(array(), array())),
+ array('test_loop'),
+ '',
+ ),
+ array(
'include_define_variable.html',
array('VARIABLE' => 'variable.html'),
array(),
@@ -275,6 +345,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"noloop\nnoloop",
),
array(
+ // Just like a regular loop but the name begins
+ // with an underscore
+ 'loop_underscore_twig.html',
+ array(),
+ array(),
+ array(),
+ "noloop\nnoloop",
+ ),
+ array(
'lang.html',
array(),
array(),
@@ -286,7 +365,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
- "Value'\n1 O'Clock\nValue\'\n1 O\'Clock",
+ "Value'\n1 O'Clock\nValue\\x27\n1\\x20O\\x27Clock",
array('VARIABLE' => "Value'", '1_VARIABLE' => "1 O'Clock"),
),
array(
@@ -297,6 +376,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"top-level content",
),
array(
+ 'loop_nested_multilevel_ref_twig.html',
+ array(),
+ array(),
+ array(),
+ "top-level content",
+ ),
+ array(
'loop_nested_multilevel_ref.html',
array(),
array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
@@ -304,6 +390,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz",
),
array(
+ 'loop_nested_multilevel_ref_twig.html',
+ array(),
+ array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
+ array(),
+ "top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz",
+ ),
+ array(
'loop_nested_deep_multilevel_ref.html',
array(),
array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
@@ -311,6 +404,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz",
),
array(
+ 'loop_nested_deep_multilevel_ref_twig.html',
+ array(),
+ array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
+ array(),
+ "top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz",
+ ),
+ array(
'loop_size.html',
array(),
array('test_loop' => array(array()), 'empty_loop' => array()),
@@ -318,6 +418,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop",
),
array(
+ 'loop_size_twig.html',
+ array(),
+ array('test_loop' => array(array()), 'empty_loop' => array()),
+ array(),
+ "nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop",
+ ),
+ array(
'loop_include.html',
array(),
array('test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1'))),
@@ -325,6 +432,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"barbarbar1bar1",
),
array(
+ 'loop_include_twig.html',
+ array(),
+ array('test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1'))),
+ array(),
+ "barbarbar1bar1",
+ ),
+ array(
'loop_nested_include.html',
array(),
array(
@@ -335,6 +449,17 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
"[bar|[bar|]][bar1|[bar1|[bar1|works]]]",
array(),
),
+ array(
+ 'loop_nested_include_twig.html',
+ array(),
+ array(
+ 'test_loop' => array(array('foo' => 'bar'), array('foo' => 'bar1')),
+ 'test_loop.inner' => array(array('myinner' => 'works')),
+ ),
+ array(),
+ "[bar|[bar|]][bar1|[bar1|[bar1|works]]]",
+ array(),
+ ),
/* Does not pass with the current implementation.
array(
'loop_reuse.html',
@@ -343,8 +468,15 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
// Not entirely sure what should be outputted but the current output of "a" is most certainly wrong
"a\nb\nc\nd",
+ ),*/
+ array(
+ 'loop_reuse_twig.html',
+ array(),
+ array('one' => array(array('VAR' => 'a'), array('VAR' => 'b')), 'one.one' => array(array('VAR' => 'c'), array('VAR' => 'd'))),
+ array(),
+ // Not entirely sure what should be outputted but the current output of "a" is most certainly wrong
+ "a\nb\nc\nd",
),
- */
array(
'twig.html',
array('VARIABLE' => 'FOObar',),
@@ -359,6 +491,27 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
'inner_value',
),
+ array(
+ 'loop_expressions.html',
+ array(),
+ array('loop' => array(array(),array(),array(),array(),array(),array()),),
+ array(),
+ 'yesnononoyesnoyesnonoyesnono',
+ ),
+ array(
+ 'loop_expressions_twig.html',
+ array(),
+ array('loop' => array(array(),array(),array(),array(),array(),array()),),
+ array(),
+ 'yesnononoyesnoyesnonoyesnono',
+ ),
+ array(
+ 'loop_expressions_twig2.html',
+ array('loop' => array(array(),array(),array(),array(),array(),array()),),
+ array(),
+ array(),
+ 'yesnononoyesnoyesnonoyesnono',
+ ),
);
}
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 1250397401..f9ea8cfaba 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -78,7 +78,27 @@ class phpbb_template_template_test_case extends phpbb_test_case
);
$this->template_path = $this->test_path . '/templates';
- $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context());
+
+ $container = new phpbb_mock_container_builder();
+ $cache_path = $phpbb_root_path . 'cache/twig';
+ $context = new \phpbb\template\context();
+ $loader = new \phpbb\template\twig\loader('');
+ $twig = new \phpbb\template\twig\environment(
+ $config,
+ $path_helper,
+ $container,
+ $cache_path,
+ null,
+ $loader,
+ array(
+ 'cache' => false,
+ 'debug' => false,
+ 'auto_reload' => true,
+ 'autoescape' => false,
+ )
+ );
+ $this->template = new phpbb\template\twig\twig($path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', $this->template_path);
}
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index 68ecc4b706..c634e2051a 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -34,7 +34,27 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
$this->template_path = $this->test_path . '/templates';
$this->parent_template_path = $this->test_path . '/parent_templates';
- $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, new phpbb\template\context());
+
+ $container = new phpbb_mock_container_builder();
+ $cache_path = $phpbb_root_path . 'cache/twig';
+ $context = new \phpbb\template\context();
+ $loader = new \phpbb\template\twig\loader('');
+ $twig = new \phpbb\template\twig\environment(
+ $config,
+ $this->phpbb_path_helper,
+ $container,
+ $cache_path,
+ null,
+ $loader,
+ array(
+ 'cache' => false,
+ 'debug' => false,
+ 'auto_reload' => true,
+ 'autoescape' => false,
+ )
+ );
+ $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
}
}
diff --git a/tests/template/templates/loop_advanced_twig.html b/tests/template/templates/loop_advanced_twig.html
new file mode 100644
index 0000000000..fd9fcae045
--- /dev/null
+++ b/tests/template/templates/loop_advanced_twig.html
@@ -0,0 +1,19 @@
+{% for test_loop_inner in test_loop %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(0) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(0,-1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(1,1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(0,1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(2,4) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(0,-7) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(-2,6) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
+x
+{% for test_loop_inner in test_loop|subset(-2,-1) %}{{ test_loop_inner.S_FIRST_ROW }}{{ test_loop_inner.S_ROW_COUNT }}{{ test_loop_inner.S_LAST_ROW }}{% endfor %}
diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html
index 6bff53f388..ddb9fd52fa 100644
--- a/tests/template/templates/loop_expressions.html
+++ b/tests/template/templates/loop_expressions.html
@@ -1,11 +1,11 @@
<!-- BEGIN loop -->
-<!-- IF loop.S_ROW_NUM is even by 4 -->on<!-- ELSE -->off<!-- ENDIF -->
+<!-- IF loop.S_ROW_NUM is divisible by(4) -->yes<!-- ELSE -->no<!-- ENDIF -->
<!-- END loop -->
<!-- BEGIN loop -->
-<!-- IF loop.S_ROW_NUM is odd by 3 -->on<!-- ELSE -->off<!-- ENDIF -->
+<!-- IF loop.S_ROW_NUM is divisible by(3) -->yes<!-- ELSE -->no<!-- ENDIF -->
<!-- END loop -->
diff --git a/tests/template/templates/loop_expressions_twig.html b/tests/template/templates/loop_expressions_twig.html
new file mode 100644
index 0000000000..5ca8cc3601
--- /dev/null
+++ b/tests/template/templates/loop_expressions_twig.html
@@ -0,0 +1,11 @@
+{% for loop_inner in loop %}
+
+{% if loop_inner.S_ROW_NUM is divisible by(4) %}yes{% else %}no{% endif %}
+
+{% endfor %}
+
+{% for loop_inner in loop %}
+
+{% if loop_inner.S_ROW_NUM is divisible by(3) %}yes{% else %}no{% endif %}
+
+{% endfor %}
diff --git a/tests/template/templates/loop_expressions_twig2.html b/tests/template/templates/loop_expressions_twig2.html
new file mode 100644
index 0000000000..16159ead4c
--- /dev/null
+++ b/tests/template/templates/loop_expressions_twig2.html
@@ -0,0 +1,11 @@
+{% for loop_inner in loop %}
+
+{% if loop.index0 is divisible by(4) %}yes{% else %}no{% endif %}
+
+{% endfor %}
+
+{% for loop_inner in loop %}
+
+{% if loop.index0 is divisible by(3) %}yes{% else %}no{% endif %}
+
+{% endfor %}
diff --git a/tests/template/templates/loop_include1_twig.html b/tests/template/templates/loop_include1_twig.html
new file mode 100644
index 0000000000..2ff9f61b02
--- /dev/null
+++ b/tests/template/templates/loop_include1_twig.html
@@ -0,0 +1 @@
+{{ test_loop_inner.foo }}
diff --git a/tests/template/templates/loop_include_twig.html b/tests/template/templates/loop_include_twig.html
new file mode 100644
index 0000000000..1a534e2dbc
--- /dev/null
+++ b/tests/template/templates/loop_include_twig.html
@@ -0,0 +1,4 @@
+{% for test_loop_inner in test_loop %}
+ {{ test_loop_inner.foo }}
+ {% INCLUDE 'loop_include1_twig.html' %}
+{% endfor %}
diff --git a/tests/template/templates/loop_nested2_twig.html b/tests/template/templates/loop_nested2_twig.html
new file mode 100644
index 0000000000..cf802dc69f
--- /dev/null
+++ b/tests/template/templates/loop_nested2_twig.html
@@ -0,0 +1,6 @@
+{% for outer_inner in outer %}
+ o{{ outer_inner.S_ROW_COUNT }}
+ {% for middle in outer_inner.middle %}
+ m{{ middle.S_ROW_COUNT }}{{ outer_inner.S_ROW_COUNT }}
+ {% endfor %}
+{% endfor %}
diff --git a/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html b/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html
new file mode 100644
index 0000000000..9bc68e6e2e
--- /dev/null
+++ b/tests/template/templates/loop_nested_deep_multilevel_ref_twig.html
@@ -0,0 +1,13 @@
+top-level content
+{% for outer_inner in outer %}
+ outer
+ {% for middle in outer_inner.middle %}
+ {{ middle.S_BLOCK_NAME }}
+ {% for inner in middle.inner %}
+ inner {{ inner.VARIABLE }}
+ {% if inner.S_FIRST_ROW %}
+ first row of {{ inner.S_NUM_ROWS }} in {{ inner.S_BLOCK_NAME }}
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+{% endfor %}
diff --git a/tests/template/templates/loop_nested_include1_twig.html b/tests/template/templates/loop_nested_include1_twig.html
new file mode 100644
index 0000000000..4c2ebb5f15
--- /dev/null
+++ b/tests/template/templates/loop_nested_include1_twig.html
@@ -0,0 +1,5 @@
+[{{ test_loop_inner.foo }}|
+{% for inner in test_loop_inner.inner %}
+ [{{ test_loop_inner.foo }}|
+ {{ inner.myinner }}]
+{% endfor %}]
diff --git a/tests/template/templates/loop_nested_include_twig.html b/tests/template/templates/loop_nested_include_twig.html
new file mode 100644
index 0000000000..c92ac922d1
--- /dev/null
+++ b/tests/template/templates/loop_nested_include_twig.html
@@ -0,0 +1,4 @@
+{% for test_loop_inner in test_loop %}
+ [{{ test_loop_inner.foo }}
+ |{% INCLUDE 'loop_nested_include1_twig.html' %}]
+{% endfor %}
diff --git a/tests/template/templates/loop_nested_multilevel_ref_twig.html b/tests/template/templates/loop_nested_multilevel_ref_twig.html
new file mode 100644
index 0000000000..336a57d0bc
--- /dev/null
+++ b/tests/template/templates/loop_nested_multilevel_ref_twig.html
@@ -0,0 +1,10 @@
+top-level content
+{% for outer_inner in outer %}
+ outer {{ outer_inner.VARIABLE }}
+ {% for inner in outer_inner.inner %}
+ inner {{ inner.VARIABLE }}
+ {% if inner.S_FIRST_ROW %}
+ first row
+ {% endif %}
+ {% endfor %}
+{% endfor %}
diff --git a/tests/template/templates/loop_nested_twig.html b/tests/template/templates/loop_nested_twig.html
new file mode 100644
index 0000000000..b294226b3a
--- /dev/null
+++ b/tests/template/templates/loop_nested_twig.html
@@ -0,0 +1,6 @@
+{% for outer_inner in outer %}
+outer - {{ outer_inner.S_ROW_COUNT }}{% if outer_inner.VARIABLE %} - {{ outer_inner.VARIABLE }}{% endif %}{% if TEST_MORE %}[{{ outer_inner.S_BLOCK_NAME }}|{{ outer_inner.S_NUM_ROWS }}]{% endif %}
+{% for middle in outer_inner.middle %}
+middle - {{ middle.S_ROW_COUNT }}{% if middle.VARIABLE %} - {{ middle.VARIABLE }}{% endif %}{% if TEST_MORE %}[{{ middle.S_BLOCK_NAME }}|{{ middle.S_NUM_ROWS }}]{% endif %}
+{% endfor %}
+{% endfor %}
diff --git a/tests/template/templates/loop_reuse_twig.html b/tests/template/templates/loop_reuse_twig.html
new file mode 100644
index 0000000000..67452a737f
--- /dev/null
+++ b/tests/template/templates/loop_reuse_twig.html
@@ -0,0 +1,6 @@
+{% for one_inner in one %}
+ {{ one_inner.VAR }}
+ {% for one_one_inner in one_inner.one %}
+ {{ one_one_inner.VAR }}
+ {% endfor %}
+{% endfor %}
diff --git a/tests/template/templates/loop_size_twig.html b/tests/template/templates/loop_size_twig.html
new file mode 100644
index 0000000000..f6d2571e11
--- /dev/null
+++ b/tests/template/templates/loop_size_twig.html
@@ -0,0 +1,39 @@
+{% if nonexistent_loop|length %}
+nonexistent
+{% endif %}
+
+{% if nonexistent_loop|length == 0 %}
+nonexistent = 0
+{% endif %}
+
+{% if ! nonexistent_loop|length %}
+! nonexistent
+{% endif %}
+
+{% if empty_loop|length %}
+empty
+{% endif %}
+
+{% if empty_loop|length == 0 %}
+empty = 0
+{% endif %}
+
+{% if ! empty_loop|length %}
+! empty
+{% endif %}
+
+{% if test_loop|length %}
+loop
+{% endif %}
+
+{% if test_loop|length == 0 %}
+loop = 0
+{% endif %}
+
+{% if ! test_loop|length %}
+! loop
+{% endif %}
+
+{% for test_loop_inner in test_loop %}
+in loop
+{% endfor %}
diff --git a/tests/template/templates/loop_twig.html b/tests/template/templates/loop_twig.html
new file mode 100644
index 0000000000..fb24f331b3
--- /dev/null
+++ b/tests/template/templates/loop_twig.html
@@ -0,0 +1,21 @@
+{% for test_loop_inner in test_loop %}
+loop
+{% else %}
+noloop
+{% endfor %}
+
+{% if test_loop|length %}
+loop
+{% else %}
+noloop
+{% endif %}
+
+{% if test_loop|length == 2 %}
+loop
+{% endif %}
+
+{% for test_loop_inner in test_loop %}
+{% for block_inner in block %}
+loop#{{ test_loop_inner.S_ROW_COUNT }}-block#{{ block_inner.S_ROW_COUNT }}
+{% endfor %}
+{% endfor %}
diff --git a/tests/template/templates/loop_underscore_twig.html b/tests/template/templates/loop_underscore_twig.html
new file mode 100644
index 0000000000..44b095c882
--- /dev/null
+++ b/tests/template/templates/loop_underscore_twig.html
@@ -0,0 +1,21 @@
+{% for _underscore_loop_inner in _underscore_loop %}
+loop
+{% else %}
+noloop
+{% endfor %}
+
+{% if _underscore_loop|length %}
+loop
+{% else %}
+noloop
+{% endif %}
+
+{% if _underscore_loop|length == 2 %}
+loop
+{% endif %}
+
+{% for _underscore_loop_inner in _underscore_loop %}
+{% for block_inner in block %}
+loop#{{ loop.S_ROW_COUNT }}-block#{{ block_inner.S_ROW_COUNT }}
+{% endfor %}
+{% endfor %}
diff --git a/tests/template/templates/loop_vars_twig.html b/tests/template/templates/loop_vars_twig.html
new file mode 100644
index 0000000000..af6c63d8e3
--- /dev/null
+++ b/tests/template/templates/loop_vars_twig.html
@@ -0,0 +1,13 @@
+{% for test_loop_inner in test_loop %}
+{% if test_loop_inner.S_FIRST_ROW %}first{% endif %}
+{{ test_loop_inner.S_ROW_NUM }} - a
+{{ test_loop_inner.VARIABLE }} - b
+{% if test_loop_inner.VARIABLE %}set{% endif %}
+{% if test_loop_inner.S_LAST_ROW %}
+last
+{% endif %}
+{% for inner_inner in test_loop_inner.inner %}
+{{ inner_inner.S_ROW_NUM }} - c
+{% if inner_inner.S_LAST_ROW and inner_inner.S_ROW_COUNT and inner_inner.S_NUM_ROWS %}last inner{% endif %}
+{% endfor %}
+{% endfor %}
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index fc1a3632f4..903158d3c6 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -77,7 +77,10 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
global $table_prefix;
$db = new \phpbb\db\driver\sqlite();
- $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
+ $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);
file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema()));
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index 5d643e43e2..4f38ccc0d8 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -370,11 +370,15 @@ class phpbb_database_test_connection_manager
->get_classes();
$db = new \phpbb\db\driver\sqlite();
- $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
+ $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);
$db_table_schema = $schema_generator->get_schema();
}
- $db_tools = new \phpbb\db\tools($db, true);
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($db, true);
foreach ($db_table_schema as $table_name => $table_data)
{
$queries = $db_tools->sql_create_table(
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 844caa8f54..495413593b 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -204,6 +204,11 @@ class phpbb_functional_test_case extends phpbb_test_case
{
if (!$this->cache)
{
+ global $phpbb_container;
+
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->setParameter('core.environment', PHPBB_ENVIRONMENT);
+
$this->cache = new \phpbb\cache\driver\file;
}
@@ -225,7 +230,8 @@ class phpbb_functional_test_case extends phpbb_test_case
$config = new \phpbb\config\config(array());
$db = $this->get_db();
- $db_tools = new \phpbb\db\tools($db);
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($db);
$container = new phpbb_mock_container_builder();
$migrator = new \phpbb\db\migrator(
@@ -489,7 +495,7 @@ class phpbb_functional_test_case extends phpbb_test_case
));
$db->sql_query($sql);
- if ($style_path != 'prosilver' && $style_path != 'subsilver2')
+ if ($style_path != 'prosilver')
{
@mkdir($phpbb_root_path . 'styles/' . $style_path, 0777);
@mkdir($phpbb_root_path . 'styles/' . $style_path . '/template', 0777);
@@ -528,7 +534,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$db->sql_query('DELETE FROM ' . STYLES_TEMPLATE_TABLE . ' WHERE template_id = ' . $style_id);
$db->sql_query('DELETE FROM ' . STYLES_THEME_TABLE . ' WHERE theme_id = ' . $style_id);
- if ($style_path != 'prosilver' && $style_path != 'subsilver2')
+ if ($style_path != 'prosilver')
{
@rmdir($phpbb_root_path . 'styles/' . $style_path . '/template');
@rmdir($phpbb_root_path . 'styles/' . $style_path);
@@ -584,8 +590,7 @@ class phpbb_functional_test_case extends phpbb_test_case
{
require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
}
- set_config(null, null, null, $config);
- set_config_count(null, null, null, $config);
+
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$passwords_manager = $this->get_passwords_manager();
@@ -947,8 +952,7 @@ class phpbb_functional_test_case extends phpbb_test_case
*/
public function assert_checkbox_is_unchecked($crawler, $name, $message = '')
{
- $this->assertSame(
- '',
+ $this->assertNull(
$this->assert_find_one_checkbox($crawler, $name)->attr('checked'),
$message ?: "Failed asserting that checkbox $name is unchecked."
);
diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php
index c56be1f81e..647fcef2af 100644
--- a/tests/tree/nestedset_forum_base.php
+++ b/tests/tree/nestedset_forum_base.php
@@ -59,7 +59,6 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
global $config;
$config = $this->config = new \phpbb\config\config(array('nestedset_forum_lock' => 0));
- set_config(null, null, null, $this->config);
$this->lock = new \phpbb\lock\db('nestedset_forum_lock', $this->config, $this->db);
$this->set = new \phpbb\tree\nestedset_forum($this->db, $this->lock, 'phpbb_forums');
diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php
deleted file mode 100644
index 50eafda859..0000000000
--- a/tests/utf/normalizer_test.php
+++ /dev/null
@@ -1,327 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_normalizer.php';
-
-/**
-* @group slow
-*/
-class phpbb_utf_normalizer_test extends phpbb_test_case
-{
- static private $data_dir;
-
- static public function setUpBeforeClass()
- {
- self::$data_dir = dirname(__file__) . '/../tmp';
- self::download('http://www.unicode.org/Public/UNIDATA/NormalizationTest.txt', self::$data_dir);
- self::download('http://www.unicode.org/Public/UNIDATA/UnicodeData.txt', self::$data_dir);
- }
-
- public function test_normalizer()
- {
- $test_suite = array(
- /**
- * NFC
- * c2 == NFC(c1) == NFC(c2) == NFC(c3)
- * c4 == NFC(c4) == NFC(c5)
- */
- 'NFC' => array(
- 'c2' => array('c1', 'c2', 'c3'),
- 'c4' => array('c4', 'c5')
- ),
-
- /**
- * NFD
- * c3 == NFD(c1) == NFD(c2) == NFD(c3)
- * c5 == NFD(c4) == NFD(c5)
- */
- 'NFD' => array(
- 'c3' => array('c1', 'c2', 'c3'),
- 'c5' => array('c4', 'c5')
- ),
-
- /**
- * NFKC
- * c4 == NFKC(c1) == NFKC(c2) == NFKC(c3) == NFKC(c4) == NFKC(c5)
- */
- 'NFKC' => array(
- 'c4' => array('c1', 'c2', 'c3', 'c4', 'c5')
- ),
-
- /**
- * NFKD
- * c5 == NFKD(c1) == NFKD(c2) == NFKD(c3) == NFKD(c4) == NFKD(c5)
- */
- 'NFKD' => array(
- 'c5' => array('c1', 'c2', 'c3', 'c4', 'c5')
- )
- );
-
- $tested_chars = array();
-
- $fp = fopen(self::$data_dir . '/NormalizationTest.txt', 'rb');
- while (!feof($fp))
- {
- $line = fgets($fp);
-
- if ($line[0] == '@')
- {
- continue;
- }
-
- if (!strpos(' 0123456789ABCDEF', $line[0]))
- {
- continue;
- }
-
- list($c1, $c2, $c3, $c4, $c5) = explode(';', $line);
-
- if (!strpos($c1, ' '))
- {
- /**
- * We are currently testing a single character, we add it to the list of
- * characters we have processed so that we can exclude it when testing
- * for invariants
- */
- $tested_chars[$c1] = 1;
- }
-
- foreach ($test_suite as $form => $serie)
- {
- foreach ($serie as $expected => $tests)
- {
- $hex_expected = ${$expected};
- $utf_expected = $this->hexseq_to_utf($hex_expected);
-
- foreach ($tests as $test)
- {
- $utf_result = $utf_expected;
- call_user_func_array(array('utf_normalizer', $form), array(&$utf_result));
-
- $hex_result = $this->utf_to_hexseq($utf_result);
- $this->assertEquals($utf_expected, $utf_result, "$expected == $form($test) ($hex_expected != $hex_result)");
- }
- }
- }
- }
- fclose($fp);
-
- return $tested_chars;
- }
-
- /**
- * @depends test_normalizer
- */
- public function test_invariants(array $tested_chars)
- {
- $fp = fopen(self::$data_dir . '/UnicodeData.txt', 'rb');
-
- while (!feof($fp))
- {
- $line = fgets($fp, 1024);
-
- if (!$pos = strpos($line, ';'))
- {
- continue;
- }
-
- $hex_tested = $hex_expected = substr($line, 0, $pos);
-
- if (isset($tested_chars[$hex_tested]))
- {
- continue;
- }
-
- $utf_expected = $this->hex_to_utf($hex_expected);
-
- if ($utf_expected >= UTF8_SURROGATE_FIRST
- && $utf_expected <= UTF8_SURROGATE_LAST)
- {
- /**
- * Surrogates are illegal on their own, we expect the normalizer
- * to return a replacement char
- */
- $utf_expected = UTF8_REPLACEMENT;
- $hex_expected = $this->utf_to_hexseq($utf_expected);
- }
-
- foreach (array('nfc', 'nfkc', 'nfd', 'nfkd') as $form)
- {
- $utf_result = $utf_expected;
- call_user_func_array(array('utf_normalizer', $form), array(&$utf_result));
- $hex_result = $this->utf_to_hexseq($utf_result);
-
- $this->assertEquals($utf_expected, $utf_result, "$hex_expected == $form($hex_tested) ($hex_expected != $hex_result)");
- }
- }
- fclose($fp);
- }
-
- /**
- * Convert a UTF string to a sequence of codepoints in hexadecimal
- *
- * @param string $utf UTF string
- * @return integer Unicode codepoints in hex
- */
- protected function utf_to_hexseq($str)
- {
- $pos = 0;
- $len = strlen($str);
- $ret = array();
-
- while ($pos < $len)
- {
- $c = $str[$pos];
- switch ($c & "\xF0")
- {
- case "\xC0":
- case "\xD0":
- $utf_char = substr($str, $pos, 2);
- $pos += 2;
- break;
-
- case "\xE0":
- $utf_char = substr($str, $pos, 3);
- $pos += 3;
- break;
-
- case "\xF0":
- $utf_char = substr($str, $pos, 4);
- $pos += 4;
- break;
-
- default:
- $utf_char = $c;
- ++$pos;
- }
-
- $hex = dechex($this->utf_to_cp($utf_char));
-
- if (!isset($hex[3]))
- {
- $hex = substr('000' . $hex, -4);
- }
-
- $ret[] = $hex;
- }
-
- return strtr(implode(' ', $ret), 'abcdef', 'ABCDEF');
- }
-
- /**
- * Convert a UTF-8 char to its codepoint
- *
- * @param string $utf_char UTF-8 char
- * @return integer Unicode codepoint
- */
- protected function utf_to_cp($utf_char)
- {
- switch (strlen($utf_char))
- {
- case 1:
- return ord($utf_char);
-
- case 2:
- return ((ord($utf_char[0]) & 0x1F) << 6) | (ord($utf_char[1]) & 0x3F);
-
- case 3:
- return ((ord($utf_char[0]) & 0x0F) << 12) | ((ord($utf_char[1]) & 0x3F) << 6) | (ord($utf_char[2]) & 0x3F);
-
- case 4:
- return ((ord($utf_char[0]) & 0x07) << 18) | ((ord($utf_char[1]) & 0x3F) << 12) | ((ord($utf_char[2]) & 0x3F) << 6) | (ord($utf_char[3]) & 0x3F);
-
- default:
- throw new RuntimeException('UTF-8 chars can only be 1-4 bytes long');
- }
- }
-
- /**
- * Return a UTF string formed from a sequence of codepoints in hexadecimal
- *
- * @param string $seq Sequence of codepoints, separated with a space
- * @return string UTF-8 string
- */
- protected function hexseq_to_utf($seq)
- {
- return implode('', array_map(array($this, 'hex_to_utf'), explode(' ', $seq)));
- }
-
- /**
- * Convert a codepoint in hexadecimal to a UTF-8 char
- *
- * @param string $hex Codepoint, in hexadecimal
- * @return string UTF-8 char
- */
- protected function hex_to_utf($hex)
- {
- return $this->cp_to_utf(hexdec($hex));
- }
-
- /**
- * Convert a codepoint to a UTF-8 char
- *
- * @param integer $cp Unicode codepoint
- * @return string UTF-8 string
- */
- protected function cp_to_utf($cp)
- {
- if ($cp > 0xFFFF)
- {
- return chr(0xF0 | ($cp >> 18)) . chr(0x80 | (($cp >> 12) & 0x3F)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
- }
- else if ($cp > 0x7FF)
- {
- return chr(0xE0 | ($cp >> 12)) . chr(0x80 | (($cp >> 6) & 0x3F)) . chr(0x80 | ($cp & 0x3F));
- }
- else if ($cp > 0x7F)
- {
- return chr(0xC0 | ($cp >> 6)) . chr(0x80 | ($cp & 0x3F));
- }
- else
- {
- return chr($cp);
- }
- }
-
- // chunked download helper
- static protected function download($url, $to)
- {
- $target = $to . '/' . basename($url);
-
- if (file_exists($target))
- {
- return;
- }
-
- if (!$fpr = fopen($url, 'rb'))
- {
- echo "Failed to download $url\n";
- return;
- }
-
- if (!$fpw = fopen($target, 'wb'))
- {
- echo "Failed to open $target for writing\n";
- return;
- }
-
- $chunk = 32768;
-
- while (!feof($fpr))
- {
- fwrite($fpw, fread($fpr, $chunk));
- }
- fclose($fpr);
- fclose($fpw);
- }
-}