diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2013-07-11 15:02:07 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2013-07-11 15:02:07 +0200 |
commit | 753dc62267118e44b16653113521fe6d0a360720 (patch) | |
tree | 5f96411a594a61781de9247a68d36ae626b964fb /tests/content_visibility | |
parent | 9aed758c1397c31b979f4aca51249c73d21bd6f5 (diff) | |
download | forums-753dc62267118e44b16653113521fe6d0a360720.tar forums-753dc62267118e44b16653113521fe6d0a360720.tar.gz forums-753dc62267118e44b16653113521fe6d0a360720.tar.bz2 forums-753dc62267118e44b16653113521fe6d0a360720.tar.xz forums-753dc62267118e44b16653113521fe6d0a360720.zip |
[ticket/9657] Fix unit tests
PHPBB3-9657
Diffstat (limited to 'tests/content_visibility')
6 files changed, 24 insertions, 14 deletions
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index e7ab3e3879..6234aac9ad 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -262,16 +262,13 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case */ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum) { - global $auth, $cache, $config, $db, $phpbb_container; + global $auth, $cache, $config, $db, $phpbb_container, $phpbb_root_path, $phpEx; $config['search_type'] = 'phpbb_mock_search'; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); set_config_count(null, null, null, new phpbb_config(array('num_posts' => 3, 'num_topics' => 1))); - $phpbb_container = new phpbb_mock_container_builder(); - $phpbb_container->set('notification_manager', new phpbb_mock_notification_manager()); - // Create auth mock $auth = $this->getMock('phpbb_auth'); $auth->expects($this->any()) @@ -280,6 +277,11 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case ->will($this->returnValueMap(array( array('m_approve', 1, true), ))); + $user = $this->getMock('phpbb_user'); + + $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, $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/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php index 236b08f74c..7580a53fa4 100644 --- a/tests/content_visibility/get_forums_visibility_sql_test.php +++ b/tests/content_visibility/get_forums_visibility_sql_test.php @@ -119,7 +119,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data */ public function test_get_forums_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -131,9 +131,11 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); + $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_forums_visibility_sql($mode, $forum_ids, $table_alias) . ' + WHERE ' . $content_visibility->get_forums_visibility_sql($mode, $forum_ids, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php index 9d320a4ee7..bdb0a96954 100644 --- a/tests/content_visibility/get_global_visibility_sql_test.php +++ b/tests/content_visibility/get_global_visibility_sql_test.php @@ -119,7 +119,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data */ public function test_get_global_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -130,10 +130,11 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data ->method('acl_getf') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_global_visibility_sql($mode, $forum_ids, $table_alias) . ' + WHERE ' . $content_visibility->get_global_visibility_sql($mode, $forum_ids, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php index 4af8c062e7..f75c98f899 100644 --- a/tests/content_visibility/get_visibility_sql_test.php +++ b/tests/content_visibility/get_visibility_sql_test.php @@ -66,7 +66,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te */ public function test_get_visibility_sql($table, $mode, $forum_id, $table_alias, $permissions, $expected) { - global $cache, $db, $auth; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); @@ -77,10 +77,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te ->method('acl_get') ->with($this->stringContains('_'), $this->anything()) ->will($this->returnValueMap($permissions)); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); $result = $db->sql_query('SELECT ' . $mode . '_id FROM ' . $table . ' - WHERE ' . phpbb_content_visibility::get_visibility_sql($mode, $forum_id, $table_alias) . ' + WHERE ' . $content_visibility->get_visibility_sql($mode, $forum_id, $table_alias) . ' ORDER BY ' . $mode . '_id ASC'); $this->assertEquals($expected, $db->sql_fetchrowset($result)); diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php index 8f83457cae..845430b21b 100644 --- a/tests/content_visibility/set_post_visibility_test.php +++ b/tests/content_visibility/set_post_visibility_test.php @@ -115,12 +115,14 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t */ public function test_set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $expected, $expected_topic) { - global $cache, $db; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); + $auth = $this->getMock('phpbb_auth'); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); - phpbb_content_visibility::set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); + $content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest); $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason FROM phpbb_posts diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php index 31a6b37caa..3061ba44db 100644 --- a/tests/content_visibility/set_topic_visibility_test.php +++ b/tests/content_visibility/set_topic_visibility_test.php @@ -79,12 +79,14 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_ */ public function test_set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all, $expected_posts, $expected_topic) { - global $cache, $db; + global $cache, $db, $auth, $phpbb_root_path, $phpEx; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); + $auth = $this->getMock('phpbb_auth'); + $content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE); - phpbb_content_visibility::set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); + $content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all); $result = $db->sql_query('SELECT post_id, post_visibility, post_delete_reason FROM phpbb_posts |