1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
<?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.method.board', true),
array('notification.type.topic_notification.method.board', 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.method.board', true),
array('notification.type.quote_notification.method.board', 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->assertCount(1, $crawler->filter('#notification_list_button strong.badge.hidden'));
$this->assertEquals("0", $crawler->filter('#notification_list_button strong.badge.hidden')->text());
}
}
|