[ticket/16346] Remove code in test

PHPBB3-16346
This commit is contained in:
rubencm 2020-06-08 11:47:17 +00:00
parent 6969a9d0db
commit b13fb3298f
2 changed files with 15 additions and 45 deletions

View file

@ -32,36 +32,28 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/ */
public function test_get_group_value($group_id, $expected, $throws_exception) public function test_get_group_value($group_id, $expected, $throws_exception)
{ {
global $cache, $phpbb_root_path, $phpEx; global $cache;
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$db = $this->new_dbal(); $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) if ($throws_exception)
{ {
$this->expectException($throws_exception); $this->expectException($throws_exception);
} }
$test_class = new \phpbb\groupposition\legend($db, $user); $test_class = new \phpbb\groupposition\legend($db);
$this->assertEquals($expected, $test_class->get_group_value($group_id)); $this->assertEquals($expected, $test_class->get_group_value($group_id));
} }
public function test_get_group_count() public function test_get_group_count()
{ {
global $cache, $phpbb_root_path, $phpEx; global $cache;
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$db = $this->new_dbal(); $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\legend($db, $user); $test_class = new \phpbb\groupposition\legend($db);
$this->assertEquals(2, $test_class->get_group_count()); $this->assertEquals(2, $test_class->get_group_count());
} }
@ -94,16 +86,12 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/ */
public function test_add_group($group_id, $expected_added, $expected) public function test_add_group($group_id, $expected_added, $expected)
{ {
global $cache, $phpbb_root_path, $phpEx; global $cache;
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$db = $this->new_dbal(); $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\legend($db, $user); $test_class = new \phpbb\groupposition\legend($db);
$this->assertEquals($expected_added, $test_class->add_group($group_id)); $this->assertEquals($expected_added, $test_class->add_group($group_id));
$result = $db->sql_query('SELECT group_id, group_legend $result = $db->sql_query('SELECT group_id, group_legend
@ -184,16 +172,12 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/ */
public function test_delete_group($group_id, $skip_group, $expected_deleted, $expected) public function test_delete_group($group_id, $skip_group, $expected_deleted, $expected)
{ {
global $cache, $phpbb_root_path, $phpEx; global $cache;
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$db = $this->new_dbal(); $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\legend($db, $user); $test_class = new \phpbb\groupposition\legend($db);
$this->assertEquals($expected_deleted, $test_class->delete_group($group_id, $skip_group)); $this->assertEquals($expected_deleted, $test_class->delete_group($group_id, $skip_group));
$result = $db->sql_query('SELECT group_id, group_legend $result = $db->sql_query('SELECT group_id, group_legend
@ -241,16 +225,12 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/ */
public function test_move_up($group_id, $excepted_moved, $expected) public function test_move_up($group_id, $excepted_moved, $expected)
{ {
global $cache, $phpbb_root_path, $phpEx; global $cache;
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$db = $this->new_dbal(); $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\legend($db, $user); $test_class = new \phpbb\groupposition\legend($db);
$this->assertEquals($excepted_moved, $test_class->move_up($group_id)); $this->assertEquals($excepted_moved, $test_class->move_up($group_id));
$result = $db->sql_query('SELECT group_id, group_legend $result = $db->sql_query('SELECT group_id, group_legend
@ -298,16 +278,12 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/ */
public function test_move_down($group_id, $excepted_moved, $expected) public function test_move_down($group_id, $excepted_moved, $expected)
{ {
global $cache, $phpbb_root_path, $phpEx; global $cache;
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$db = $this->new_dbal(); $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\legend($db, $user); $test_class = new \phpbb\groupposition\legend($db);
$this->assertEquals($excepted_moved, $test_class->move_down($group_id)); $this->assertEquals($excepted_moved, $test_class->move_down($group_id));
$result = $db->sql_query('SELECT group_id, group_legend $result = $db->sql_query('SELECT group_id, group_legend
@ -398,16 +374,12 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
*/ */
public function test_move($group_id, $increment, $excepted_moved, $expected) public function test_move($group_id, $increment, $excepted_moved, $expected)
{ {
global $cache, $phpbb_root_path, $phpEx; global $cache;
$cache = new phpbb_mock_cache; $cache = new phpbb_mock_cache;
$db = $this->new_dbal(); $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\legend($db, $user); $test_class = new \phpbb\groupposition\legend($db);
$this->assertEquals($excepted_moved, $test_class->move($group_id, $increment)); $this->assertEquals($excepted_moved, $test_class->move($group_id, $increment));
$result = $db->sql_query('SELECT group_id, group_legend $result = $db->sql_query('SELECT group_id, group_legend
@ -417,4 +389,3 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
$this->assertEquals($expected, $db->sql_fetchrowset($result)); $this->assertEquals($expected, $db->sql_fetchrowset($result));
} }
} }

View file

@ -40,8 +40,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
include_once($phpbb_root_path . 'includes/functions_content.' . $phpEx); include_once($phpbb_root_path . 'includes/functions_content.' . $phpEx);
$this->container->set('groupposition.legend', new \phpbb\groupposition\legend( $this->container->set('groupposition.legend', new \phpbb\groupposition\legend(
$this->db, $this->db
$this->user
)); ));
$this->container->set('groupposition.teampage', new \phpbb\groupposition\teampage( $this->container->set('groupposition.teampage', new \phpbb\groupposition\teampage(
$this->db, $this->db,