mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-11 22:08:54 +00:00
Merge remote-tracking branch 'Marc/ticket/11896' into develop
* Marc/ticket/11896: [ticket/11896] Use $form_time and fix out of bounds $form_time [ticket/11896] Correctly document return of null in docblocks [ticket/11896] Minor code improvements in phpbb_functional_test_case [ticket/11896] Add functional tests for marking all notifications read [ticket/11896] Add ability to define expected message after posting [ŧicket/11896] Set form_time with time() when marking all notifications read
This commit is contained in:
commit
d213e23ab6
3 changed files with 52 additions and 10 deletions
|
@ -27,7 +27,8 @@ class ucp_notifications
|
|||
add_form_key('ucp_notification');
|
||||
|
||||
$start = $request->variable('start', 0);
|
||||
$form_time = min($request->variable('form_time', 0), time());
|
||||
$form_time = $request->variable('form_time', 0);
|
||||
$form_time = ($form_time <= 0 || $form_time > time()) ? time() : $form_time;
|
||||
|
||||
$phpbb_notifications = $phpbb_container->get('notification_manager');
|
||||
|
||||
|
|
|
@ -52,4 +52,37 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
|
|||
$this->assert_checkbox_is_unchecked($cplist, $checkbox_name);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_mark_notifications_read()
|
||||
{
|
||||
// Create a new standard user
|
||||
$this->create_user('notificationtestuser');
|
||||
$this->add_user_group('NEWLY_REGISTERED', array('notificationtestuser'));
|
||||
$this->login('notificationtestuser');
|
||||
$crawler = self::request('GET', 'index.php');
|
||||
$this->assertContains('notificationtestuser', $crawler->filter('.icon-logout')->text());
|
||||
|
||||
// Post a new post that needs approval
|
||||
$this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD');
|
||||
$crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}");
|
||||
$this->assertNotContains('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text());
|
||||
|
||||
// logout
|
||||
$crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
|
||||
|
||||
// admin login
|
||||
$this->login();
|
||||
$this->add_lang('ucp');
|
||||
$crawler = self::request('GET', 'ucp.php?i=ucp_notifications');
|
||||
|
||||
// At least one notification should exist
|
||||
$this->assertGreaterThan(0, $crawler->filter('#notification_list_button strong')->text());
|
||||
|
||||
// Get form token
|
||||
$link = $crawler->selectLink($this->lang('NOTIFICATIONS_MARK_ALL_READ'))->link()->getUri();
|
||||
$crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
|
||||
$form = $crawler->selectButton($this->lang('YES'))->form();
|
||||
$crawler = self::submit($form);
|
||||
$this->assertEquals(0, $crawler->filter('#notification_list_button strong')->text());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -868,9 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
* @return array post_id, topic_id
|
||||
* @param string $expected Lang var of expected message after posting
|
||||
* @return array|null post_id, topic_id if message is 'POST_STORED'
|
||||
*/
|
||||
public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
|
||||
public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED')
|
||||
{
|
||||
$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
|
||||
|
||||
|
@ -880,7 +881,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
'post' => true,
|
||||
), $additional_form_data);
|
||||
|
||||
return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
|
||||
return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -893,9 +894,10 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
* @return array post_id, topic_id
|
||||
* @param string $expected Lang var of expected message after posting
|
||||
* @return array|null post_id, topic_id if message is 'POST_STORED'
|
||||
*/
|
||||
public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
|
||||
public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED')
|
||||
{
|
||||
$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
|
||||
|
||||
|
@ -905,7 +907,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
'post' => true,
|
||||
), $additional_form_data);
|
||||
|
||||
return self::submit_post($posting_url, 'POST_REPLY', $form_data);
|
||||
return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -914,9 +916,10 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
* @param string $posting_url
|
||||
* @param string $posting_contains
|
||||
* @param array $form_data
|
||||
* @return array post_id, topic_id
|
||||
* @param string $expected Lang var of expected message after posting
|
||||
* @return array|null post_id, topic_id if message is 'POST_STORED'
|
||||
*/
|
||||
protected function submit_post($posting_url, $posting_contains, $form_data)
|
||||
protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED')
|
||||
{
|
||||
$this->add_lang('posting');
|
||||
|
||||
|
@ -945,7 +948,12 @@ class phpbb_functional_test_case extends phpbb_test_case
|
|||
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
|
||||
// Instead, I send it as a request with the submit button "post" set to true.
|
||||
$crawler = self::request('POST', $posting_url, $form_data);
|
||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||
$this->assertContainsLang($expected, $crawler->filter('html')->text());
|
||||
|
||||
if ($expected !== 'POST_STORED')
|
||||
{
|
||||
return;
|
||||
}
|
||||
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
|
||||
|
||||
return array(
|
||||
|
|
Loading…
Add table
Reference in a new issue