aboutsummaryrefslogtreecommitdiffstats
path: root/tests/notification/submit_post_type_quote_test.php
blob: 655f12661b51b8ac131b6c9a8df8562a1990b17b (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?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.
*
*/

require_once dirname(__FILE__) . '/submit_post_base.php';

class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_submit_post_base
{
	protected $item_type = 'notification.type.quote';

	public function setUp(): void
	{
		parent::setUp();

		global $auth;

		// Add additional permissions
		$auth->expects($this->any())
			->method('acl_get_list')
			->with($this->anything(),
				$this->stringContains('_'),
				$this->greaterThan(0))
			->will($this->returnValueMap(array(
				array(
					array(3, 4, 5, 6, 7),
					'f_read',
					1,
					array(
						1 => array(
							'f_read' => array(3, 5, 6, 7),
						),
					),
				),
			)));
	}

	/**
	* submit_post() Notifications test
	*
	* submit_post() $mode = 'reply'
	* Notification item_type = 'quote'
	*/
	public function submit_post_data()
	{
		// The new mock container is needed because the data providers may be executed before phpunit call setUp()
		$parser = $this->get_test_case_helpers()->set_s9e_services(new phpbb_mock_container_builder())->get('text_formatter.parser');

		return array(
			/**
			* Normal post
			*
			* User => State description
			*	2	=> Poster, should NOT receive a notification
			*	3	=> Quoted, should receive a notification
			*	4	=> Quoted, but unauthed to read, should NOT receive a notification
			*	5	=> Quoted, but already notified, should STILL receive a new notification
			*	6	=> Quoted, but option disabled, should NOT receive a notification
			*	7	=> Quoted, option set to default, should receive a notification
			*/
			array(
				array(
					'message'			=> $parser->parse(implode(' ', array(
						'[quote="poster"]poster should not be notified[/quote]',
						'[quote="test"]test should be notified[/quote]',
						'[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]',
						'[quote="notified"]already notified, should not receive a new notification[/quote]',
						'[quote="disabled"]option disabled, should not receive a notification[/quote]',
						'[quote="default"]option set to default, should receive a notification[/quote]',
						'[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]',
					))),
					'bbcode_uid'		=> 'uid',
				),
				array(
					array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
				),
				array(
					array('user_id' => 3, 'item_id' => 2, 'item_parent_id' => 1),
					array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
					array('user_id' => 5, 'item_id' => 2, 'item_parent_id' => 1),
					array('user_id' => 7, 'item_id' => 2, 'item_parent_id' => 1),
				),
			),

			/**
			* Unapproved post
			*
			* No new notifications
			*/
			array(
				array(
					'message'			=> $parser->parse(implode(' ', array(
						'[quote="poster"]poster should not be notified[/quote]',
						'[quote="test"]test should be notified[/quote]',
						'[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]',
						'[quote="notified"]already notified, should not receive a new notification[/quote]',
						'[quote="disabled"]option disabled, should not receive a notification[/quote]',
						'[quote="default"]option set to default, should receive a notification[/quote]',
						'[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]',
					))),
					'bbcode_uid'		=> 'uid',
					'force_approved_state' => false,
				),
				array(
					array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
				),
				array(
					array('user_id' => 5, 'item_id' => 1, 'item_parent_id' => 1),
				),
			),
		);
	}
}