コード例 #1
0
    /**
     * @dataProvider set_topic_visibility_data
     */
    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, $auth, $phpbb_root_path, $phpEx;
        $cache = new phpbb_mock_cache();
        $db = $this->new_dbal();
        $auth = $this->getMock('\\phpbb\\auth\\auth');
        $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');
        $config = new phpbb\config\config(array());
        $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
        $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
        $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
			WHERE topic_id = ' . $topic_id . '
			ORDER BY post_id ASC');
        $this->assertEquals($expected_posts, $db->sql_fetchrowset($result));
        $db->sql_freeresult($result);
        $result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id, topic_delete_reason
			FROM phpbb_topics
			WHERE topic_id = ' . $topic_id);
        $this->assertEquals($expected_topic, $db->sql_fetchrowset($result));
        $db->sql_freeresult($result);
    }
コード例 #2
0
    /**
     * @dataProvider set_post_soft_deleted_data
     */
    public function test_set_post_soft_deleted($post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest, $expected)
    {
        global $cache, $db, $auth, $phpbb_root_path, $phpEx;
        $cache = new phpbb_mock_cache();
        $db = $this->new_dbal();
        $auth = $this->getMock('\\phpbb\\auth\\auth');
        $user = new \phpbb\user('\\phpbb\\datetime');
        $config = new phpbb\config\config(array());
        $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
        $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
        $content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest);
        $result = $db->sql_query('SELECT topic_attachment
			FROM phpbb_topics
			WHERE topic_id = ' . $topic_id);
        $this->assertEquals($expected, $db->sql_fetchrowset($result));
        $db->sql_freeresult($result);
    }
コード例 #3
0
    /**
     * @dataProvider get_forums_visibility_sql_data
     */
    public function test_get_forums_visibility_sql($table, $mode, $forum_ids, $table_alias, $permissions, $expected)
    {
        global $cache, $db, $auth, $phpbb_root_path, $phpEx;
        $cache = new phpbb_mock_cache();
        $db = $this->new_dbal();
        // Create auth mock
        $auth = $this->getMock('\\phpbb\\auth\\auth');
        $auth->expects($this->any())->method('acl_getf')->with($this->stringContains('_'), $this->anything())->will($this->returnValueMap($permissions));
        $user = new \phpbb\user('\\phpbb\\datetime');
        $config = new phpbb\config\config(array());
        $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
        $content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
        $result = $db->sql_query('SELECT ' . $mode . '_id
			FROM ' . $table . '
			WHERE ' . $content_visibility->get_forums_visibility_sql($mode, $forum_ids, $table_alias) . '
			ORDER BY ' . $mode . '_id ASC');
        $this->assertEquals($expected, $db->sql_fetchrowset($result));
    }