aboutsummaryrefslogtreecommitdiffstats
path: root/tests/privmsgs/delete_user_pms_test.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2012-06-23 16:02:16 +0200
committerJoas Schilling <nickvergessen@gmx.de>2012-06-23 16:02:16 +0200
commitd30dc11f3e1ade19fd8643bdded6f11625da1bb3 (patch)
treeea0157b14917c89be7493ff8c9b32204677b4ab6 /tests/privmsgs/delete_user_pms_test.php
parent49afc1f2dc3a3ee17c6abff1e94c25a8ba8b3604 (diff)
downloadforums-d30dc11f3e1ade19fd8643bdded6f11625da1bb3.tar
forums-d30dc11f3e1ade19fd8643bdded6f11625da1bb3.tar.gz
forums-d30dc11f3e1ade19fd8643bdded6f11625da1bb3.tar.bz2
forums-d30dc11f3e1ade19fd8643bdded6f11625da1bb3.tar.xz
forums-d30dc11f3e1ade19fd8643bdded6f11625da1bb3.zip
[ticket/10950] Add some first and simple unit tests for phpbb_delete_user_pms()
Todo: Add cases to in which the msg is also deleted. PHPBB3-10950
Diffstat (limited to 'tests/privmsgs/delete_user_pms_test.php')
-rw-r--r--tests/privmsgs/delete_user_pms_test.php95
1 files changed, 95 insertions, 0 deletions
diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php
new file mode 100644
index 0000000000..b399d94c6d
--- /dev/null
+++ b/tests/privmsgs/delete_user_pms_test.php
@@ -0,0 +1,95 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_privmsgs.php';
+
+class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/delete_user_pms.xml');
+ }
+
+ public static function delete_user_pms_data()
+ {
+ return array(
+ // array(
+ // (user we delete),
+ // array(remaining privmsgs ids),
+ // array(remaining privmsgs_to),
+ // ),
+ array(
+ 2,
+ array(
+ array('msg_id' => 1),
+ array('msg_id' => 2),
+ ),
+ array(
+ //array('msg_id' => 1, 'user_id' => 2),
+ array('msg_id' => 1, 'user_id' => 3),
+ array('msg_id' => 1, 'user_id' => 4),
+ //array('msg_id' => 2, 'user_id' => 2),
+ array('msg_id' => 2, 'user_id' => 4),
+ ),
+ ),
+ array(
+ 3,
+ array(
+ array('msg_id' => 1),
+ array('msg_id' => 2),
+ ),
+ array(
+ array('msg_id' => 1, 'user_id' => 2),
+ //array('msg_id' => 1, 'user_id' => 3),
+ array('msg_id' => 1, 'user_id' => 4),
+ array('msg_id' => 2, 'user_id' => 2),
+ array('msg_id' => 2, 'user_id' => 4),
+ ),
+ ),
+ array(
+ 5,
+ array(
+ array('msg_id' => 1),
+ array('msg_id' => 2),
+ ),
+ array(
+ array('msg_id' => 1, 'user_id' => 2),
+ array('msg_id' => 1, 'user_id' => 3),
+ array('msg_id' => 1, 'user_id' => 4),
+ array('msg_id' => 2, 'user_id' => 2),
+ array('msg_id' => 2, 'user_id' => 4),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider delete_user_pms_data
+ */
+ public function test_delete_user_pms($delete_user, $remaining_privmsgs, $remaining_privmsgs_to)
+ {
+ global $db;
+
+ $db = $this->new_dbal();
+
+ phpbb_delete_user_pms($delete_user);
+
+ $sql = 'SELECT msg_id
+ FROM ' . PRIVMSGS_TABLE;
+ $result = $db->sql_query($sql);
+
+ $this->assertEquals($remaining_privmsgs, $db->sql_fetchrowset($result));
+
+ $sql = 'SELECT msg_id, user_id
+ FROM ' . PRIVMSGS_TO_TABLE;
+ $result = $db->sql_query($sql);
+
+ $this->assertEquals($remaining_privmsgs_to, $db->sql_fetchrowset($result));
+ }
+}