aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Chase <asperous2@gmail.com>2013-07-22 17:39:14 -0700
committerAndy Chase <asperous2@gmail.com>2013-07-22 17:39:14 -0700
commit0c54fb034b71cfc2bff338430acb1e2b43083dd5 (patch)
tree644e610453697c2e39fe6440ea5cc4d022a204e2
parent568de3b8ceb68c4d988a7e69b0d357bd43bdd25b (diff)
downloadforums-0c54fb034b71cfc2bff338430acb1e2b43083dd5.tar
forums-0c54fb034b71cfc2bff338430acb1e2b43083dd5.tar.gz
forums-0c54fb034b71cfc2bff338430acb1e2b43083dd5.tar.bz2
forums-0c54fb034b71cfc2bff338430acb1e2b43083dd5.tar.xz
forums-0c54fb034b71cfc2bff338430acb1e2b43083dd5.zip
[ticket/11620] Move check_ban_test functions to setUp/tearDown for clarity
PHPBB3-11620
-rw-r--r--tests/session/check_ban_test.php36
1 files changed, 26 insertions, 10 deletions
diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php
index fe7c70575a..8d6c9a866d 100644
--- a/tests/session/check_ban_test.php
+++ b/tests/session/check_ban_test.php
@@ -13,6 +13,8 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
{
protected $user_id = 4;
protected $key_id = 4;
+ protected $session;
+ protected $backup_cache;
public function getDataSet()
{
@@ -31,14 +33,16 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
);
}
- /** @dataProvider check_banned_data */
- public function test_check_is_banned($test_msg, $user_id, $user_ips, $user_email, $return, $should_be_banned)
+ public function setUp()
{
- $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.
+ parent::setUp();
+ // Get session here so that config is mocked correctly
+ $this->session = $this->session_factory->get_session($this->db);
global $cache, $config, $phpbb_root_path, $phpEx;
+ $this->backup_cache = $cache;
+ // Change the global cache object for this test because
+ // the mock cache object does not hit the database as is needed
+ // for this test.
$cache = new phpbb_cache_service(
new phpbb_cache_driver_file(),
$config,
@@ -46,17 +50,29 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
$phpbb_root_path,
$phpEx
);
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ // Set cache back to what it was before the test changed it
+ global $cache;
+ $cache = $this->backup_cache;
+ }
+ /** @dataProvider check_banned_data */
+ public function test_check_is_banned($test_msg, $user_id, $user_ips, $user_email, $return, $should_be_banned)
+ {
try
{
- $is_banned = $session->check_ban($user_id, $user_ips, $user_email, $return);
- } catch (PHPUnit_Framework_Error_Notice $e)
+ $is_banned = $this->session->check_ban($user_id, $user_ips, $user_email, $return);
+ }
+ catch (PHPUnit_Framework_Error_Notice $e)
{
// User error was triggered, user must have been banned
$is_banned = true;
}
- $this->assertEquals($should_be_banned, $is_banned, $test_msg);
- $cache = new phpbb_mock_cache();
+ $this->assertEquals($should_be_banned, $is_banned, $test_msg);
}
}