mirror of
https://github.com/phpbb/phpbb.git
synced 2025-05-01 13:17:52 +02:00
[ticket/17296] Fix session page update test
PHPBB3-17296
This commit is contained in:
parent
51b3d9de63
commit
9c51a7866b
@ -90,12 +90,15 @@ class kernel_exception_subscriber implements EventSubscriberInterface
|
||||
}
|
||||
else if (!$this->debug && $exception instanceof NotFoundHttpException)
|
||||
{
|
||||
// Do not update user session page if it does not exist
|
||||
$this->user->update_session_page = false;
|
||||
|
||||
$message = $this->language->lang('PAGE_NOT_FOUND');
|
||||
}
|
||||
|
||||
// Do not update user session page if it does not exist
|
||||
if ($exception instanceof NotFoundHttpException)
|
||||
{
|
||||
$this->user->update_session_page = false;
|
||||
}
|
||||
|
||||
// Show <strong> text in bold
|
||||
$message = preg_replace('#<(/?strong)>#i', '<$1>', $message);
|
||||
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user