aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functions_user
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-09-22 02:01:54 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-09-22 02:01:54 +0200
commit7fca351e05fd47bb1aaef3611ee9b7d7c946b0b3 (patch)
treee2567c6581afe0814c15d2224f50240cee9d72d9 /tests/functions_user
parentd7c12ccd6067a74ca24fe9cec872c29b94ce13b2 (diff)
downloadforums-7fca351e05fd47bb1aaef3611ee9b7d7c946b0b3.tar
forums-7fca351e05fd47bb1aaef3611ee9b7d7c946b0b3.tar.gz
forums-7fca351e05fd47bb1aaef3611ee9b7d7c946b0b3.tar.bz2
forums-7fca351e05fd47bb1aaef3611ee9b7d7c946b0b3.tar.xz
forums-7fca351e05fd47bb1aaef3611ee9b7d7c946b0b3.zip
[ticket/10729] Add assert messages and finish up tests
PHPBB3-10729
Diffstat (limited to 'tests/functions_user')
-rw-r--r--tests/functions_user/delete_user_test.php123
-rw-r--r--tests/functions_user/fixtures/delete_user.xml132
2 files changed, 228 insertions, 27 deletions
diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php
index 3cd575457d..1d7c843058 100644
--- a/tests/functions_user/delete_user_test.php
+++ b/tests/functions_user/delete_user_test.php
@@ -39,7 +39,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
{
return array(
array(
- 'retain', 2, false,
+ 'retain', false,
array(
array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => ''),
array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
@@ -76,7 +76,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
),
),
array(
- 'remove', 2, false,
+ 'remove', false,
array(
array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
@@ -101,7 +101,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
),
),
array(
- 'retain', 2, 'Bertie',
+ 'retain', 'Bertie',
array(
array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => 'Bertie'),
array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
@@ -138,7 +138,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
),
),
array(
- 'remove', 2, 'Bertie',
+ 'remove', 'Bertie',
array(
array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
@@ -168,29 +168,29 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
/**
* @dataProvider first_last_post_data
*/
- public function test_first_last_post_info($mode, $user_id, $post_username, $expected_posts, $expected_topics, $expected_forums)
+ public function test_first_last_post_info($mode, $post_username, $expected_posts, $expected_topics, $expected_forums)
{
- $this->assertFalse(user_delete($mode, $user_id, $post_username));
+ $this->assertFalse(user_delete($mode, 2, $post_username));
$sql = 'SELECT post_id, poster_id, post_username
FROM ' . POSTS_TABLE . '
ORDER BY post_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_posts, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_posts, $this->db->sql_fetchrowset($result), 'Post table poster info is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT topic_id, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour
FROM ' . TOPICS_TABLE . '
ORDER BY topic_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_topics, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_topics, $this->db->sql_fetchrowset($result), 'Topic table first/last poster info is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT forum_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour
FROM ' . FORUMS_TABLE . '
ORDER BY forum_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_forums, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_forums, $this->db->sql_fetchrowset($result), 'Forum table last poster info is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
}
@@ -198,7 +198,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
{
return array(
array(
- 'retain', 2,
+ 'retain',
array(
array('post_id' => 1, 'post_reported' => 1, 'post_edit_user' => 1),
array('post_id' => 2, 'post_reported' => 1, 'post_edit_user' => 1),
@@ -222,7 +222,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
),
),
array(
- 'remove', 2,
+ 'remove',
array(
array('post_id' => 2, 'post_reported' => 1, 'post_edit_user' => 1),
array('post_id' => 4, 'post_reported' => 0, 'post_edit_user' => 1),
@@ -245,36 +245,36 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
/**
* @dataProvider report_attachment_data
*/
- public function test_report_attachment_info($mode, $user_id, $expected_posts, $expected_reports, $expected_topics, $expected_attach)
+ public function test_report_attachment_info($mode, $expected_posts, $expected_reports, $expected_topics, $expected_attach)
{
- $this->assertFalse(user_delete($mode, $user_id));
+ $this->assertFalse(user_delete($mode, 2));
$sql = 'SELECT post_id, post_reported, post_edit_user
FROM ' . POSTS_TABLE . '
ORDER BY post_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_posts, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_posts, $this->db->sql_fetchrowset($result), 'Post report status content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT report_id, post_id, user_id
FROM ' . REPORTS_TABLE . '
ORDER BY report_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_reports, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_reports, $this->db->sql_fetchrowset($result), 'Report table content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT topic_id, topic_reported
FROM ' . TOPICS_TABLE . '
ORDER BY topic_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_topics, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_topics, $this->db->sql_fetchrowset($result), 'Topic report status is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT attach_id, post_msg_id, poster_id
FROM ' . ATTACHMENTS_TABLE . '
ORDER BY attach_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_attach, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_attach, $this->db->sql_fetchrowset($result), 'Attachment table content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
}
@@ -282,7 +282,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
{
return array(
array(
- 'retain', 2,
+ 'retain',
array(array('user_id' => 1, 'user_posts' => 4)),
array(array('user_id' => 1, 'zebra_id' => 3)),
array(array('ban_id' => 2), array('ban_id' => 3)),
@@ -297,7 +297,7 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
),
),
array(
- 'remove', 2,
+ 'remove',
array(array('user_id' => 1, 'user_posts' => 2)),
array(array('user_id' => 1, 'zebra_id' => 3)),
array(array('ban_id' => 2), array('ban_id' => 3)),
@@ -317,50 +317,119 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
/**
* @dataProvider delete_data
*/
- public function test_delete_data($mode, $user_id, $expected_users, $expected_zebra, $expected_ban, $expected_sessions, $expected_logs, $expected_pms)
+ public function test_delete_data($mode, $expected_users, $expected_zebra, $expected_ban, $expected_sessions, $expected_logs, $expected_pms)
{
- $this->assertFalse(user_delete($mode, $user_id));
+ $this->assertFalse(user_delete($mode, 2));
$sql = 'SELECT user_id, user_posts
FROM ' . USERS_TABLE . '
ORDER BY user_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_users, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_users, $this->db->sql_fetchrowset($result), 'User table content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT user_id, zebra_id
FROM ' . ZEBRA_TABLE . '
ORDER BY user_id ASC, zebra_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_zebra, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_zebra, $this->db->sql_fetchrowset($result), 'Zebra table content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT ban_id
FROM ' . BANLIST_TABLE . '
ORDER BY ban_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_ban, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_ban, $this->db->sql_fetchrowset($result), 'Ban table content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT session_id
FROM ' . SESSIONS_TABLE . '
ORDER BY session_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_sessions, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_sessions, $this->db->sql_fetchrowset($result), 'Session table content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT log_id, user_id, reportee_id
FROM ' . LOG_TABLE . '
ORDER BY log_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_logs, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_logs, $this->db->sql_fetchrowset($result), 'Log table content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
$sql = 'SELECT msg_id, author_id, message_edit_user
FROM ' . PRIVMSGS_TABLE . '
ORDER BY msg_id ASC';
$result = $this->db->sql_query($sql);
- $this->assertEquals($expected_pms, $this->db->sql_fetchrowset($result));
+ $this->assertEquals($expected_pms, $this->db->sql_fetchrowset($result), 'Private messages table content is mismatching after deleting a user.');
$this->db->sql_freeresult($result);
}
+
+ public function delete_user_id_data()
+ {
+ return array(
+ array(
+ 'retain',
+ array(
+ USER_GROUP_TABLE,
+ TOPICS_WATCH_TABLE,
+ FORUMS_WATCH_TABLE,
+ ACL_USERS_TABLE,
+ TOPICS_TRACK_TABLE,
+ TOPICS_POSTED_TABLE,
+ FORUMS_TRACK_TABLE,
+ PROFILE_FIELDS_DATA_TABLE,
+ MODERATOR_CACHE_TABLE,
+ DRAFTS_TABLE,
+ BOOKMARKS_TABLE,
+ SESSIONS_KEYS_TABLE,
+ PRIVMSGS_FOLDER_TABLE,
+ PRIVMSGS_RULES_TABLE,
+ ),
+ ),
+ array(
+ 'remove',
+ array(
+ USER_GROUP_TABLE,
+ TOPICS_WATCH_TABLE,
+ FORUMS_WATCH_TABLE,
+ ACL_USERS_TABLE,
+ TOPICS_TRACK_TABLE,
+ TOPICS_POSTED_TABLE,
+ FORUMS_TRACK_TABLE,
+ PROFILE_FIELDS_DATA_TABLE,
+ MODERATOR_CACHE_TABLE,
+ DRAFTS_TABLE,
+ BOOKMARKS_TABLE,
+ SESSIONS_KEYS_TABLE,
+ PRIVMSGS_FOLDER_TABLE,
+ PRIVMSGS_RULES_TABLE,
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider delete_user_id_data
+ */
+ public function test_delete_user_id_data($mode, $cleaned_tables)
+ {
+ $this->assertFalse(user_delete($mode, 2));
+
+ foreach ($cleaned_tables as $table)
+ {
+ $sql = 'SELECT user_id
+ FROM ' . $table . '
+ WHERE user_id = 2';
+ $result = $this->db->sql_query($sql);
+ $this->assertFalse($this->db->sql_fetchfield('user_id'), 'Found data for deleted user in table: ' . $table);
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT user_id
+ FROM ' . $table . '
+ WHERE user_id = 3';
+ $result = $this->db->sql_query($sql);
+ $this->assertEquals(3, $this->db->sql_fetchfield('user_id'), 'Missing data for user in table: ' . $table);
+ $this->db->sql_freeresult($result);
+ }
+ }
}
diff --git a/tests/functions_user/fixtures/delete_user.xml b/tests/functions_user/fixtures/delete_user.xml
index 8efa05f467..07591389d2 100644
--- a/tests/functions_user/fixtures/delete_user.xml
+++ b/tests/functions_user/fixtures/delete_user.xml
@@ -396,4 +396,136 @@
<value>1</value>
</row>
</table>
+ <table name="phpbb_user_group">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_topics_watch">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_forums_watch">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_acl_users">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_topics_track">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_forums_track">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_topics_posted">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_profile_fields_data">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_moderator_cache">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_bookmarks">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_sessions_keys">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_privmsgs_folder">
+ <column>user_id</column>
+ <row>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ </row>
+ </table>
+ <table name="phpbb_privmsgs_rules">
+ <column>user_id</column>
+ <column>rule_string</column>
+ <row>
+ <value>2</value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_drafts">
+ <column>user_id</column>
+ <column>draft_message</column>
+ <row>
+ <value>2</value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value></value>
+ </row>
+ </table>
</dataset>