1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-20 07:21:30 +02:00

[ticket/16345] Small improvements

PHPBB3-16346
This commit is contained in:
rubencm
2020-06-07 02:15:35 +00:00
parent 3cceeb45bf
commit 774c609c4a
284 changed files with 1380 additions and 835 deletions

View File

@@ -32,36 +32,28 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_get_group_value($group_id, $expected, $throws_exception)
{
global $cache, $phpbb_root_path, $phpEx;
global $cache;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$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 = array();
if ($throws_exception)
{
$this->expectException($throws_exception);
}
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
$test_class = new \phpbb\groupposition\teampage($db, $cache);
$this->assertEquals($expected, $test_class->get_group_value($group_id));
}
public function test_get_group_count()
{
global $cache, $phpbb_root_path, $phpEx;
global $cache;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$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 = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
$test_class = new \phpbb\groupposition\teampage($db, $cache);
$this->assertEquals(8, $test_class->get_group_count());
}
@@ -138,16 +130,12 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_add_group_teampage($group_id, $parent_id, $expected_added, $expected)
{
global $cache, $phpbb_root_path, $phpEx;
global $cache;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$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 = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
$test_class = new \phpbb\groupposition\teampage($db, $cache);
$this->assertEquals($expected_added, $test_class->add_group_teampage($group_id, $parent_id));
$result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name
@@ -183,16 +171,12 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_add_category_teampage($group_name, $expected_added, $expected)
{
global $cache, $phpbb_root_path, $phpEx;
global $cache;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$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 = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
$test_class = new \phpbb\groupposition\teampage($db, $cache);
$this->assertEquals($expected_added, $test_class->add_category_teampage($group_name));
$result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name
@@ -252,16 +236,12 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_delete_group($group_id, $expected_deleted, $expected)
{
global $cache, $phpbb_root_path, $phpEx;
global $cache;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$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 = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
$test_class = new \phpbb\groupposition\teampage($db, $cache);
$this->assertEquals($expected_deleted, $test_class->delete_group($group_id, false));
$result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name
@@ -306,16 +286,12 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_delete_teampage($teampage_id, $expected_deleted, $expected)
{
global $cache, $phpbb_root_path, $phpEx;
global $cache;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$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 = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
$test_class = new \phpbb\groupposition\teampage($db, $cache);
$this->assertEquals($expected_deleted, $test_class->delete_teampage($teampage_id, false));
$result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name
@@ -471,16 +447,12 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_move($group_id, $move_delta, $excepted_moved, $expected)
{
global $cache, $phpbb_root_path, $phpEx;
global $cache;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$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 = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
$test_class = new \phpbb\groupposition\teampage($db, $cache);
$this->assertEquals($excepted_moved, $test_class->move($group_id, $move_delta));
$result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name
@@ -636,16 +608,12 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
*/
public function test_move_teampage($teampage_id, $move_delta, $excepted_moved, $expected)
{
global $cache, $phpbb_root_path, $phpEx;
global $cache;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$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 = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
$test_class = new \phpbb\groupposition\teampage($db, $cache);
$this->assertEquals($excepted_moved, $test_class->move_teampage($teampage_id, $move_delta));
$result = $db->sql_query('SELECT teampage_position, group_id, teampage_parent, teampage_name
@@ -655,4 +623,3 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$this->assertEquals($expected, $db->sql_fetchrowset($result));
}
}