mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/17107] Fix viewonline functional test
PHPBB3-17107
This commit is contained in:
parent
130e7f7e8a
commit
60d267893c
1 changed files with 37 additions and 43 deletions
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
class phpbb_functional_viewonline_test extends phpbb_functional_test_case
|
||||
{
|
||||
|
||||
protected function get_forum_name_by_topic_id($topic_id)
|
||||
{
|
||||
$db = $this->get_db();
|
||||
|
@ -40,7 +39,7 @@ class phpbb_functional_viewonline_test extends phpbb_functional_test_case
|
|||
// Forum info
|
||||
$sql = 'SELECT forum_name
|
||||
FROM ' . FORUMS_TABLE . '
|
||||
WHERE forum_id = ' . (int) $topic_id;
|
||||
WHERE forum_id = ' . (int) $forum_id;
|
||||
$result = $db->sql_query($sql);
|
||||
$forum_name = $db->sql_fetchfield('forum_name');
|
||||
$db->sql_freeresult($result, 1800); // cache for 30 minutes
|
||||
|
@ -48,71 +47,66 @@ class phpbb_functional_viewonline_test extends phpbb_functional_test_case
|
|||
return $forum_name;
|
||||
}
|
||||
|
||||
public function test_viewonline_reply_mode()
|
||||
public function test_viewonline()
|
||||
{
|
||||
$this->create_user('viewonline-test-user');
|
||||
$this->logout();
|
||||
$this->login('viewonline-test-user');
|
||||
$this->create_user('viewonline-test-user1');
|
||||
|
||||
// Log in as test user
|
||||
self::$client->restart();
|
||||
$this->login('viewonline-test-user1');
|
||||
$crawler = self::request('GET', 'posting.php?mode=reply&t=1&sid=' . $this->sid);
|
||||
$this->assertContainsLang('POST_REPLY', $crawler->text());
|
||||
|
||||
// Log in as another user
|
||||
$this->logout();
|
||||
self::$client->restart();
|
||||
$this->login();
|
||||
// PHP goes faster than DBMS, make sure session data got written to the database
|
||||
sleep(1);
|
||||
$crawler = self::request('GET', 'viewonline.php?sid=' . $this->sid);
|
||||
$this->assertContainsLang('FORUM_LOCATION', $crawler->text());
|
||||
|
||||
// Make sure posting reply page is in the list
|
||||
$this->assertStringContainsString('viewonline-test-user', $crawler->text());
|
||||
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
|
||||
$this->assertStringContainsString($this->lang('REPLYING_MESSAGE', $this->get_forum_name_by_topic_id(1)), $crawler->text());
|
||||
}
|
||||
|
||||
public function test_viewonline_posting_mode()
|
||||
{
|
||||
$this->logout();
|
||||
$this->login('viewonline-test-user');
|
||||
$crawler = self::request('GET', 'posting.php?mode=post&f=1&sid=' . $this->sid);
|
||||
// Log in as test user
|
||||
self::$client->restart();
|
||||
$this->login('viewonline-test-user1');
|
||||
$crawler = self::request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
|
||||
$this->assertContainsLang('POST_TOPIC', $crawler->text());
|
||||
|
||||
// Log in as another user
|
||||
$this->logout();
|
||||
self::$client->restart();
|
||||
$this->login();
|
||||
// PHP goes faster than DBMS, make sure session data got written to the database
|
||||
sleep(1);
|
||||
$crawler = self::request('GET', 'viewonline.php?sid=' . $this->sid);
|
||||
|
||||
// Make sure posting message page is in the list
|
||||
$this->assertStringContainsString('viewonline-test-user', $crawler->text());
|
||||
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
|
||||
$this->assertStringContainsString($this->lang('POSTING_MESSAGE', $this->get_forum_name_by_forum_id(2)), $crawler->text());
|
||||
}
|
||||
|
||||
public function test_viewonline_reading_topic()
|
||||
{
|
||||
$this->logout();
|
||||
$this->login('viewonline-test-user');
|
||||
$crawler = self::request('GET', 'viewtopic.php?t=1&sid=' . $this->sid);
|
||||
|
||||
// Log in as test user
|
||||
self::$client->restart();
|
||||
$this->login('viewonline-test-user1');
|
||||
self::request('GET', 'viewtopic.php?t=1&sid=' . $this->sid);
|
||||
// Log in as another user
|
||||
$this->logout();
|
||||
self::$client->restart();
|
||||
$this->login();
|
||||
// PHP goes faster than DBMS, make sure session data got written to the database
|
||||
sleep(1);
|
||||
$crawler = self::request('GET', 'viewonline.php?sid=' . $this->sid);
|
||||
|
||||
// Make sure the page is in the list
|
||||
$this->assertStringContainsString('viewonline-test-user', $crawler->text());
|
||||
// Make sure reading topic page is in the list
|
||||
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
|
||||
$this->assertStringContainsString($this->lang('READING_TOPIC', $this->get_forum_name_by_topic_id(1)), $crawler->text());
|
||||
}
|
||||
|
||||
public function test_viewonline_reading_forum()
|
||||
{
|
||||
$this->logout();
|
||||
$this->login('viewonline-test-user');
|
||||
$crawler = self::request('GET', 'viewforum.php?f=2&sid=' . $this->sid);
|
||||
|
||||
// Log in as test user
|
||||
self::$client->restart();
|
||||
$this->login('viewonline-test-user1');
|
||||
self::request('GET', 'viewforum.php?f=2&sid=' . $this->sid);
|
||||
// Log in as another user
|
||||
$this->logout();
|
||||
self::$client->restart();
|
||||
$this->login();
|
||||
// PHP goes faster than DBMS, make sure session data got written to the database
|
||||
sleep(1);
|
||||
$crawler = self::request('GET', 'viewonline.php?sid=' . $this->sid);
|
||||
|
||||
// Make sure the page is in the list
|
||||
$this->assertStringContainsString('viewonline-test-user', $crawler->text());
|
||||
// Make sure reading forum page is in the list
|
||||
$this->assertStringContainsString('viewonline-test-user1', $crawler->text());
|
||||
$this->assertStringContainsString($this->lang('READING_FORUM', $this->get_forum_name_by_forum_id(2)), $crawler->text());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue