aboutsummaryrefslogtreecommitdiffstats
path: root/tests/mcp/post_ip_test.php
blob: f53066c9e670267ba77483202dd3518a225ca33b (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
<?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/mcp/mcp_post.php';

class phpbb_mcp_post_ip_test extends phpbb_database_test_case
{
	/** @var \phpbb\db\driver\driver_interface */
	protected $db;

	public function getDataSet()
	{
		return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/post_ip.xml');
	}

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

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

	public function data_get_num_ips()
	{
		return array(
			array(2, 1),
			array(2, 2),
			array(0, 3),
		);
	}

	/**
	 * @dataProvider data_get_num_ips
	 */
	public function test_get_num_ips($expected, $poster_id)
	{
		$this->assertSame($expected, phpbb_get_num_ips_for_poster($this->db, $poster_id));
	}

	public function data_get_num_posters()
	{
		return array(
			array(2, '127.0.0.1'),
			array(1, '127.0.0.2'),
			array(1, '127.0.0.3'),
			array(0, '127.0.0.4'),
		);
	}

	/**
	 * @dataProvider data_get_num_posters
	 */
	public function test_get_num_posters($expected, $ip)
	{
		$this->assertSame($expected, phpbb_get_num_posters_for_ip($this->db, $ip));
	}
}