1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-10-06 04:31:38 +02:00

[ticket/17543] Use class method to call db object instance where possible

PHPBB-17543
This commit is contained in:
rxu
2025-09-24 23:16:15 +07:00
parent 70c07d4302
commit b51f8bc6e9
13 changed files with 73 additions and 97 deletions

View File

@@ -21,35 +21,29 @@ class phpbb_functional_session_page_update_test extends phpbb_functional_test_ca
{
parent::setUp();
global $db;
$db = $this->db;
// Delete previous session info for admin user
$sql = 'DELETE FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = 2';
$db->sql_query($sql);
$this->db->sql_query($sql);
$this->login();
}
public function test_session_page_update()
{
$db = $this->get_db();
// Request index page
self::request('GET', 'index.php');
$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 = 2 ORDER BY session_time DESC';
$db->sql_query_limit($sql, 1);
$this->assertEquals('index.php', $db->sql_fetchfield('session_page'), 'Failed asserting that session_page is index.php for admin user');
$this->db->sql_query_limit($sql, 1);
$this->assertEquals('index.php', $this->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->getInternalResponse()->getStatusCode(), 'Failed asserting that status of non-existent image is 404');
$db->sql_query_limit($sql, 1);
$this->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'), 'Failed asserting that session page has not changed after 404');
$this->assertEquals('index.php', $this->db->sql_fetchfield('session_page'), 'Failed asserting that session page has not changed after 404');
}
}