mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/11620] Whitespace and combine function into test_case
PHPBB3-11620
This commit is contained in:
parent
0c54fb034b
commit
2fe2724e68
7 changed files with 30 additions and 39 deletions
|
@ -20,10 +20,10 @@ class phpbb_mock_auth_provider implements phpbb_auth_provider_interface
|
|||
function login($username, $password)
|
||||
{
|
||||
return array(
|
||||
'status' => "",
|
||||
'error_msg' => "",
|
||||
'user_row' => "",
|
||||
);
|
||||
'status' => "",
|
||||
'error_msg' => "",
|
||||
'user_row' => "",
|
||||
);
|
||||
}
|
||||
|
||||
function autologin()
|
||||
|
|
|
@ -28,21 +28,12 @@ class phpbb_session_check_isvalid_test extends phpbb_session_test_case
|
|||
return $session;
|
||||
}
|
||||
|
||||
protected function check_session_equals($expected_sessions, $message)
|
||||
{
|
||||
$sql = 'SELECT session_id, session_user_id
|
||||
FROM phpbb_sessions
|
||||
ORDER BY session_user_id';
|
||||
|
||||
$this->assertSqlResultEquals($expected_sessions, $sql, $message);
|
||||
}
|
||||
|
||||
public function test_session_valid_session_exists()
|
||||
{
|
||||
$session = $this->access_with('bar_session000000000000000000000', '4', 'user agent', '127.0.0.1');
|
||||
$session->check_cookies($this, array());
|
||||
|
||||
$this->check_session_equals(array(
|
||||
$this->check_sessions_equals(array(
|
||||
array('session_id' => 'anon_session00000000000000000000', 'session_user_id' => 1),
|
||||
array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4),
|
||||
),
|
||||
|
@ -59,7 +50,7 @@ class phpbb_session_check_isvalid_test extends phpbb_session_test_case
|
|||
'sid' => array($session->session_id, null),
|
||||
));
|
||||
|
||||
$this->check_session_equals(array(
|
||||
$this->check_sessions_equals(array(
|
||||
array('session_id' => $session->session_id, 'session_user_id' => 1), // use generated SID
|
||||
array('session_id' => 'bar_session000000000000000000000', 'session_user_id' => 4),
|
||||
),
|
||||
|
|
|
@ -38,6 +38,6 @@ class phpbb_session_create_test extends phpbb_session_test_case
|
|||
self::bot('user agent', 13, '127.0.0.1'),
|
||||
''
|
||||
);
|
||||
$this->assertEquals(true, $output->data['is_bot'] , 'should be a bot');
|
||||
$this->assertEquals(true, $output->data['is_bot'], 'should be a bot');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,29 +24,19 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case
|
|||
$this->session = $this->session_factory->get_session($this->db);
|
||||
}
|
||||
|
||||
protected function assert_sessions_equal($expected, $msg)
|
||||
{
|
||||
$sql = 'SELECT session_id, session_user_id
|
||||
FROM phpbb_sessions
|
||||
ORDER BY session_user_id';
|
||||
|
||||
$this->assertSqlResultEquals($expected, $sql, $msg);
|
||||
}
|
||||
|
||||
public function test_cleanup_all()
|
||||
{
|
||||
$this->assert_sessions_equal(
|
||||
$this->check_sessions_equals(
|
||||
array(
|
||||
array
|
||||
(
|
||||
array(
|
||||
'session_id' => 'anon_session00000000000000000000',
|
||||
'session_user_id' => 1,
|
||||
),
|
||||
array
|
||||
(
|
||||
array(
|
||||
'session_id' => 'bar_session000000000000000000000',
|
||||
'session_user_id' => 4,
|
||||
)),
|
||||
),
|
||||
),
|
||||
'Before test, should have some sessions.'
|
||||
);
|
||||
// Set session length so it clears all
|
||||
|
@ -55,7 +45,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case
|
|||
// There is an error unless the captcha plugin is set
|
||||
$config['captcha_plugin'] = 'phpbb_captcha_nogd';
|
||||
$this->session->session_gc();
|
||||
$this->assert_sessions_equal(
|
||||
$this->check_sessions_equals(
|
||||
array(),
|
||||
'After setting session time to 0, should remove all.'
|
||||
);
|
||||
|
|
|
@ -33,7 +33,7 @@ class phpbb_session_testable_facade
|
|||
$this->session_factory = $session_factory;
|
||||
}
|
||||
|
||||
function extract_current_page (
|
||||
function extract_current_page(
|
||||
$root_path,
|
||||
$php_self,
|
||||
$query_string,
|
||||
|
@ -48,7 +48,7 @@ class phpbb_session_testable_facade
|
|||
return phpbb_session::extract_current_page($root_path);
|
||||
}
|
||||
|
||||
function extract_current_hostname (
|
||||
function extract_current_hostname(
|
||||
$host,
|
||||
$server_name_config,
|
||||
$cookie_domain_config
|
||||
|
@ -75,7 +75,7 @@ class phpbb_session_testable_facade
|
|||
* @param request_overrides An array of overrides for the global request object
|
||||
* @return boolean False if the user is identified, otherwise true.
|
||||
*/
|
||||
function session_begin (
|
||||
function session_begin(
|
||||
$update_session_page = true,
|
||||
$config_overrides = array(),
|
||||
$request_overrides = array(),
|
||||
|
@ -90,7 +90,7 @@ class phpbb_session_testable_facade
|
|||
return $session;
|
||||
}
|
||||
|
||||
function session_create (
|
||||
function session_create(
|
||||
$user_id = false,
|
||||
$set_admin = false,
|
||||
$persist_login = false,
|
||||
|
|
|
@ -16,7 +16,8 @@ class phpbb_session_validate_referrer_test extends phpbb_session_test_case
|
|||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_empty.xml');
|
||||
}
|
||||
|
||||
static function referrer_inputs() {
|
||||
static function referrer_inputs()
|
||||
{
|
||||
$ex = "example.org";
|
||||
$alt = "example.com";
|
||||
return array(
|
||||
|
@ -39,8 +40,8 @@ class phpbb_session_validate_referrer_test extends phpbb_session_test_case
|
|||
);
|
||||
}
|
||||
|
||||
/** @dataProvider referrer_inputs */
|
||||
function test_referrer_inputs (
|
||||
/** @dataProvider referrer_inputs */
|
||||
function test_referrer_inputs(
|
||||
$check_script_path,
|
||||
$referrer,
|
||||
$host,
|
||||
|
|
|
@ -24,4 +24,13 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case
|
|||
$this->session_facade =
|
||||
new phpbb_session_testable_facade($this->db, $this->session_factory);
|
||||
}
|
||||
|
||||
protected function check_sessions_equals($expected_sessions, $message)
|
||||
{
|
||||
$sql = 'SELECT session_id, session_user_id
|
||||
FROM phpbb_sessions
|
||||
ORDER BY session_user_id';
|
||||
|
||||
$this->assertSqlResultEquals($expected_sessions, $sql, $message);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue