From 1bc9cbefb2e4ca30744002c4e8de0fab15920def Mon Sep 17 00:00:00 2001 From: rubencm Date: Sat, 15 Aug 2020 13:05:54 +0000 Subject: [PATCH] [ticket/15540] Fix tests PHPBB3-15540 --- .../default/container/services_search.yml | 3 - phpBB/includes/mcp/mcp_main.php | 2 +- phpBB/includes/mcp/mcp_topic.php | 2 +- phpBB/phpbb/search/backend/fulltext_mysql.php | 10 +-- .../phpbb/search/backend/fulltext_native.php | 35 ++++---- .../search/backend/fulltext_postgres.php | 23 ++--- .../phpbb/search/backend/fulltext_sphinx.php | 25 +++--- tests/content_visibility/delete_post_test.php | 2 +- tests/functional/search/base.php | 2 +- tests/functional/search/mysql_test.php | 2 +- tests/functional/search/native_test.php | 2 +- tests/functional/search/postgres_test.php | 2 +- tests/functional/search/sphinx_test.php | 2 +- tests/mock/search.php | 90 ------------------- tests/search/mysql_test.php | 2 +- tests/search/native_test.php | 2 +- tests/search/postgres_test.php | 2 +- 17 files changed, 62 insertions(+), 146 deletions(-) delete mode 100644 tests/mock/search.php diff --git a/phpBB/config/default/container/services_search.yml b/phpBB/config/default/container/services_search.yml index 0ceb7e06c3..0ec01e187e 100644 --- a/phpBB/config/default/container/services_search.yml +++ b/phpBB/config/default/container/services_search.yml @@ -4,7 +4,6 @@ services: search.fulltext.native: class: phpbb\search\backend\fulltext_native arguments: - - '@auth' - '@config' - '@dbal.conn' - '@dispatcher' @@ -17,7 +16,6 @@ services: search.fulltext.mysql: class: phpbb\search\backend\fulltext_mysql arguments: - - '@auth' - '@config' - '@dbal.conn' - '@dispatcher' @@ -30,7 +28,6 @@ services: search.fulltext.postgres: class: phpbb\search\backend\fulltext_postgres arguments: - - '@auth' - '@config' - '@dbal.conn' - '@dispatcher' diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 966be7cd91..5d61ac640d 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1330,7 +1330,7 @@ function mcp_delete_post($post_ids, $is_soft = false, $soft_delete_reason = '', */ function mcp_fork_topic($topic_ids) { - global $auth, $user, $db, $template, $config; + global $auth, $user, $db, $template, $config, $phpbb_container; global $phpEx, $phpbb_root_path, $phpbb_log, $request, $phpbb_dispatcher; if (!phpbb_check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_'))) diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 3c37fa4d66..0aa6160831 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -428,7 +428,7 @@ function mcp_topic_view($id, $mode, $action) */ function split_topic($action, $topic_id, $to_forum_id, $subject) { - global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request; + global $db, $template, $user, $phpEx, $phpbb_root_path, $auth, $config, $phpbb_log, $request, $phpbb_container; $post_id_list = $request->variable('post_id_list', array(0)); $forum_id = $request->variable('forum_id', 0); diff --git a/phpBB/phpbb/search/backend/fulltext_mysql.php b/phpBB/phpbb/search/backend/fulltext_mysql.php index f71c9d21e9..2da5ab2221 100644 --- a/phpBB/phpbb/search/backend/fulltext_mysql.php +++ b/phpBB/phpbb/search/backend/fulltext_mysql.php @@ -78,16 +78,14 @@ class fulltext_mysql extends base implements search_backend_interface * Constructor * Creates a new \phpbb\search\backend\fulltext_mysql, which is used as a search backend * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false - * @param string $phpbb_root_path Relative path to phpBB root - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\config\config $config Config object * @param \phpbb\db\driver\driver_interface $db Database object + * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object + * @param string $phpbb_root_path Relative path to phpBB root + * @param string $phpEx PHP file extension */ - public function __construct($auth, $config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx) + public function __construct($config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx) { $this->config = $config; $this->db = $db; diff --git a/phpBB/phpbb/search/backend/fulltext_native.php b/phpBB/phpbb/search/backend/fulltext_native.php index 99f47f8b9c..7341c77ba1 100644 --- a/phpBB/phpbb/search/backend/fulltext_native.php +++ b/phpBB/phpbb/search/backend/fulltext_native.php @@ -13,6 +13,11 @@ namespace phpbb\search\backend; +use phpbb\config\config; +use phpbb\db\driver\driver_interface; +use phpbb\event\dispatcher_interface; +use phpbb\user; + /** * phpBB's own db driven fulltext search, version 2 */ @@ -83,41 +88,39 @@ class fulltext_native extends base implements search_backend_interface /** * Config object - * @var \phpbb\config\config + * @var config */ protected $config; /** * Database connection - * @var \phpbb\db\driver\driver_interface + * @var driver_interface */ protected $db; /** * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface + * @var dispatcher_interface */ protected $phpbb_dispatcher; /** * User object - * @var \phpbb\user + * @var user */ protected $user; /** - * Initialises the fulltext_native search backend with min/max word length - * - * @param boolean|string &$error is passed by reference and should either be set to false on success or an error message on failure - * @param string $phpbb_root_path phpBB root path - * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface $db Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object - */ - public function __construct($auth, $config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx) + * Initialises the fulltext_native search backend with min/max word length + * + * @param config $config Config object + * @param driver_interface $db Database object + * @param dispatcher_interface $phpbb_dispatcher Event dispatcher object + * @param user $user User object + * @param string $phpbb_root_path phpBB root path + * @param string $phpEx PHP file extension + */ + public function __construct($config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx) { $this->config = $config; $this->db = $db; diff --git a/phpBB/phpbb/search/backend/fulltext_postgres.php b/phpBB/phpbb/search/backend/fulltext_postgres.php index b0652a361d..087f76559b 100644 --- a/phpBB/phpbb/search/backend/fulltext_postgres.php +++ b/phpBB/phpbb/search/backend/fulltext_postgres.php @@ -13,6 +13,11 @@ namespace phpbb\search\backend; +use phpbb\config\config; +use phpbb\db\driver\driver_interface; +use phpbb\event\dispatcher_interface; +use phpbb\user; + /** * Fulltext search for PostgreSQL */ @@ -45,7 +50,7 @@ class fulltext_postgres extends base implements search_backend_interface /** * Config object - * @var \phpbb\config\config + * @var config */ protected $config; @@ -57,13 +62,13 @@ class fulltext_postgres extends base implements search_backend_interface /** * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface + * @var dispatcher_interface */ protected $phpbb_dispatcher; /** * User object - * @var \phpbb\user + * @var user */ protected $user; @@ -91,16 +96,14 @@ class fulltext_postgres extends base implements search_backend_interface * Constructor * Creates a new \phpbb\search\backend\fulltext_postgres, which is used as a search backend * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false + * @param config $config Config object + * @param driver_interface $db Database object + * @param dispatcher_interface $phpbb_dispatcher Event dispatcher object + * @param user $user User object * @param string $phpbb_root_path Relative path to phpBB root * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object */ - public function __construct($auth, $config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx) + public function __construct($config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx) { $this->config = $config; $this->db = $db; diff --git a/phpBB/phpbb/search/backend/fulltext_sphinx.php b/phpBB/phpbb/search/backend/fulltext_sphinx.php index 7a21878303..4212eddfb1 100644 --- a/phpBB/phpbb/search/backend/fulltext_sphinx.php +++ b/phpBB/phpbb/search/backend/fulltext_sphinx.php @@ -13,6 +13,11 @@ namespace phpbb\search\backend; +use phpbb\auth\auth; +use phpbb\config\config; +use phpbb\event\dispatcher_interface; +use phpbb\user; + define('SPHINX_MAX_MATCHES', 20000); define('SPHINX_CONNECT_RETRIES', 3); define('SPHINX_CONNECT_WAIT_TIME', 300); @@ -67,13 +72,13 @@ class fulltext_sphinx implements search_backend_interface /** * Auth object - * @var \phpbb\auth\auth + * @var auth */ protected $auth; /** * Config object - * @var \phpbb\config\config + * @var config */ protected $config; @@ -97,13 +102,13 @@ class fulltext_sphinx implements search_backend_interface /** * phpBB event dispatcher object - * @var \phpbb\event\dispatcher_interface + * @var dispatcher_interface */ protected $phpbb_dispatcher; /** * User object - * @var \phpbb\user + * @var user */ protected $user; @@ -124,14 +129,14 @@ class fulltext_sphinx implements search_backend_interface * Constructor * Creates a new \phpbb\search\backend\fulltext_postgres, which is used as a search backend * - * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false + * @param auth $auth Auth object + * @param config $config Config object + * @param $db + * @param dispatcher_interface $phpbb_dispatcher Event dispatcher object + * @param user $user User object * @param string $phpbb_root_path Relative path to phpBB root * @param string $phpEx PHP file extension - * @param \phpbb\auth\auth $auth Auth object - * @param \phpbb\config\config $config Config object - * @param \phpbb\db\driver\driver_interface Database object - * @param \phpbb\user $user User object - * @param \phpbb\event\dispatcher_interface $phpbb_dispatcher Event dispatcher object + * @throws \Exception */ public function __construct($auth, $config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx) { diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 009a817766..bba1281551 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -292,7 +292,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $config = new \phpbb\config\config(array( 'num_posts' => 3, 'num_topics' => 1, - 'search_type' => 'phpbb_mock_search', + 'search_type' => 'foo', )); $cache = new phpbb_mock_cache; $db = $this->new_dbal(); diff --git a/tests/functional/search/base.php b/tests/functional/search/base.php index 0558c8e8de..b849724bf9 100644 --- a/tests/functional/search/base.php +++ b/tests/functional/search/base.php @@ -38,7 +38,7 @@ abstract class phpbb_functional_search_base extends phpbb_functional_test_case $this->login(); $this->admin_login(); - $this->create_search_index('\phpbb\search\backend\fulltext_native'); + $this->create_search_index('phpbb\search\backend\fulltext_native'); $post = $this->create_topic(2, 'Test Topic 1 foosubject', 'This is a test topic posted by the barsearch testing framework.'); diff --git a/tests/functional/search/mysql_test.php b/tests/functional/search/mysql_test.php index 43e5c5cab2..50b2d6487b 100644 --- a/tests/functional/search/mysql_test.php +++ b/tests/functional/search/mysql_test.php @@ -18,7 +18,7 @@ require_once __DIR__ . '/base.php'; */ class phpbb_functional_search_mysql_test extends phpbb_functional_search_base { - protected $search_backend = '\phpbb\search\backend\fulltext_mysql'; + protected $search_backend = 'phpbb\search\backend\fulltext_mysql'; protected function create_search_index($backend = null) { diff --git a/tests/functional/search/native_test.php b/tests/functional/search/native_test.php index f95ce3184d..5b8d8f2206 100644 --- a/tests/functional/search/native_test.php +++ b/tests/functional/search/native_test.php @@ -18,5 +18,5 @@ require_once __DIR__ . '/base.php'; */ class phpbb_functional_search_native_test extends phpbb_functional_search_base { - protected $search_backend = '\phpbb\search\backend\fulltext_native'; + protected $search_backend = 'phpbb\search\backend\fulltext_native'; } diff --git a/tests/functional/search/postgres_test.php b/tests/functional/search/postgres_test.php index ae8f717232..4389705d66 100644 --- a/tests/functional/search/postgres_test.php +++ b/tests/functional/search/postgres_test.php @@ -18,6 +18,6 @@ require_once __DIR__ . '/base.php'; */ class phpbb_functional_search_postgres_test extends phpbb_functional_search_base { - protected $search_backend = '\phpbb\search\backend\fulltext_postgres'; + protected $search_backend = 'phpbb\search\backend\fulltext_postgres'; } diff --git a/tests/functional/search/sphinx_test.php b/tests/functional/search/sphinx_test.php index 6a8907ed03..6e42da0e86 100644 --- a/tests/functional/search/sphinx_test.php +++ b/tests/functional/search/sphinx_test.php @@ -18,7 +18,7 @@ require_once __DIR__ . '/base.php'; */ class phpbb_functional_search_sphinx_test extends phpbb_functional_search_base { - protected $search_backend = '\phpbb\search\backend\fulltext_sphinx'; + protected $search_backend = 'phpbb\search\backend\fulltext_sphinx'; public function test_search_backend() { diff --git a/tests/mock/search.php b/tests/mock/search.php deleted file mode 100644 index 6aa9c52a80..0000000000 --- a/tests/mock/search.php +++ /dev/null @@ -1,90 +0,0 @@ - -* @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_search implements \phpbb\search\backend\search_backend_interface -{ - - public function __construct($auth, $config, $db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx) - { - } - - public function get_name() - { - } - - public function get_search_query() - { - } - - public function get_common_words() - { - } - - public function get_word_length() - { - } - - public function init() - { - } - - public function split_keywords(&$keywords, $terms) - { - } - - public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - } - - public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $post_visibility, $topic_id, $author_ary, $author_name, &$id_ary, &$start, $per_page) - { - } - - public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id) - { - } - - public function index_remove($post_ids, $author_ids, $forum_ids) - { - } - - public function tidy() - { - } - - public function create_index($acp_module, $u_action) - { - } - - public function delete_index($acp_module, $u_action) - { - } - - public function index_created() - { - } - - public function index_stats() - { - } - - protected function get_stats() - { - } - - public function acp() - { - } -} diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php index b0f99ea9c2..75f534c328 100644 --- a/tests/search/mysql_test.php +++ b/tests/search/mysql_test.php @@ -38,6 +38,6 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case $this->db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $class = self::get_search_wrapper('\phpbb\search\backend\fulltext_mysql'); - $this->search = new $class($auth, $config, $this->db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx); + $this->search = new $class($config, $this->db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx); } } diff --git a/tests/search/native_test.php b/tests/search/native_test.php index e342dd21c5..652206e1b4 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -36,7 +36,7 @@ class phpbb_search_native_test extends phpbb_search_test_case $class = self::get_search_wrapper('\phpbb\search\backend\fulltext_native'); $config['fulltext_native_min_chars'] = 2; $config['fulltext_native_max_chars'] = 14; - $this->search = new $class($auth, $config, $this->db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx); + $this->search = new $class($config, $this->db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx); } public function keywords() diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php index c08fb1de5d..5f2466a76b 100644 --- a/tests/search/postgres_test.php +++ b/tests/search/postgres_test.php @@ -38,6 +38,6 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case $this->db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $class = self::get_search_wrapper('\phpbb\search\backend\fulltext_postgres'); - $this->search = new $class($auth, $config, $this->db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx); + $this->search = new $class($config, $this->db, $phpbb_dispatcher, $user, $phpbb_root_path, $phpEx); } }