diff options
author | 2020-01-09 20:34:59 +0100 | |
---|---|---|
committer | 2020-01-09 20:34:59 +0100 | |
commit | d50d878e7bdbcc9043da5534ed0ed38d4a4022e8 (patch) | |
tree | 63f1c7bac8cafe9e9debe70c8a135f307adcec19 /tests | |
parent | Merge branch '3.3.x' (diff) | |
parent | Merge pull request #5812 from rxu/ticket/16288 (diff) | |
download | phpbb-d50d878e7bdbcc9043da5534ed0ed38d4a4022e8.tar.gz phpbb-d50d878e7bdbcc9043da5534ed0ed38d4a4022e8.tar.bz2 phpbb-d50d878e7bdbcc9043da5534ed0ed38d4a4022e8.zip |
Merge branch '3.3.x'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/functional/feed_test.php | 6 | ||||
-rw-r--r-- | tests/functional/visibility_reapprove_test.php | 2 | ||||
-rw-r--r-- | tests/functions_user/delete_user_test.php | 2 | ||||
-rw-r--r-- | tests/mock/fileupload.php | 5 | ||||
-rw-r--r-- | tests/mock/session_testable.php | 1 | ||||
-rw-r--r-- | tests/mock/user.php | 2 | ||||
-rw-r--r-- | tests/path_helper/path_helper_test.php | 14 | ||||
-rw-r--r-- | tests/request/request_var_test.php | 2 | ||||
-rw-r--r-- | tests/search/common_test_case.php | 3 | ||||
-rw-r--r-- | tests/search/native_test.php | 6 | ||||
-rw-r--r-- | tests/security/base.php | 1 | ||||
-rw-r--r-- | tests/security/redirect_test.php | 6 | ||||
-rw-r--r-- | tests/session/fixtures/sessions_full.xml | 6 | ||||
-rw-r--r-- | tests/session/fixtures/sessions_key.xml | 11 | ||||
-rw-r--r-- | tests/test_framework/phpbb_database_test_case.php | 40 | ||||
-rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 6 | ||||
-rw-r--r-- | tests/version/version_helper_remote_test.php | 4 |
17 files changed, 86 insertions, 31 deletions
diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 24ddca9c64..8f6fc25650 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -850,10 +850,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->set_flood_interval(0); $this->login('disapprove_user'); - $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); - $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; - $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}"); + $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); + $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}"); self::assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); $this->logout(); @@ -1240,6 +1239,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case 'posts' => array( 'Feeds #1 - Topic #3', ), + 'attachments' => array(), )); $this->add_lang('viewtopic'); diff --git a/tests/functional/visibility_reapprove_test.php b/tests/functional/visibility_reapprove_test.php index 5af2ddafa4..6a6e2edf18 100644 --- a/tests/functional/visibility_reapprove_test.php +++ b/tests/functional/visibility_reapprove_test.php @@ -226,7 +226,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link(); $link_url = $link->getUri(); - $this->assertContains('viewtopic.php?f=' . $this->data['topic']['Reapprove Test Topic #2'], $link_url); + $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'], $link_url); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}"); $this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text()); diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index aee21e33bd..52fb4f3d42 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -196,6 +196,8 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case */ public function test_first_last_post_info($mode, $retain_username, $expected_posts, $expected_topics, $expected_forums) { + global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; + $this->assertFalse(user_delete($mode, 2, $retain_username)); $sql = 'SELECT post_id, poster_id, post_username diff --git a/tests/mock/fileupload.php b/tests/mock/fileupload.php index 5a0afc6cd3..83c43d8af0 100644 --- a/tests/mock/fileupload.php +++ b/tests/mock/fileupload.php @@ -21,6 +21,11 @@ class phpbb_mock_fileupload public $error_prefix = ''; public $valid_dimensions = true; + public $min_width = 0; + public $min_height = 0; + public $max_width = 0; + public $max_height = 0; + public function valid_dimensions($filespec) { return $this->valid_dimensions; diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php index 7828a864d4..fea5db6fb9 100644 --- a/tests/mock/session_testable.php +++ b/tests/mock/session_testable.php @@ -21,6 +21,7 @@ class phpbb_mock_session_testable extends \phpbb\session { private $_cookies = array(); + public $lang = []; public function set_cookie($name, $data, $time, $httponly = true) { diff --git a/tests/mock/user.php b/tests/mock/user.php index 9888337a9e..d9211369bc 100644 --- a/tests/mock/user.php +++ b/tests/mock/user.php @@ -21,6 +21,8 @@ class phpbb_mock_user { public $host = "testhost"; public $page = array('root_script_path' => '/'); + public $style = []; + public $data = []; private $options = array(); public function optionget($item) diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 1479c57051..bca0f0eb07 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -102,13 +102,6 @@ class phpbb_path_helper_test extends phpbb_test_case array( $this->phpbb_root_path . 'test.php', '//', - null, - null, - './../', - ), - array( - $this->phpbb_root_path . 'test.php', - '//', 'foo/bar.php', 'bar.php', './../', @@ -139,13 +132,6 @@ class phpbb_path_helper_test extends phpbb_test_case array( './../' . $this->phpbb_root_path . 'test.php', '//', - null, - null, - '', - ), - array( - './../' . $this->phpbb_root_path . 'test.php', - '//', 'foo/bar.php', 'bar.php', '', diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php index 8dc8e4c7c7..c95dce46d0 100644 --- a/tests/request/request_var_test.php +++ b/tests/request/request_var_test.php @@ -110,7 +110,7 @@ class phpbb_request_var_test extends phpbb_test_case ); $result = request_var($path, $default); - $this->assertEquals($expected, $result, 'Testing deep access to multidimensional input arrays: ' . $path); + $this->assertEquals($expected, $result); } public function deep_access() diff --git a/tests/search/common_test_case.php b/tests/search/common_test_case.php index 0bb4549832..d157d3ae7e 100644 --- a/tests/search/common_test_case.php +++ b/tests/search/common_test_case.php @@ -200,6 +200,9 @@ abstract class phpbb_search_common_test_case extends phpbb_search_test_case $this->assertEquals($ok, $rv); if ($ok) { + // If there are valid keywords, search->split_keywords perfoms array sort + sort($split_words); + // only check criteria if the search is going to be performed $this->assert_array_content_equals($split_words, $this->search->get_split_words()); } diff --git a/tests/search/native_test.php b/tests/search/native_test.php index 2e11eaff14..ba37660b1f 100644 --- a/tests/search/native_test.php +++ b/tests/search/native_test.php @@ -195,7 +195,7 @@ class phpbb_search_native_test extends phpbb_search_test_case 'foo foo-', 'all', true, - array(1), + array(1, 1), array(), array(), ), @@ -203,7 +203,7 @@ class phpbb_search_native_test extends phpbb_search_test_case 'foo- foo', 'all', true, - array(1), + array(1, 1), array(), array(), ), @@ -219,7 +219,7 @@ class phpbb_search_native_test extends phpbb_search_test_case 'foo-bar-foo', 'all', true, - array(1, 2), + array(1, 2, 1), array(), array(), ), diff --git a/tests/security/base.php b/tests/security/base.php index ad518b5543..77747bf243 100644 --- a/tests/security/base.php +++ b/tests/security/base.php @@ -52,7 +52,6 @@ abstract class phpbb_security_test_base extends phpbb_test_case $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $lang = new \phpbb\language\language($lang_loader); $user = new \phpbb\user($lang, '\phpbb\datetime'); - $user->lang = true; $user->browser = $this->server['HTTP_USER_AGENT']; $user->referer = ''; $user->forwarded_for = ''; diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php index 9f1b2d99ff..4630bc8dc5 100644 --- a/tests/security/redirect_test.php +++ b/tests/security/redirect_test.php @@ -60,6 +60,8 @@ class phpbb_security_redirect_test extends phpbb_security_test_base protected function get_path_helper() { + global $phpbb_root_path; + if (!($this->path_helper instanceof \phpbb\path_helper)) { $this->path_helper = new \phpbb\path_helper( @@ -67,7 +69,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base new phpbb_mock_request() ), $this->createMock('\phpbb\request\request'), - $this->phpbb_root_path, + $phpbb_root_path, 'php' ); } @@ -108,7 +110,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base if ($expected_error !== false) { - $this->setExpectedTriggerError(E_USER_WARNING, $user->lang[$expected_error]); + $this->setExpectedTriggerError(E_USER_WARNING, $expected_error); } $result = redirect($test, true, $disable_cd_check); diff --git a/tests/session/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml index 4fb6b9dfd4..268e19f905 100644 --- a/tests/session/fixtures/sessions_full.xml +++ b/tests/session/fixtures/sessions_full.xml @@ -23,6 +23,12 @@ <value></value> <value></value> </row> + <row> + <value>13</value> + <value>bot</value> + <value></value> + <value></value> + </row> </table> <table name="phpbb_sessions"> <column>session_id</column> diff --git a/tests/session/fixtures/sessions_key.xml b/tests/session/fixtures/sessions_key.xml index 245f89a604..0653dfee82 100644 --- a/tests/session/fixtures/sessions_key.xml +++ b/tests/session/fixtures/sessions_key.xml @@ -29,11 +29,20 @@ <column>username_clean</column> <column>user_permissions</column> <column>user_sig</column> - <row> + <column>user_type</column> + <row> <value>4</value> <value>bar</value> <value></value> <value></value> + <value>0</value> + </row> + <row> + <value>1</value> + <value>anonymous</value> + <value></value> + <value></value> + <value>2</value> </row> </table> </dataset> diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 0197b3c68d..ccd9044e65 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -304,11 +304,45 @@ abstract class phpbb_database_test_case extends TestCase return new phpbb_database_test_connection_manager($config); } + /** array_diff() does not corretly compare multidimensionsl arrays + * This solution used for that https://www.codeproject.com/Questions/780780/PHP-Finding-differences-in-two-multidimensional-ar + */ + function array_diff_assoc_recursive($array1, $array2) + { + $difference = array(); + foreach ($array1 as $key => $value) + { + if (is_array($value)) + { + if (!isset($array2[$key])) + { + $difference[$key] = $value; + } + else if (!is_array($array2[$key])) + { + $difference[$key] = $value; + } + else + { + $new_diff = $this->array_diff_assoc_recursive($value, $array2[$key]); + if (!empty($new_diff)) + { + $difference[$key] = $new_diff; + } + } + } + else if (!isset($array2[$key]) || $array2[$key] != $value) + { + $difference[$key] = $value; + } + } + return $difference; + } + public function assert_array_content_equals($one, $two) { - // http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important - // but one array_diff is not enough! - if (count(array_diff($one, $two)) || count(array_diff($two, $one))) + // one-way comparison is not enough! + if (count($this->array_diff_assoc_recursive($one, $two)) || count($this->array_diff_assoc_recursive($two, $one))) { // get a nice error message $this->assertEquals($one, $two); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 7538a453ac..abf83d777b 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -709,7 +709,7 @@ class phpbb_functional_test_case extends phpbb_test_case protected function remove_user_group($group_name, $usernames) { - global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; + global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $user, $phpbb_root_path, $phpEx; $config = new \phpbb\config\config(array()); $config['coppa_enable'] = 0; @@ -746,7 +746,7 @@ class phpbb_functional_test_case extends phpbb_test_case protected function add_user_group($group_name, $usernames, $default = false, $leader = false) { - global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $phpbb_root_path, $phpEx; + global $db, $cache, $auth, $config, $phpbb_dispatcher, $phpbb_log, $phpbb_container, $user, $phpbb_root_path, $phpEx; $config = new \phpbb\config\config(array()); $config['coppa_enable'] = 0; @@ -868,6 +868,8 @@ class phpbb_functional_test_case extends phpbb_test_case { $this->add_lang($file); } + + return; } $lang_path = __DIR__ . "/../../phpBB/language/en/$lang_file.php"; diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php index e15ff897b0..d392d6d256 100644 --- a/tests/version/version_helper_remote_test.php +++ b/tests/version/version_helper_remote_test.php @@ -203,6 +203,10 @@ class version_helper_remote_test extends \phpbb_test_case { $this->file_downloader->set($input); + // version_helper->get_versions() doesn't return a value on VERSIONCHECK_FAIL but only throws exception + // so the $return is undefined. Define it here + $return = false; + if (!$valid_data) { try { |