@@ 16-40 (lines=25) @@ | ||
13 | * @param array $urls |
|
14 | * @return void |
|
15 | */ |
|
16 | public function testCleanParam($urls) |
|
17 | { |
|
18 | $filter = new CleanParamFilter($urls); |
|
19 | $this->assertInstanceOf('vipnytt\CleanParamFilter', $filter); |
|
20 | ||
21 | $filter->addCleanParam('ref'); |
|
22 | $filter->addCleanParam('uid', '/page2/', 'example.com'); |
|
23 | ||
24 | // Contains |
|
25 | $this->assertContains('http://example.com/', $filter->listApproved()); |
|
26 | $this->assertContains('http://example.com/?ref=somewhere1', $filter->listDuplicate()); |
|
27 | $this->assertContains('http://example.com/?ref=somewhere3&test1=3', $filter->listApproved()); |
|
28 | $this->assertContains('http://example.com/?ref=somewhere5&test1=3', $filter->listDuplicate()); |
|
29 | $this->assertContains('http://example.com/page1/', $filter->listApproved()); |
|
30 | $this->assertContains('http://example.com/page1/?uid=12345', $filter->listApproved()); |
|
31 | $this->assertContains('http://example.com:80/', $filter->listDuplicate()); |
|
32 | // Same tests as over, but as opposite of the first |
|
33 | $this->assertNotContains('http://example.com/', $filter->listDuplicate()); |
|
34 | $this->assertNotContains('http://example.com/?ref=somewhere1', $filter->listApproved()); |
|
35 | $this->assertNotContains('http://example.com/?ref=somewhere3&test1=3', $filter->listDuplicate()); |
|
36 | $this->assertNotContains('http://example.com/?ref=somewhere5&test1=3', $filter->listApproved()); |
|
37 | $this->assertNotContains('http://example.com/page1/', $filter->listDuplicate()); |
|
38 | $this->assertNotContains('http://example.com/page1/?uid=12345', $filter->listDuplicate()); |
|
39 | $this->assertNotContains('http://example.com:80/', $filter->listApproved()); |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * Generate test case data |
@@ 16-40 (lines=25) @@ | ||
13 | * @param array $urls |
|
14 | * @return void |
|
15 | */ |
|
16 | public function testMultiHost($urls) |
|
17 | { |
|
18 | $filter = new CleanParamFilter($urls); |
|
19 | $this->assertInstanceOf('vipnytt\CleanParamFilter', $filter); |
|
20 | ||
21 | $filter->addCleanParam('ref', '/', 'example.com'); |
|
22 | $filter->addCleanParam('uid', '/', 'test.net'); |
|
23 | ||
24 | // Contains |
|
25 | $this->assertContains('http://example.com/', $filter->listApproved()); |
|
26 | $this->assertContains('http://example.com/?ref=somewhere', $filter->listDuplicate()); |
|
27 | $this->assertContains('http://example.com/?uid=12345', $filter->listApproved()); |
|
28 | $this->assertContains('http://test.net/', $filter->listApproved()); |
|
29 | $this->assertContains('http://test.net/?ref=somewhere', $filter->listApproved()); |
|
30 | $this->assertContains('http://test.net/?uid=12345', $filter->listDuplicate()); |
|
31 | $this->assertContains('http://somewhere.tld/?param=unknown', $filter->listApproved()); |
|
32 | // Same tests as over, but as opposite of the first |
|
33 | $this->assertNotContains('http://example.com/', $filter->listDuplicate()); |
|
34 | $this->assertNotContains('http://example.com/?ref=somewhere', $filter->listApproved()); |
|
35 | $this->assertNotContains('http://example.com/?uid=12345', $filter->listDuplicate()); |
|
36 | $this->assertNotContains('http://test.net/', $filter->listDuplicate()); |
|
37 | $this->assertNotContains('http://test.net/?ref=somewhere', $filter->listDuplicate()); |
|
38 | $this->assertNotContains('http://test.net/?uid=12345', $filter->listApproved()); |
|
39 | $this->assertNotContains('http://somewhere.tld/?param=unknown', $filter->listDuplicate()); |
|
40 | } |
|
41 | ||
42 | /** |
|
43 | * Generate test case data |