Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 64 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_functional_viewonline_test | |
0.00% |
0 / 64 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
| get_forum_name_by_topic_id | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| get_forum_name_by_forum_id | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
| test_viewonline | |
0.00% |
0 / 50 |
|
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 | class phpbb_functional_viewonline_test extends phpbb_functional_test_case |
| 18 | { |
| 19 | protected function get_forum_name_by_topic_id($topic_id) |
| 20 | { |
| 21 | // Forum info |
| 22 | $sql = 'SELECT f.forum_name |
| 23 | FROM ' . FORUMS_TABLE . ' f,' . TOPICS_TABLE . ' t |
| 24 | WHERE t.forum_id = f.forum_id |
| 25 | AND t.topic_id = ' . (int) $topic_id; |
| 26 | $result = $this->db->sql_query($sql); |
| 27 | $forum_name = $this->db->sql_fetchfield('forum_name'); |
| 28 | $this->db->sql_freeresult($result, 1800); // cache for 30 minutes |
| 29 | |
| 30 | return $forum_name; |
| 31 | } |
| 32 | |
| 33 | protected function get_forum_name_by_forum_id($forum_id) |
| 34 | { |
| 35 | // Forum info |
| 36 | $sql = 'SELECT forum_name |
| 37 | FROM ' . FORUMS_TABLE . ' |
| 38 | WHERE forum_id = ' . (int) $forum_id; |
| 39 | $result = $this->db->sql_query($sql); |
| 40 | $forum_name = $this->db->sql_fetchfield('forum_name'); |
| 41 | $this->db->sql_freeresult($result, 1800); // cache for 30 minutes |
| 42 | |
| 43 | return $forum_name; |
| 44 | } |
| 45 | |
| 46 | public function test_viewonline() |
| 47 | { |
| 48 | $this->create_user('viewonline-test-user1'); |
| 49 | |
| 50 | // Log in as test user |
| 51 | self::$client->restart(); |
| 52 | $this->login('viewonline-test-user1'); |
| 53 | $crawler = self::request('GET', 'posting.php?mode=reply&t=1&sid=' . $this->sid); |
| 54 | $this->assertContainsLang('POST_REPLY', $crawler->text()); |
| 55 | // Log in as another user |
| 56 | self::$client->restart(); |
| 57 | $this->login(); |
| 58 | // PHP goes faster than DBMS, make sure session data got written to the database |
| 59 | sleep(1); |
| 60 | $crawler = self::request('GET', 'app.php/members/online'); |
| 61 | // Make sure posting reply page is in the list |
| 62 | $this->assertStringContainsString('viewonline-test-user1', $crawler->text()); |
| 63 | $this->assertStringContainsString($this->lang('REPLYING_MESSAGE', $this->get_forum_name_by_topic_id(1)), $crawler->text()); |
| 64 | |
| 65 | // Log in as test user |
| 66 | self::$client->restart(); |
| 67 | $this->login('viewonline-test-user1'); |
| 68 | $crawler = self::request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid); |
| 69 | $this->assertContainsLang('POST_TOPIC', $crawler->text()); |
| 70 | // Log in as another user |
| 71 | self::$client->restart(); |
| 72 | $this->login(); |
| 73 | // PHP goes faster than DBMS, make sure session data got written to the database |
| 74 | sleep(1); |
| 75 | $crawler = self::request('GET', 'app.php/members/online'); |
| 76 | // Make sure posting message page is in the list |
| 77 | $this->assertStringContainsString('viewonline-test-user1', $crawler->text()); |
| 78 | $this->assertStringContainsString($this->lang('POSTING_MESSAGE', $this->get_forum_name_by_forum_id(2)), $crawler->text()); |
| 79 | |
| 80 | // Log in as test user |
| 81 | self::$client->restart(); |
| 82 | $this->login('viewonline-test-user1'); |
| 83 | $test_post_data = $this->create_post(2, 1, 'Viewonline test post #1', 'Viewonline test post message'); |
| 84 | $crawler = self::request('GET', 'posting.php?mode=edit&p=' . $test_post_data['post_id'] . '&sid=' . $this->sid); |
| 85 | $this->assertContainsLang('EDIT_POST', $crawler->text()); |
| 86 | // Log in as another user |
| 87 | self::$client->restart(); |
| 88 | $this->login(); |
| 89 | // PHP goes faster than DBMS, make sure session data got written to the database |
| 90 | sleep(1); |
| 91 | $crawler = self::request('GET', 'app.php/members/online'); |
| 92 | // Make sure posting message page is in the list |
| 93 | $this->assertStringContainsString('viewonline-test-user1', $crawler->text()); |
| 94 | $this->assertStringContainsString($this->lang('POSTING_MESSAGE', $this->get_forum_name_by_forum_id(2)), $crawler->text()); |
| 95 | |
| 96 | // Log in as test user |
| 97 | self::$client->restart(); |
| 98 | $this->login('viewonline-test-user1'); |
| 99 | self::request('GET', 'viewtopic.php?t=1&sid=' . $this->sid); |
| 100 | // Log in as another user |
| 101 | self::$client->restart(); |
| 102 | $this->login(); |
| 103 | // PHP goes faster than DBMS, make sure session data got written to the database |
| 104 | sleep(1); |
| 105 | $crawler = self::request('GET', 'app.php/members/online'); |
| 106 | // Make sure reading topic page is in the list |
| 107 | $this->assertStringContainsString('viewonline-test-user1', $crawler->text()); |
| 108 | $this->assertStringContainsString($this->lang('READING_TOPIC', $this->get_forum_name_by_topic_id(1)), $crawler->text()); |
| 109 | |
| 110 | // Log in as test user |
| 111 | self::$client->restart(); |
| 112 | $this->login('viewonline-test-user1'); |
| 113 | self::request('GET', 'viewforum.php?f=2&sid=' . $this->sid); |
| 114 | // Log in as another user |
| 115 | self::$client->restart(); |
| 116 | $this->login(); |
| 117 | // PHP goes faster than DBMS, make sure session data got written to the database |
| 118 | sleep(1); |
| 119 | $crawler = self::request('GET', 'app.php/members/online'); |
| 120 | // Make sure reading forum page is in the list |
| 121 | $this->assertStringContainsString('viewonline-test-user1', $crawler->text()); |
| 122 | $this->assertStringContainsString($this->lang('READING_FORUM', $this->get_forum_name_by_forum_id(2)), $crawler->text()); |
| 123 | } |
| 124 | } |