aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functions
diff options
context:
space:
mode:
authorNils Adermann <naderman@naderman.de>2014-05-02 15:54:10 +0200
committerNils Adermann <naderman@naderman.de>2014-05-02 15:54:10 +0200
commit97e651a4917778bd4294073d254c8735b7b1f4df (patch)
tree6fb005f38a35a2ebd2388300df5f79312deb4865 /tests/functions
parentd52c2d1b5caf1382d178e55eff311ceddf4b392f (diff)
parentd14aed0819f2314ab0da1787aa7228025a6a024c (diff)
downloadforums-97e651a4917778bd4294073d254c8735b7b1f4df.tar
forums-97e651a4917778bd4294073d254c8735b7b1f4df.tar.gz
forums-97e651a4917778bd4294073d254c8735b7b1f4df.tar.bz2
forums-97e651a4917778bd4294073d254c8735b7b1f4df.tar.xz
forums-97e651a4917778bd4294073d254c8735b7b1f4df.zip
Merge remote-tracking branch 'github-exreaction/ticket/8323' into develop-ascraeus
* github-exreaction/ticket/8323: [ticket/8323] Cache auth request [ticket/8323] Combine into a single query [ticket/8323] Comments on phpbb_get_banned_user_ids input for test [ticket/8323] More readability in test case [ticket/8323] Comments [ticket/8323] dataProvider for the test; better test data [ticket/8323] Comments [ticket/8323] Unit test for phpbb_get_banned_user_ids [ticket/8323] Comments for inactive reasons in constants.php [ticket/8323] Only disable administrative deactivated accounts from receiving PMs [ticket/8323] Allow temporarily banned users to receive PMs, but not a notification [ticket/8323] Correct PM notification settings (only notify those who can receive them) [ticket/8323] Cleanup viewtopic code (not sure how this mess happened) [ticket/8323] Allow sending PMs to temporarily banned users [ticket/8323] Do not allow sending PMs to Inactive users [ticket/8323] Hide the Send PM link if users cannot receive the PM [ticket/8323] Correcting the comment [ticket/8323] Do not allow sending of Private Messages to users who are banned [ticket/8323] Remove code used for testing [ticket/8323] Do not allow sending of Private Messages to users who do not have permission to read private messages Conflicts: phpBB/language/en/ucp.php
Diffstat (limited to 'tests/functions')
-rw-r--r--tests/functions/fixtures/banned_users.xml38
-rw-r--r--tests/functions/phpbb_get_banned_user_ids.php58
2 files changed, 96 insertions, 0 deletions
diff --git a/tests/functions/fixtures/banned_users.xml b/tests/functions/fixtures/banned_users.xml
new file mode 100644
index 0000000000..cec3f4e51f
--- /dev/null
+++ b/tests/functions/fixtures/banned_users.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_banlist">
+ <column>ban_userid</column>
+ <column>ban_exclude</column>
+ <column>ban_end</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>0</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>0</value>
+ <value>2</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>0</value>
+ <value>999999999999999999999</value>
+ </row>
+ <row>
+ <value>6</value>
+ <value>0</value>
+ <value>3</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php
new file mode 100644
index 0000000000..96de5c5767
--- /dev/null
+++ b/tests/functions/phpbb_get_banned_user_ids.php
@@ -0,0 +1,58 @@
+<?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_user.php';
+
+class phpbb_get_banned_user_ids_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/banned_users.xml');
+ }
+
+ public function phpbb_get_banned_user_ids_data()
+ {
+ return array(
+ // Input to phpbb_get_banned_user_ids (user_id list, ban_end)
+ // Expected output
+ array(
+ // True to get users currently banned
+ array(array(1, 2, 4, 5, 6), true),
+ array(2 => 2, 5 => 5),
+ ),
+ array(
+ // False to only get permanently banned users
+ array(array(1, 2, 4, 5, 6), false),
+ array(2 => 2),
+ ),
+ array(
+ // Unix timestamp to get users banned until that time
+ array(array(1, 2, 4, 5, 6), 2),
+ array(2 => 2, 5 => 5, 6 => 6),
+ ),
+ );
+ }
+
+ public function setUp()
+ {
+ global $db;
+
+ $db = $this->new_dbal();
+
+ return parent::setUp();
+ }
+
+ /**
+ * @dataProvider phpbb_get_banned_user_ids_data
+ */
+ public function test_phpbb_get_banned_user_ids($input, $expected)
+ {
+ $this->assertEquals($expected, call_user_func_array('phpbb_get_banned_user_ids', $input));
+ }
+}