1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-06 08:47:45 +02:00

[ticket/17296] Fix session page update test

PHPBB3-17296
This commit is contained in:
Marc Alexander
2024-03-09 09:54:57 +01:00
parent 51b3d9de63
commit 9c51a7866b
2 changed files with 14 additions and 21 deletions

View File

@@ -24,41 +24,31 @@ class phpbb_functional_session_page_update_test extends phpbb_functional_test_ca
global $db;
$db = $this->db;
$this->login();
}
public function test_session_page_update()
{
$this->login();
$db = $this->get_db();
if (!function_exists('utf_clean_string'))
{
require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php');
}
if (!function_exists('user_get_id_name'))
{
require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
}
$user_ids = [];
$username = ['admin'];
user_get_id_name($user_ids, $username);
$user_id = (int) $user_ids[0];
// Sleep for 2 seconds to ensure we don't have session time race condition
sleep(2);
// Request index page
self::request('GET', 'index.php');
$this->assertEquals(200, self::$client->getResponse()->getStatus());
$sql = 'SELECT session_page FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = ' . $user_id . ' ORDER BY session_time DESC';
$sql = 'SELECT session_page FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = 2 ORDER BY session_time DESC';
$db->sql_query_limit($sql, 1);
$this->assertEquals('index.php', $db->sql_fetchfield('session_page'));
$this->assertEquals('index.php', $db->sql_fetchfield('session_page'), 'Failed asserting that session_page is index.php for admin user');
// Request non-existent url
self::request('GET', 'nonexistent.jpg', [], false);
$this->assertEquals(404, self::$client->getResponse()->getStatus());
$this->assertEquals(404, self::$client->getResponse()->getStatus(), 'Failed asserting that status of non-existent image is 404');
$db->sql_query_limit($sql, 1);
// User page should not be updated to non-existent one
$this->assertEquals('index.php', $db->sql_fetchfield('session_page'));
$this->assertEquals('index.php', $db->sql_fetchfield('session_page'), 'Failed asserting that session page has not changed after 404');
}
}