mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-22 00:05:49 +02:00
Merge pull request #1017 from nickvergessen/feature/softdelete-1-permission
Soft delete
This commit is contained in:
310
tests/content_visibility/delete_post_test.php
Normal file
310
tests/content_visibility/delete_post_test.php
Normal file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||
require_once dirname(__FILE__) . '/../mock/search.php';
|
||||
|
||||
class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/delete_post.xml');
|
||||
}
|
||||
|
||||
public function delete_post_data()
|
||||
{
|
||||
$info_data = array(
|
||||
'topic_first_post_id' => 1,
|
||||
'topic_last_post_id' => 3,
|
||||
'topic_posts_approved' => 3,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 0,
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'post_time' => 2,
|
||||
'post_visibility' => ITEM_APPROVED,
|
||||
'post_postcount' => true,
|
||||
'poster_id' => 1,
|
||||
'post_reported' => false,
|
||||
);
|
||||
|
||||
return array(
|
||||
array(
|
||||
1, 1, 2,
|
||||
array_merge($info_data, array(
|
||||
'post_time' => 2,
|
||||
)),
|
||||
false, 'harddelete',
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
//array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'topic_first_post_id' => 1,
|
||||
'topic_last_post_id' => 3,
|
||||
'topic_posts_approved' => 2,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 0,
|
||||
'topic_delete_reason' => '',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3),
|
||||
),
|
||||
),
|
||||
array(
|
||||
1, 1, 1,
|
||||
array_merge($info_data, array(
|
||||
'post_time' => 1,
|
||||
)),
|
||||
false, 'harddelete',
|
||||
array(
|
||||
//array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'topic_first_post_id' => 2,
|
||||
'topic_last_post_id' => 3,
|
||||
'topic_posts_approved' => 2,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 0,
|
||||
'topic_delete_reason' => '',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3),
|
||||
),
|
||||
),
|
||||
array(
|
||||
1, 1, 3,
|
||||
array_merge($info_data, array(
|
||||
'post_time' => 3,
|
||||
)),
|
||||
false, 'harddelete',
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
//array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'topic_first_post_id' => 1,
|
||||
'topic_last_post_id' => 2,
|
||||
'topic_posts_approved' => 2,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 0,
|
||||
'topic_delete_reason' => '',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2),
|
||||
),
|
||||
),
|
||||
array(
|
||||
1, 1, 2,
|
||||
array_merge($info_data, array(
|
||||
'post_time' => 2,
|
||||
)),
|
||||
true, 'soft delete',
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
array('post_id' => 2, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => 'soft delete'),
|
||||
array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'topic_first_post_id' => 1,
|
||||
'topic_last_post_id' => 3,
|
||||
'topic_posts_approved' => 2,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 1,
|
||||
'topic_delete_reason' => '',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3),
|
||||
),
|
||||
),
|
||||
array(
|
||||
1, 1, 1,
|
||||
array_merge($info_data, array(
|
||||
'post_time' => 1,
|
||||
)),
|
||||
true, 'soft delete',
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => 'soft delete'),
|
||||
array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
array('post_id' => 3, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'topic_first_post_id' => 2,
|
||||
'topic_last_post_id' => 3,
|
||||
'topic_posts_approved' => 2,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 1,
|
||||
'topic_delete_reason' => '',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3),
|
||||
),
|
||||
),
|
||||
array(
|
||||
1, 1, 3,
|
||||
array_merge($info_data, array(
|
||||
'post_time' => 3,
|
||||
)),
|
||||
true, 'soft delete',
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
array('post_id' => 2, 'post_visibility' => ITEM_APPROVED, 'post_delete_reason' => ''),
|
||||
array('post_id' => 3, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => 'soft delete'),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'topic_first_post_id' => 1,
|
||||
'topic_last_post_id' => 2,
|
||||
'topic_posts_approved' => 2,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 1,
|
||||
'topic_delete_reason' => '',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
2, 2, 4,
|
||||
array(
|
||||
'topic_first_post_id' => 4,
|
||||
'topic_last_post_id' => 4,
|
||||
'topic_posts_approved' => 1,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 0,
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'post_time' => 4,
|
||||
'post_visibility' => ITEM_APPROVED,
|
||||
'post_postcount' => true,
|
||||
'poster_id' => 1,
|
||||
'post_reported' => false,
|
||||
),
|
||||
false, 'harddelete',
|
||||
array(
|
||||
),
|
||||
array(
|
||||
),
|
||||
array(
|
||||
array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 0),
|
||||
),
|
||||
),
|
||||
|
||||
array(
|
||||
2, 2, 4,
|
||||
array(
|
||||
'topic_first_post_id' => 4,
|
||||
'topic_last_post_id' => 4,
|
||||
'topic_posts_approved' => 1,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 0,
|
||||
'topic_visibility' => ITEM_APPROVED,
|
||||
'post_time' => 4,
|
||||
'post_visibility' => ITEM_APPROVED,
|
||||
'post_postcount' => true,
|
||||
'poster_id' => 1,
|
||||
'post_reported' => false,
|
||||
),
|
||||
true, 'soft delete',
|
||||
array(
|
||||
array('post_id' => 4, 'post_visibility' => ITEM_DELETED, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array(
|
||||
'topic_visibility' => ITEM_DELETED,
|
||||
'topic_first_post_id' => 4,
|
||||
'topic_last_post_id' => 4,
|
||||
'topic_posts_approved' => 0,
|
||||
'topic_posts_unapproved' => 0,
|
||||
'topic_posts_softdeleted' => 1,
|
||||
'topic_delete_reason' => 'soft delete',
|
||||
),
|
||||
),
|
||||
array(
|
||||
array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider delete_post_data
|
||||
*/
|
||||
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, $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)));
|
||||
|
||||
// Create auth mock
|
||||
$auth = $this->getMock('phpbb_auth');
|
||||
$auth->expects($this->any())
|
||||
->method('acl_get')
|
||||
->with($this->stringContains('_'), $this->anything())
|
||||
->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);
|
||||
|
||||
$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_posts_approved, topic_posts_unapproved, topic_posts_softdeleted, topic_delete_reason
|
||||
FROM phpbb_topics
|
||||
WHERE topic_id = ' . $topic_id);
|
||||
|
||||
$this->assertEquals($expected_topic, $db->sql_fetchrowset($result));
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$result = $db->sql_query('SELECT forum_posts_approved, forum_posts_unapproved, forum_posts_softdeleted, forum_topics_approved, forum_topics_unapproved, forum_topics_softdeleted, forum_last_post_id
|
||||
FROM phpbb_forums
|
||||
WHERE forum_id = ' . $forum_id);
|
||||
|
||||
$this->assertEquals($expected_forum, $db->sql_fetchrowset($result));
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
167
tests/content_visibility/fixtures/delete_post.xml
Normal file
167
tests/content_visibility/fixtures/delete_post.xml
Normal file
@@ -0,0 +1,167 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_forums">
|
||||
<column>forum_id</column>
|
||||
<column>forum_posts_approved</column>
|
||||
<column>forum_posts_unapproved</column>
|
||||
<column>forum_posts_softdeleted</column>
|
||||
<column>forum_topics_approved</column>
|
||||
<column>forum_topics_unapproved</column>
|
||||
<column>forum_topics_softdeleted</column>
|
||||
<column>forum_last_post_id</column>
|
||||
<column>forum_parents</column>
|
||||
<column>forum_desc</column>
|
||||
<column>forum_rules</column>
|
||||
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>3</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value>3</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value>4</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_topics">
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>topic_visibility</column>
|
||||
<column>topic_title</column>
|
||||
<column>topic_first_post_id</column>
|
||||
<column>topic_last_post_id</column>
|
||||
<column>topic_delete_user</column>
|
||||
<column>topic_delete_time</column>
|
||||
<column>topic_delete_reason</column>
|
||||
<column>topic_posts_approved</column>
|
||||
<column>topic_posts_unapproved</column>
|
||||
<column>topic_posts_softdeleted</column>
|
||||
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
<value>1</value>
|
||||
<value>3</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
<value>3</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
<value>4</value>
|
||||
<value>4</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_posts">
|
||||
<column>post_id</column>
|
||||
<column>poster_id</column>
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>post_visibility</column>
|
||||
<column>post_time</column>
|
||||
<column>post_text</column>
|
||||
<column>post_delete_user</column>
|
||||
<column>post_delete_time</column>
|
||||
<column>post_delete_reason</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Approved</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>3</value>
|
||||
<value>Approved</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
<value>Approved</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>user_posts</column>
|
||||
<column>username</column>
|
||||
<column>username_clean</column>
|
||||
<column>user_permissions</column>
|
||||
<column>user_sig</column>
|
||||
<column>user_occ</column>
|
||||
<column>user_interests</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
<value>user 1</value>
|
||||
<value>user 1</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
133
tests/content_visibility/fixtures/get_forums_visibility_sql.xml
Normal file
133
tests/content_visibility/fixtures/get_forums_visibility_sql.xml
Normal file
@@ -0,0 +1,133 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_topics">
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>topic_visibility</column>
|
||||
<column>topic_title</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>2</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>5</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>6</value>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>7</value>
|
||||
<value>3</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>8</value>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>9</value>
|
||||
<value>3</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_posts">
|
||||
<column>post_id</column>
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>post_visibility</column>
|
||||
<column>post_text</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>4</value>
|
||||
<value>2</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>5</value>
|
||||
<value>5</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>6</value>
|
||||
<value>6</value>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>7</value>
|
||||
<value>7</value>
|
||||
<value>3</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>8</value>
|
||||
<value>8</value>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>9</value>
|
||||
<value>9</value>
|
||||
<value>3</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
55
tests/content_visibility/fixtures/get_visibility_sql.xml
Normal file
55
tests/content_visibility/fixtures/get_visibility_sql.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_topics">
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>topic_visibility</column>
|
||||
<column>topic_title</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_posts">
|
||||
<column>post_id</column>
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>post_visibility</column>
|
||||
<column>post_text</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
162
tests/content_visibility/fixtures/set_post_visibility.xml
Normal file
162
tests/content_visibility/fixtures/set_post_visibility.xml
Normal file
@@ -0,0 +1,162 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_topics">
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>topic_visibility</column>
|
||||
<column>topic_title</column>
|
||||
<column>topic_first_post_id</column>
|
||||
<column>topic_last_post_id</column>
|
||||
<column>topic_posts_approved</column>
|
||||
<column>topic_posts_softdeleted</column>
|
||||
<column>topic_posts_unapproved</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>2 Approved posts</value>
|
||||
<value>5</value>
|
||||
<value>6</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Only 1 Approved posts</value>
|
||||
<value>8</value>
|
||||
<value>8</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_posts">
|
||||
<column>post_id</column>
|
||||
<column>poster_id</column>
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>post_visibility</column>
|
||||
<column>post_text</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>5</value>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>6</value>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved 2</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>7</value>
|
||||
<value>3</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Softdeleted</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>8</value>
|
||||
<value>1</value>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>user_posts</column>
|
||||
<column>username</column>
|
||||
<column>username_clean</column>
|
||||
<column>user_permissions</column>
|
||||
<column>user_sig</column>
|
||||
<column>user_occ</column>
|
||||
<column>user_interests</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>user 1</value>
|
||||
<value>user 1</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>user 2</value>
|
||||
<value>user 2</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>user 3</value>
|
||||
<value>user 3</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
136
tests/content_visibility/fixtures/set_topic_visibility.xml
Normal file
136
tests/content_visibility/fixtures/set_topic_visibility.xml
Normal file
@@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_topics">
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>topic_visibility</column>
|
||||
<column>topic_title</column>
|
||||
<column>topic_first_post_id</column>
|
||||
<column>topic_last_post_id</column>
|
||||
<column>topic_delete_user</column>
|
||||
<column>topic_delete_time</column>
|
||||
<column>topic_delete_reason</column>
|
||||
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Soft deleted</value>
|
||||
<value>4</value>
|
||||
<value>5</value>
|
||||
<value>2</value>
|
||||
<value>123</value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_posts">
|
||||
<column>post_id</column>
|
||||
<column>poster_id</column>
|
||||
<column>topic_id</column>
|
||||
<column>forum_id</column>
|
||||
<column>post_visibility</column>
|
||||
<column>post_text</column>
|
||||
<column>post_delete_user</column>
|
||||
<column>post_delete_time</column>
|
||||
<column>post_delete_reason</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>Approved</value>
|
||||
<value>2</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Soft deleted</value>
|
||||
<value>2</value>
|
||||
<value>123</value>
|
||||
<value>manually</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<value>4</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Soft deleted by topic soft delete</value>
|
||||
<value>2</value>
|
||||
<value>123</value>
|
||||
<value></value>
|
||||
</row>
|
||||
<row>
|
||||
<value>5</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>Soft deleted before the topic was soft deleted</value>
|
||||
<value>2</value>
|
||||
<value>120</value>
|
||||
<value>manually</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>6</value>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
<value>0</value>
|
||||
<value>Unapproved before the topic was soft deleted</value>
|
||||
<value>0</value>
|
||||
<value>0</value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
<table name="phpbb_users">
|
||||
<column>user_id</column>
|
||||
<column>user_posts</column>
|
||||
<column>username</column>
|
||||
<column>username_clean</column>
|
||||
<column>user_permissions</column>
|
||||
<column>user_sig</column>
|
||||
<column>user_occ</column>
|
||||
<column>user_interests</column>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>6</value>
|
||||
<value>user 1</value>
|
||||
<value>user 1</value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
<value></value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
143
tests/content_visibility/get_forums_visibility_sql_test.php
Normal file
143
tests/content_visibility/get_forums_visibility_sql_test.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/get_forums_visibility_sql.xml');
|
||||
}
|
||||
|
||||
public function get_forums_visibility_sql_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'phpbb_topics',
|
||||
'topic', array(1, 2, 3), '',
|
||||
array(
|
||||
array('m_approve', true, array(1 => true, 2 => true, 3 => true)),
|
||||
),
|
||||
array(
|
||||
array('topic_id' => 1),
|
||||
array('topic_id' => 2),
|
||||
array('topic_id' => 3),
|
||||
array('topic_id' => 4),
|
||||
array('topic_id' => 5),
|
||||
array('topic_id' => 6),
|
||||
array('topic_id' => 7),
|
||||
array('topic_id' => 8),
|
||||
array('topic_id' => 9),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_topics',
|
||||
'topic', array(1, 2), '',
|
||||
array(
|
||||
array('m_approve', true, array(1 => true, 2 => true, 3 => true)),
|
||||
),
|
||||
array(
|
||||
array('topic_id' => 1),
|
||||
array('topic_id' => 2),
|
||||
array('topic_id' => 3),
|
||||
array('topic_id' => 4),
|
||||
array('topic_id' => 5),
|
||||
array('topic_id' => 6),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_topics',
|
||||
'topic', array(1, 2, 3), '',
|
||||
array(
|
||||
array('m_approve', true, array(2 => true)),
|
||||
),
|
||||
array(
|
||||
array('topic_id' => 2),
|
||||
array('topic_id' => 4),
|
||||
array('topic_id' => 5),
|
||||
array('topic_id' => 6),
|
||||
array('topic_id' => 8),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_posts',
|
||||
'post', array(1, 2, 3), '',
|
||||
array(
|
||||
array('m_approve', true, array(1 => true, 2 => true, 3 => true)),
|
||||
),
|
||||
array(
|
||||
array('post_id' => 1),
|
||||
array('post_id' => 2),
|
||||
array('post_id' => 3),
|
||||
array('post_id' => 4),
|
||||
array('post_id' => 5),
|
||||
array('post_id' => 6),
|
||||
array('post_id' => 7),
|
||||
array('post_id' => 8),
|
||||
array('post_id' => 9),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_posts',
|
||||
'post', array(1, 2), '',
|
||||
array(
|
||||
array('m_approve', true, array(1 => true, 2 => true, 3 => true)),
|
||||
),
|
||||
array(
|
||||
array('post_id' => 1),
|
||||
array('post_id' => 2),
|
||||
array('post_id' => 3),
|
||||
array('post_id' => 4),
|
||||
array('post_id' => 5),
|
||||
array('post_id' => 6),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_posts',
|
||||
'post', array(1, 2, 3), '',
|
||||
array(
|
||||
array('m_approve', true, array(2 => true)),
|
||||
),
|
||||
array(
|
||||
array('post_id' => 2),
|
||||
array('post_id' => 4),
|
||||
array('post_id' => 5),
|
||||
array('post_id' => 6),
|
||||
array('post_id' => 8),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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->expects($this->any())
|
||||
->method('acl_getf')
|
||||
->with($this->stringContains('_'), $this->anything())
|
||||
->will($this->returnValueMap($permissions));
|
||||
$user = $this->getMock('phpbb_user');
|
||||
$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 ' . $content_visibility->get_forums_visibility_sql($mode, $forum_ids, $table_alias) . '
|
||||
ORDER BY ' . $mode . '_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
}
|
||||
}
|
143
tests/content_visibility/get_global_visibility_sql_test.php
Normal file
143
tests/content_visibility/get_global_visibility_sql_test.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/get_forums_visibility_sql.xml');
|
||||
}
|
||||
|
||||
public function get_global_visibility_sql_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'phpbb_topics',
|
||||
'topic', array(), '',
|
||||
array(
|
||||
array('m_approve', true, array(1 => true, 2 => true, 3 => true)),
|
||||
),
|
||||
array(
|
||||
array('topic_id' => 1),
|
||||
array('topic_id' => 2),
|
||||
array('topic_id' => 3),
|
||||
array('topic_id' => 4),
|
||||
array('topic_id' => 5),
|
||||
array('topic_id' => 6),
|
||||
array('topic_id' => 7),
|
||||
array('topic_id' => 8),
|
||||
array('topic_id' => 9),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_topics',
|
||||
'topic', array(3), '',
|
||||
array(
|
||||
array('m_approve', true, array(1 => true, 2 => true, 3 => true)),
|
||||
),
|
||||
array(
|
||||
array('topic_id' => 1),
|
||||
array('topic_id' => 2),
|
||||
array('topic_id' => 3),
|
||||
array('topic_id' => 4),
|
||||
array('topic_id' => 5),
|
||||
array('topic_id' => 6),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_topics',
|
||||
'topic', array(), '',
|
||||
array(
|
||||
array('m_approve', true, array(2 => true)),
|
||||
),
|
||||
array(
|
||||
array('topic_id' => 2),
|
||||
array('topic_id' => 4),
|
||||
array('topic_id' => 5),
|
||||
array('topic_id' => 6),
|
||||
array('topic_id' => 8),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_posts',
|
||||
'post', array(), '',
|
||||
array(
|
||||
array('m_approve', true, array(1 => true, 2 => true, 3 => true)),
|
||||
),
|
||||
array(
|
||||
array('post_id' => 1),
|
||||
array('post_id' => 2),
|
||||
array('post_id' => 3),
|
||||
array('post_id' => 4),
|
||||
array('post_id' => 5),
|
||||
array('post_id' => 6),
|
||||
array('post_id' => 7),
|
||||
array('post_id' => 8),
|
||||
array('post_id' => 9),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_posts',
|
||||
'post', array(3), '',
|
||||
array(
|
||||
array('m_approve', true, array(1 => true, 2 => true, 3 => true)),
|
||||
),
|
||||
array(
|
||||
array('post_id' => 1),
|
||||
array('post_id' => 2),
|
||||
array('post_id' => 3),
|
||||
array('post_id' => 4),
|
||||
array('post_id' => 5),
|
||||
array('post_id' => 6),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_posts',
|
||||
'post', array(), '',
|
||||
array(
|
||||
array('m_approve', true, array(2 => true)),
|
||||
),
|
||||
array(
|
||||
array('post_id' => 2),
|
||||
array('post_id' => 4),
|
||||
array('post_id' => 5),
|
||||
array('post_id' => 6),
|
||||
array('post_id' => 8),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider get_global_visibility_sql_data
|
||||
*/
|
||||
public function test_get_global_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->expects($this->any())
|
||||
->method('acl_getf')
|
||||
->with($this->stringContains('_'), $this->anything())
|
||||
->will($this->returnValueMap($permissions));
|
||||
$user = $this->getMock('phpbb_user');
|
||||
$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 ' . $content_visibility->get_global_visibility_sql($mode, $forum_ids, $table_alias) . '
|
||||
ORDER BY ' . $mode . '_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
}
|
||||
}
|
90
tests/content_visibility/get_visibility_sql_test.php
Normal file
90
tests/content_visibility/get_visibility_sql_test.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/get_visibility_sql.xml');
|
||||
}
|
||||
|
||||
public function get_visibility_sql_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'phpbb_posts',
|
||||
'post', 1, '',
|
||||
array(
|
||||
array('m_approve', 1, true),
|
||||
),
|
||||
array(
|
||||
array('post_id' => 1),
|
||||
array('post_id' => 2),
|
||||
array('post_id' => 3),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_posts',
|
||||
'post', 1, '',
|
||||
array(
|
||||
),
|
||||
array(
|
||||
array('post_id' => 2),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_topics',
|
||||
'topic', 1, '',
|
||||
array(
|
||||
array('m_approve', 1, true),
|
||||
),
|
||||
array(
|
||||
array('topic_id' => 1),
|
||||
array('topic_id' => 2),
|
||||
array('topic_id' => 3),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'phpbb_topics',
|
||||
'topic', 1, '',
|
||||
array(),
|
||||
array(
|
||||
array('topic_id' => 2),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider get_visibility_sql_data
|
||||
*/
|
||||
public function test_get_visibility_sql($table, $mode, $forum_id, $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->expects($this->any())
|
||||
->method('acl_get')
|
||||
->with($this->stringContains('_'), $this->anything())
|
||||
->will($this->returnValueMap($permissions));
|
||||
$user = $this->getMock('phpbb_user');
|
||||
$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 ' . $content_visibility->get_visibility_sql($mode, $forum_id, $table_alias) . '
|
||||
ORDER BY ' . $mode . '_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
}
|
||||
}
|
143
tests/content_visibility/set_post_visibility_test.php
Normal file
143
tests/content_visibility/set_post_visibility_test.php
Normal file
@@ -0,0 +1,143 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||
|
||||
class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/set_post_visibility.xml');
|
||||
}
|
||||
|
||||
public function set_post_visibility_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
ITEM_APPROVED,
|
||||
1, 1, 1,
|
||||
2, time(), 'approve',
|
||||
true, false,
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => 1, 'post_delete_reason' => 'approve'),
|
||||
array('post_id' => 2, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||
array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 1, 'topic_first_post_id' => 1, 'topic_last_post_id' => 2),
|
||||
),
|
||||
),
|
||||
array(
|
||||
ITEM_APPROVED,
|
||||
3, 1, 1,
|
||||
2, time(), 'approve',
|
||||
false, true,
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
||||
array('post_id' => 2, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||
array('post_id' => 3, 'post_visibility' => 1, 'post_delete_reason' => 'approve'),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 1, 'topic_first_post_id' => 2, 'topic_last_post_id' => 3),
|
||||
),
|
||||
),
|
||||
array(
|
||||
ITEM_DELETED,
|
||||
2, 1, 1,
|
||||
2, time(), 'deleted',
|
||||
true, true,
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
||||
array('post_id' => 2, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'),
|
||||
array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 2, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3),
|
||||
),
|
||||
),
|
||||
array(
|
||||
ITEM_DELETED,
|
||||
5, 2, 1,
|
||||
2, time(), 'deleted',
|
||||
true, false,
|
||||
array(
|
||||
array('post_id' => 4, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
||||
array('post_id' => 5, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'),
|
||||
array('post_id' => 6, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||
array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 1, 'topic_first_post_id' => 6, 'topic_last_post_id' => 6),
|
||||
),
|
||||
),
|
||||
array(
|
||||
ITEM_DELETED,
|
||||
6, 2, 1,
|
||||
2, time(), 'deleted',
|
||||
false, true,
|
||||
array(
|
||||
array('post_id' => 4, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
||||
array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||
array('post_id' => 6, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'),
|
||||
array('post_id' => 7, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 1, 'topic_first_post_id' => 5, 'topic_last_post_id' => 5),
|
||||
),
|
||||
),
|
||||
array(
|
||||
ITEM_DELETED,
|
||||
8, 3, 1,
|
||||
2, time(), 'deleted',
|
||||
true, true,
|
||||
array(
|
||||
array('post_id' => 8, 'post_visibility' => 2, 'post_delete_reason' => 'deleted'),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 2, 'topic_first_post_id' => 8, 'topic_last_post_id' => 8),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider set_post_visibility_data
|
||||
*/
|
||||
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, $auth, $phpbb_root_path, $phpEx;
|
||||
|
||||
$cache = new phpbb_mock_cache;
|
||||
$db = $this->new_dbal();
|
||||
$auth = $this->getMock('phpbb_auth');
|
||||
$user = $this->getMock('phpbb_user');
|
||||
$content_visibility = new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
|
||||
|
||||
$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
|
||||
WHERE topic_id = ' . $topic_id . '
|
||||
ORDER BY post_id ASC');
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrowset($result));
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$result = $db->sql_query('SELECT topic_visibility, topic_first_post_id, topic_last_post_id
|
||||
FROM phpbb_topics
|
||||
WHERE topic_id = ' . $topic_id);
|
||||
|
||||
$this->assertEquals($expected_topic, $db->sql_fetchrowset($result));
|
||||
$db->sql_freeresult($result);
|
||||
}
|
||||
}
|
107
tests/content_visibility/set_topic_visibility_test.php
Normal file
107
tests/content_visibility/set_topic_visibility_test.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
|
||||
|
||||
class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/set_topic_visibility.xml');
|
||||
}
|
||||
|
||||
public function set_topic_visibility_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
ITEM_DELETED, 1, 1,
|
||||
2, time(), 'delete', false,
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||
array('post_id' => 2, 'post_visibility' => 2, 'post_delete_reason' => 'manually'),
|
||||
array('post_id' => 3, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 2, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, 'topic_delete_reason' => 'delete'),
|
||||
),
|
||||
),
|
||||
array(
|
||||
ITEM_DELETED, 1, 1,
|
||||
2, time(), 'delete-forced', true,
|
||||
array(
|
||||
array('post_id' => 1, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||
array('post_id' => 2, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||
array('post_id' => 3, 'post_visibility' => 2, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 2, 'topic_first_post_id' => 1, 'topic_last_post_id' => 3, 'topic_delete_reason' => 'delete-forced'),
|
||||
),
|
||||
),
|
||||
array(
|
||||
ITEM_APPROVED, 2, 1,
|
||||
2, time(), 'approved', false,
|
||||
array(
|
||||
array('post_id' => 4, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||
array('post_id' => 5, 'post_visibility' => 2, 'post_delete_reason' => 'manually'),
|
||||
array('post_id' => 6, 'post_visibility' => 0, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 1, 'topic_first_post_id' => 4, 'topic_last_post_id' => 4, 'topic_delete_reason' => 'approved'),
|
||||
),
|
||||
),
|
||||
array(
|
||||
ITEM_APPROVED, 2, 1,
|
||||
2, time(), 'approved-forced', true,
|
||||
array(
|
||||
array('post_id' => 4, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||
array('post_id' => 5, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||
array('post_id' => 6, 'post_visibility' => 1, 'post_delete_reason' => ''),
|
||||
),
|
||||
array(
|
||||
array('topic_visibility' => 1, 'topic_first_post_id' => 4, 'topic_last_post_id' => 6, 'topic_delete_reason' => 'approved-forced'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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');
|
||||
$user = $this->getMock('phpbb_user');
|
||||
$content_visibility = new phpbb_content_visibility($auth, $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);
|
||||
}
|
||||
}
|
761
tests/functional/softdelete_test.php
Normal file
761
tests/functional/softdelete_test.php
Normal file
@@ -0,0 +1,761 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_softdelete_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $data = array();
|
||||
|
||||
public function test_setup_forums()
|
||||
{
|
||||
$this->login();
|
||||
$this->admin_login();
|
||||
|
||||
$crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
|
||||
$form = $crawler->selectButton('addforum')->form(array(
|
||||
'forum_name' => 'Soft Delete #1',
|
||||
));
|
||||
$crawler = self::submit($form);
|
||||
$form = $crawler->selectButton('update')->form(array(
|
||||
'forum_perm_from' => 2,
|
||||
));
|
||||
$crawler = self::submit($form);
|
||||
|
||||
$crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
|
||||
$form = $crawler->selectButton('addforum')->form(array(
|
||||
'forum_name' => 'Soft Delete #2',
|
||||
));
|
||||
$crawler = self::submit($form);
|
||||
$form = $crawler->selectButton('update')->form(array(
|
||||
'forum_perm_from' => 2,
|
||||
));
|
||||
$crawler = self::submit($form);
|
||||
}
|
||||
|
||||
public function test_create_post()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'initial comparison');
|
||||
|
||||
// Test creating topic
|
||||
$post = $this->create_topic($this->data['forums']['Soft Delete #1'], 'Soft Delete Topic #1', 'This is a test topic posted by the testing framework.');
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
|
||||
|
||||
$this->assertContains('Soft Delete Topic #1', $crawler->filter('html')->text());
|
||||
$this->data['topics']['Soft Delete Topic #1'] = (int) $post['topic_id'];
|
||||
$this->data['posts']['Soft Delete Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'after creating topic #1');
|
||||
|
||||
// Test creating a reply
|
||||
$post2 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#2', 'This is a test post posted by the testing framework.');
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
|
||||
|
||||
$this->assertContains('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text());
|
||||
$this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->eq(1)->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 2,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'],
|
||||
), 'after replying');
|
||||
}
|
||||
|
||||
public function test_softdelete_post()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 2,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Re: Soft Delete Topic #1-#2'],
|
||||
), 'before softdelete');
|
||||
|
||||
$this->add_lang('posting');
|
||||
$crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Soft Delete #1']}&p={$this->data['posts']['Re: Soft Delete Topic #1-#2']}&sid={$this->sid}");
|
||||
$this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
|
||||
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('POST_DELETED', $crawler->text());
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'after softdelete');
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
$this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
|
||||
}
|
||||
|
||||
public function test_move_softdeleted_post()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'before moving #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'before moving #2');
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
|
||||
$form = $crawler->selectButton('Go')->eq(2)->form();
|
||||
$form['action']->select('move');
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('SELECT_DESTINATION_FORUM', $crawler->text());
|
||||
|
||||
$this->add_lang('mcp');
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$form['to_forum_id']->select($this->data['forums']['Soft Delete #2']);
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text());
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
$this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text());
|
||||
$this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'after moving #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'after moving #2');
|
||||
}
|
||||
|
||||
public function test_softdelete_topic()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'before softdeleting #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'before softdeleting #2');
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
|
||||
$this->add_lang('posting');
|
||||
$form = $crawler->selectButton('Go')->eq(2)->form();
|
||||
$form['action']->select('delete_topic');
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
|
||||
|
||||
$this->add_lang('mcp');
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text());
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
$this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text());
|
||||
$this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'after moving #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 2,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 1,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'after moving #2');
|
||||
}
|
||||
|
||||
public function test_move_softdeleted_topic()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'before moving #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 2,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 1,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'before moving #2');
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
|
||||
$form = $crawler->selectButton('Go')->eq(2)->form();
|
||||
$form['action']->select('move');
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('SELECT_DESTINATION_FORUM', $crawler->text());
|
||||
|
||||
$this->add_lang('mcp');
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$form['to_forum_id']->select($this->data['forums']['Soft Delete #1']);
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text());
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
$this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text());
|
||||
$this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 2,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 1,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'after moving #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'after moving #2');
|
||||
}
|
||||
|
||||
public function test_restore_post()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 2,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 1,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'before restoring #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'before restoring #2');
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
|
||||
$this->add_lang('mcp');
|
||||
$form = $crawler->selectButton($this->lang('RESTORE'))->form();
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('RESTORE_POST', $crawler->text());
|
||||
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('POST_RESTORED_SUCCESS', $crawler->text());
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
$this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text());
|
||||
$this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'after restoring #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'after restoring #2');
|
||||
}
|
||||
|
||||
public function test_split_topic()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'before splitting #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'before splitting #2');
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
|
||||
$this->add_lang('mcp');
|
||||
$form = $crawler->selectButton('Go')->eq(2)->form();
|
||||
$form['action']->select('split');
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('SPLIT_TOPIC_EXPLAIN', $crawler->text());
|
||||
|
||||
$form = $crawler->selectButton('Submit')->form(array(
|
||||
'subject' => 'Soft Delete Topic #2',
|
||||
));
|
||||
$form['to_forum_id']->select($this->data['forums']['Soft Delete #2']);
|
||||
$form['post_id_list'][1]->tick();
|
||||
$crawler = self::submit($form);
|
||||
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('TOPIC_SPLIT_SUCCESS', $crawler->text());
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
$this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
|
||||
$this->assertNotContains('Re: Soft Delete Topic #1-#2', $crawler->text());
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'after restoring #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 1,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'after restoring #2');
|
||||
}
|
||||
|
||||
public function test_move_topic_back()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Soft Delete Topic #2',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}");
|
||||
|
||||
$form = $crawler->selectButton('Go')->eq(1)->form();
|
||||
$form['action']->select('move');
|
||||
$crawler = self::submit($form);
|
||||
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$form['to_forum_id']->select($this->data['forums']['Soft Delete #1']);
|
||||
$crawler = self::submit($form);
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 1,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'after moving back');
|
||||
}
|
||||
|
||||
public function test_merge_topics()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Soft Delete Topic #2',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 1,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'before merging #1');
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #2']}&sid={$this->sid}");
|
||||
|
||||
$this->add_lang('mcp');
|
||||
$form = $crawler->selectButton('Go')->eq(1)->form();
|
||||
$form['action']->select('merge_topic');
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('SELECT_MERGE', $crawler->text());
|
||||
|
||||
$crawler = self::request('GET', "mcp.php?f={$this->data['forums']['Soft Delete #1']}&t={$this->data['topics']['Soft Delete Topic #2']}&i=main&mode=forum_view&action=merge_topic&to_topic_id={$this->data['topics']['Soft Delete Topic #1']}");
|
||||
$this->assertContainsLang('MERGE_TOPICS_CONFIRM', $crawler->text());
|
||||
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('POSTS_MERGED_SUCCESS', $crawler->text());
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
$this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text());
|
||||
$this->assertContainsLang('POST_DELETED', $crawler->filter('body')->text());
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'after merging #1');
|
||||
}
|
||||
|
||||
public function test_fork_topic()
|
||||
{
|
||||
$this->login();
|
||||
$this->load_ids(array(
|
||||
'forums' => array(
|
||||
'Soft Delete #1',
|
||||
'Soft Delete #2',
|
||||
),
|
||||
'topics' => array(
|
||||
'Soft Delete Topic #1',
|
||||
),
|
||||
'posts' => array(
|
||||
'Soft Delete Topic #1',
|
||||
'Re: Soft Delete Topic #1-#2',
|
||||
),
|
||||
));
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'before forking #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 0,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 0,
|
||||
'forum_topics_approved' => 0,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => 0,
|
||||
), 'before forking #2');
|
||||
|
||||
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
|
||||
|
||||
$this->add_lang('mcp');
|
||||
$form = $crawler->selectButton('Go')->eq(2)->form();
|
||||
$form['action']->select('fork');
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('FORK_TOPIC', $crawler->text());
|
||||
|
||||
$form = $crawler->selectButton('Yes')->form();
|
||||
$form['to_forum_id']->select($this->data['forums']['Soft Delete #2']);
|
||||
$crawler = self::submit($form);
|
||||
$this->assertContainsLang('TOPIC_FORKED_SUCCESS', $crawler->text());
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'],
|
||||
), 'after forking #1');
|
||||
|
||||
$this->assert_forum_details($this->data['forums']['Soft Delete #2'], array(
|
||||
'forum_posts_approved' => 1,
|
||||
'forum_posts_unapproved' => 0,
|
||||
'forum_posts_softdeleted' => 1,
|
||||
'forum_topics_approved' => 1,
|
||||
'forum_topics_unapproved' => 0,
|
||||
'forum_topics_softdeleted' => 0,
|
||||
'forum_last_post_id' => $this->data['posts']['Soft Delete Topic #1'] + 2,
|
||||
), 'after forking #2');
|
||||
}
|
||||
|
||||
public function assert_forum_details($forum_id, $details, $additional_error_message = '')
|
||||
{
|
||||
$this->db = $this->get_db();
|
||||
|
||||
$sql = 'SELECT ' . implode(', ', array_keys($details)) . '
|
||||
FROM phpbb_forums
|
||||
WHERE forum_id = ' . (int) $forum_id;
|
||||
$result = $this->db->sql_query($sql);
|
||||
$data = $this->db->sql_fetchrow($result);
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
$this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}");
|
||||
}
|
||||
|
||||
public function load_ids($data)
|
||||
{
|
||||
$this->db = $this->get_db();
|
||||
|
||||
if (!empty($data['forums']))
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM phpbb_forums
|
||||
WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if (in_array($row['forum_name'], $data['forums']))
|
||||
{
|
||||
$this->data['forums'][$row['forum_name']] = (int) $row['forum_id'];
|
||||
}
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (!empty($data['topics']))
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM phpbb_topics
|
||||
WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']);
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if (in_array($row['topic_title'], $data['topics']))
|
||||
{
|
||||
$this->data['topics'][$row['topic_title']] = (int) $row['topic_id'];
|
||||
}
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
if (!empty($data['posts']))
|
||||
{
|
||||
$sql = 'SELECT *
|
||||
FROM phpbb_posts
|
||||
WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']);
|
||||
$result = $this->db->sql_query($sql);
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
if (in_array($row['post_subject'], $data['posts']))
|
||||
{
|
||||
$this->data['posts'][$row['post_subject']] = (int) $row['post_id'];
|
||||
}
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
}
|
||||
}
|
23
tests/mock/search.php
Normal file
23
tests/mock/search.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*/
|
||||
class phpbb_mock_search
|
||||
{
|
||||
|
||||
public function __construct($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user)
|
||||
{
|
||||
}
|
||||
|
||||
public function index_remove($post_ids, $poster_ids, $forum_ids)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -96,6 +96,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case
|
||||
|
||||
// Container
|
||||
$phpbb_container = new phpbb_mock_container_builder();
|
||||
$phpbb_container->set('content.visibility', new phpbb_content_visibility($auth, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
|
||||
|
||||
$user_loader = new phpbb_user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
|
||||
|
||||
|
@@ -870,6 +870,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
* Be sure to login before creating
|
||||
*
|
||||
* @param int $forum_id
|
||||
* @param int $topic_id
|
||||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
@@ -926,18 +927,47 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
// Instead, I send it as a request with the submit button "post" set to true.
|
||||
$crawler = self::request('POST', $posting_url, $form_data);
|
||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||
|
||||
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
|
||||
|
||||
$matches = $topic_id = $post_id = false;
|
||||
preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches);
|
||||
|
||||
$topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0;
|
||||
$post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0;
|
||||
|
||||
return array(
|
||||
'topic_id' => $topic_id,
|
||||
'post_id' => $post_id,
|
||||
'topic_id' => $this->get_parameter_from_link($url, 't'),
|
||||
'post_id' => $this->get_parameter_from_link($url, 'p'),
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the requested parameter from a URL
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $parameter
|
||||
* @return string Value of the parameter in the URL, null if not set
|
||||
*/
|
||||
public function get_parameter_from_link($url, $parameter)
|
||||
{
|
||||
if (strpos($url, '?') === false)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$url_parts = explode('?', $url);
|
||||
if (isset($url_parts[1]))
|
||||
{
|
||||
$url_parameters = $url_parts[1];
|
||||
if (strpos($url_parameters, '#') !== false)
|
||||
{
|
||||
$url_parameters = explode('#', $url_parameters);
|
||||
$url_parameters = $url_parameters[0];
|
||||
}
|
||||
|
||||
foreach (explode('&', $url_parameters) as $url_param)
|
||||
{
|
||||
list($param, $value) = explode('=', $url_param);
|
||||
if ($param == $parameter)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user