1<?php 2 3/** 4 * General tests for the ipban plugin 5 * 6 * @group plugin_ipban 7 * @group plugins 8 */ 9class check_plugin_ipban_test extends DokuWikiTest 10{ 11 /** 12 * Ban configuration 13 * 14 * @var array 15 */ 16 protected $banconfig = [ 17 "127.0.0.1\t1400000000\tandi\tspam", 18 "192.168.1.0/24\t1400000000\tandi\tspam", 19 "192.168.2.*\t1400000000\tandi\tspam", 20 "broken\t1400000000\tandi\tspam", 21 ]; 22 23 /** 24 * IPs to test for above config 25 * 26 * @return array 27 */ 28 public function data() 29 { 30 return [ 31 ['127.0.0.1', true], 32 ['127.0.0.2', false], 33 ['192.168.1.13', true], 34 ['192.168.2.13', true], 35 ['192.168.3.13', false], 36 ]; 37 } 38 39 /** 40 * Simple test to make sure the plugin.info.txt is in correct format 41 * 42 * @dataProvider data 43 * @param string $ip 44 * @param bool $result 45 * @throws ReflectionException 46 */ 47 public function test_banning($ip, $result) 48 { 49 $action = new action_plugin_ipban(); 50 51 $this->assertSame( 52 $result, 53 (bool) $this->callInaccessibleMethod($action,'isBanned', [$ip, $this->banconfig]) 54 ); 55 } 56 57} 58