Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
31.25% |
5 / 16 |
|
66.67% |
4 / 6 |
CRAP | |
0.00% |
0 / 1 |
| phpbb_mcp_post_ip_test | |
31.25% |
5 / 16 |
|
66.67% |
4 / 6 |
17.70 | |
0.00% |
0 / 1 |
| getDataSet | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setUp | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| data_get_num_ips | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| test_get_num_ips | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| data_get_num_posters | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| test_get_num_posters | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | require_once __DIR__ . '/../../phpBB/includes/mcp/mcp_post.php'; |
| 15 | |
| 16 | class phpbb_mcp_post_ip_test extends phpbb_database_test_case |
| 17 | { |
| 18 | /** @var \phpbb\db\driver\driver_interface */ |
| 19 | protected $db; |
| 20 | |
| 21 | public function getDataSet() |
| 22 | { |
| 23 | return $this->createXMLDataSet(__DIR__ . '/fixtures/post_ip.xml'); |
| 24 | } |
| 25 | |
| 26 | protected function setUp(): void |
| 27 | { |
| 28 | parent::setUp(); |
| 29 | |
| 30 | $this->db = $this->new_dbal(); |
| 31 | } |
| 32 | |
| 33 | public static function data_get_num_ips() |
| 34 | { |
| 35 | return array( |
| 36 | array(2, 1), |
| 37 | array(2, 2), |
| 38 | array(0, 3), |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @dataProvider data_get_num_ips |
| 44 | */ |
| 45 | public function test_get_num_ips($expected, $poster_id) |
| 46 | { |
| 47 | $this->assertSame($expected, phpbb_get_num_ips_for_poster($this->db, $poster_id)); |
| 48 | } |
| 49 | |
| 50 | public static function data_get_num_posters() |
| 51 | { |
| 52 | return array( |
| 53 | array(2, '127.0.0.1'), |
| 54 | array(1, '127.0.0.2'), |
| 55 | array(1, '127.0.0.3'), |
| 56 | array(0, '127.0.0.4'), |
| 57 | ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @dataProvider data_get_num_posters |
| 62 | */ |
| 63 | public function test_get_num_posters($expected, $ip) |
| 64 | { |
| 65 | $this->assertSame($expected, phpbb_get_num_posters_for_ip($this->db, $ip)); |
| 66 | } |
| 67 | } |