mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-24 12:03:21 +01:00
We already use a token for preventing CSRF when marking notifications read. Making a user confirm the marking read action serves no real purpose. No information will be lost by just marking the notifications read but it will prevent users from always having to confirm this action. PHPBB3-13189
88 lines
2.9 KiB
PHP
88 lines
2.9 KiB
PHP
<?php
|
|
/**
|
|
*
|
|
* This file is part of the phpBB Forum Software package.
|
|
*
|
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
|
*
|
|
* For full copyright and license information, please see
|
|
* the docs/CREDITS.txt file.
|
|
*
|
|
*/
|
|
|
|
/**
|
|
* @group functional
|
|
*/
|
|
class phpbb_functional_notification_test extends phpbb_functional_test_case
|
|
{
|
|
static public function user_subscription_data()
|
|
{
|
|
return array(
|
|
// Rows inserted by phpBB/install/schemas/schema_data.sql
|
|
// Also see PHPBB3-11460
|
|
array('notification.type.post_notification', true),
|
|
array('notification.type.topic_notification', true),
|
|
array('notification.type.post_notification.method.email', true),
|
|
array('notification.type.topic_notification.method.email', true),
|
|
|
|
// Default behaviour for in-board notifications:
|
|
// If user did not opt-out, in-board notifications are on.
|
|
array('notification.type.bookmark_notification', true),
|
|
array('notification.type.quote_notification', true),
|
|
|
|
// Default behaviour for email notifications:
|
|
// If user did not opt-in, email notifications are off.
|
|
array('notification.type.bookmark_notification.method.email', false),
|
|
array('notification.type.quote_notification.method.email', false),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider user_subscription_data
|
|
*/
|
|
public function test_user_subscriptions($checkbox_name, $expected_status)
|
|
{
|
|
$this->login();
|
|
$crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
|
|
|
|
$cplist = $crawler->filter('.table1');
|
|
if ($expected_status)
|
|
{
|
|
$this->assert_checkbox_is_checked($cplist, $checkbox_name);
|
|
}
|
|
else
|
|
{
|
|
$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');
|
|
|
|
// 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());
|
|
|
|
// Login as admin
|
|
$this->logout();
|
|
$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.')));
|
|
$this->assertEquals(0, $crawler->filter('#notification_list_button strong')->text());
|
|
}
|
|
}
|