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

Merge branch 'ticket/17296' into ticket/17296-master

This commit is contained in:
Marc Alexander
2024-03-18 21:52:34 +01:00
4 changed files with 42 additions and 26 deletions

View File

@@ -17,39 +17,38 @@
class phpbb_functional_session_page_update_test extends phpbb_functional_test_case
{
protected function test_session_page_update()
public function setUp(): void
{
parent::setUp();
global $db;
$db = $this->db;
$this->login();
}
public function test_session_page_update()
{
$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 = [$this->get_logged_in_user()];
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());
$this->assertEquals(200, self::$client->getInternalResponse()->getStatusCode(), 'Failed asserting that status of index page is 200');
$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');
$this->assertEquals(404, self::$client->getResponse()->getStatus());
self::request('GET', 'nonexistent.jpg', [], false);
$this->assertEquals(404, self::$client->getInternalResponse()->getStatusCode(), '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');
}
}