Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
phpbb_functional_session_page_update_test
0.00% covered (danger)
0.00%
0 / 13
0.00% covered (danger)
0.00%
0 / 2
6
0.00% covered (danger)
0.00%
0 / 1
 setUp
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 test_session_page_update
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14/**
15* @group functional
16*/
17
18class phpbb_functional_session_page_update_test extends phpbb_functional_test_case
19{
20    public function setUp(): void
21    {
22        parent::setUp();
23
24        // Delete previous session info for admin user
25        $sql = 'DELETE FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = 2';
26        $this->db->sql_query($sql);
27
28        $this->login();
29    }
30
31    public function test_session_page_update()
32    {
33        // Request index page
34        self::request('GET', 'index.php');
35        $this->assertEquals(200, self::$client->getInternalResponse()->getStatusCode(), 'Failed asserting that status of index page is 200');
36
37        $sql = 'SELECT session_page FROM ' . SESSIONS_TABLE . ' WHERE session_user_id = 2 ORDER BY session_time DESC';
38        $this->db->sql_query_limit($sql, 1);
39        $this->assertEquals('index.php', $this->db->sql_fetchfield('session_page'), 'Failed asserting that session_page is index.php for admin user');
40
41        // Request non-existent url
42        self::request('GET', 'nonexistent.jpg', [], false);
43        $this->assertEquals(404, self::$client->getInternalResponse()->getStatusCode(), 'Failed asserting that status of non-existent image is 404');
44
45        $this->db->sql_query_limit($sql, 1);
46        // User page should not be updated to non-existent one
47        $this->assertEquals('index.php', $this->db->sql_fetchfield('session_page'), 'Failed asserting that session page has not changed after 404');
48    }
49}