aboutsummaryrefslogtreecommitdiffstats
path: root/tests/session/check_ban_test.php
diff options
context:
space:
mode:
authorasperous <asperous2@gmail.com>2013-07-12 09:54:38 -0700
committerAndy Chase <asperous2@gmail.com>2013-07-22 11:07:41 -0700
commitd533e8807c1f88bd1e3c30ca518e795403b521ff (patch)
treec5035d9470bde5445e9172db525dc94ca9f3014c /tests/session/check_ban_test.php
parent016faad6682495a35566d2d0451697486a47e80c (diff)
downloadforums-d533e8807c1f88bd1e3c30ca518e795403b521ff.tar
forums-d533e8807c1f88bd1e3c30ca518e795403b521ff.tar.gz
forums-d533e8807c1f88bd1e3c30ca518e795403b521ff.tar.bz2
forums-d533e8807c1f88bd1e3c30ca518e795403b521ff.tar.xz
forums-d533e8807c1f88bd1e3c30ca518e795403b521ff.zip
[ticket/11620] Added a test for checking if users are banned
PHPBB3-11620
Diffstat (limited to 'tests/session/check_ban_test.php')
-rw-r--r--tests/session/check_ban_test.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php
new file mode 100644
index 0000000000..ec1f5e3aa1
--- /dev/null
+++ b/tests/session/check_ban_test.php
@@ -0,0 +1,51 @@
+<?php
+/**
+ *
+ * @package testing
+ * @copyright (c) 2013 phpBB Group
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+ *
+ */
+
+require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
+
+class phpbb_session_check_ban_test extends phpbb_session_test_case
+{
+ protected $user_id = 4;
+ protected $key_id = 4;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/sessions_banlist.xml');
+ }
+
+ static function check_banned_data()
+ {
+ return array(
+ array('All false values, should not be banned',
+ false, false, false, false, /* ?: */ false),
+ array('Matching values in the database, should be banned',
+ 4, '127.0.0.1', 'bar@example.org', true, /* ?: */ true),
+ array('IP Banned, should be banned',
+ false, '127.1.1.1', false, falseN, /* ?: */ true),
+ );
+ }
+
+ /** @dataProvider check_banned_data */
+ public function test_check_is_banned($test_msg, $user_id, $user_ips, $user_email, $return, $should_be_banned)
+ {
+ $session = $this->session_factory->get_session($this->db);
+ // Change the global cache object for this test because
+ // the mock cache object does not hit the database as is
+ // needed for this test.
+ global $cache;
+ $old_cache = $cache;
+ $cache = new phpbb_cache_driver_file();
+
+ $is_banned =
+ $session->check_ban($user_id, $user_ips, $user_email, $return);
+ $this->assertEquals($should_be_banned, $is_banned, $test_msg);
+
+ $cache = $old_cache;
+ }
+}