mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-14 12:40:13 +01:00
[ticket/9657] Fix unit tests
PHPBB3-9657
This commit is contained in:
parent
9aed758c13
commit
753dc62267
@ -26,19 +26,19 @@ class phpbb_content_visibility
|
||||
* Database object
|
||||
* @var phpbb_db_driver
|
||||
*/
|
||||
protected $this->db;
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* User object
|
||||
* @var phpbb_user
|
||||
*/
|
||||
protected $this->user;
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Auth object
|
||||
* @var phpbb_auth
|
||||
*/
|
||||
protected $this->auth;
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* phpBB root path
|
||||
@ -55,18 +55,18 @@ class phpbb_content_visibility
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param phpbb_auth $this->auth Auth object
|
||||
* @param phpbb_db_driver $this->db Database object
|
||||
* @param phpbb_user $this->user User object
|
||||
* @param phpbb_auth $auth Auth object
|
||||
* @param phpbb_db_driver $db Database object
|
||||
* @param phpbb_user $user User object
|
||||
* @param string $phpbb_root_path Root path
|
||||
* @param string $php_ext PHP Extension
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($this->auth, phpbb_db_driver $this->db, $this->user, $phpbb_root_path, $phpEx, $forums_table, $posts_table, $topics_table, $users_table)
|
||||
public function __construct($auth, phpbb_db_driver $db, $user, $phpbb_root_path, $phpEx, $forums_table, $posts_table, $topics_table, $users_table)
|
||||
{
|
||||
$this->auth = $this->auth;
|
||||
$this->db = $this->db;
|
||||
$this->user = $this->user;
|
||||
$this->auth = $auth;
|
||||
$this->db = $db;
|
||||
$this->user = $user;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->php_ext = $php_ext;
|
||||
$this->forums_table = $forums_table;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user