aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functions_privmsgs/get_max_setting_from_group_test.php
blob: b96f490c886ceeb3ead11e233e62da61eac50ee8 (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
<?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__) . '/../../phpBB/includes/functions_privmsgs.php';

class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_database_test_case
{
	public function getDataSet()
	{
		return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/get_max_setting_from_group.xml');
	}

	/** @var \phpbb\db\driver\driver_interface */
	protected $db;

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

		$this->db = $this->new_dbal();
	}

	static public function get_max_setting_from_group_data()
	{
		return array(
			array(1, 2, 'message_limit'),
			array(2, 2, 'message_limit'),
			array(3, 0, 'message_limit'),
			array(4, 0, 'message_limit'),
			array(5, 2, 'message_limit'),
			array(1, 4, 'max_recipients'),
			array(2, 4, 'max_recipients'),
			array(3, 0, 'max_recipients'),
			array(4, 5, 'max_recipients'),
			array(5, 4, 'max_recipients'),
		);
	}

	/**
	* @dataProvider get_max_setting_from_group_data
	*/
	public function test_get_max_setting_from_group($user_id, $expected, $setting)
	{
		$this->assertEquals($expected, phpbb_get_max_setting_from_group($this->db, $user_id, $setting));
	}

	/**
	 * @expectedException InvalidArgumentException
	 */
	public function test_get_max_setting_from_group_throws()
	{
		phpbb_get_max_setting_from_group($this->db, ANONYMOUS, 'not_a_setting');
	}
}