1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace vipnytt\CleanParamFilter\Tests; |
4
|
|
|
|
5
|
|
|
use vipnytt\CleanParamFilter; |
6
|
|
|
|
7
|
|
|
class UndefinedHostTest extends \PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* Basic usage test |
11
|
|
|
* |
12
|
|
|
* @dataProvider generateDataForTest |
13
|
|
|
* @param array $urls |
14
|
|
|
* @expectedException \PHPUnit_Framework_Error_WARNING |
15
|
|
|
* @return void |
16
|
|
|
*/ |
17
|
|
|
public function testUndefinedHost($urls) |
18
|
|
|
{ |
19
|
|
|
$filter = new CleanParamFilter($urls); |
20
|
|
|
$this->assertInstanceOf('vipnytt\CleanParamFilter', $filter); |
21
|
|
|
|
22
|
|
|
$filter->addCleanParam('articleID'); |
23
|
|
|
|
24
|
|
|
// Contains |
25
|
|
|
$this->assertContains('http:/example.com/', $filter->listApproved()); |
26
|
|
|
$this->assertContains('http:/example.com/?articleID', $filter->listApproved()); |
27
|
|
|
$this->assertContains('http:/example.net/', $filter->listApproved()); |
28
|
|
|
$this->assertContains('http:/example.net/?articleID', $filter->listApproved()); |
29
|
|
|
// Same tests as over, but as opposite of the first |
30
|
|
|
$this->assertNotContains('http:/example.com/', $filter->listDuplicate()); |
31
|
|
|
$this->assertNotContains('http:/example.com/?articleID', $filter->listDuplicate()); |
32
|
|
|
$this->assertNotContains('http:/example.net/', $filter->listDuplicate()); |
33
|
|
|
$this->assertNotContains('http:/example.net/?articleID', $filter->listDuplicate()); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Generate test case data |
38
|
|
|
* @return array |
39
|
|
|
*/ |
40
|
|
|
public function generateDataForTest() |
41
|
|
|
{ |
42
|
|
|
return array( |
43
|
|
|
array( |
44
|
|
|
array( |
45
|
|
|
'http://example.com/', |
46
|
|
|
'http://example.com/?articleID', |
47
|
|
|
'http://example.net/', |
48
|
|
|
'http://example.net/?articleID' |
49
|
|
|
) |
50
|
|
|
) |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|