Completed
Push — master ( 75054d...9702ee )
by Jan-Petter
04:01
created

MultiHostTest::testMultiHost()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 19

Duplication

Lines 25
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 25
loc 25
rs 8.8571
cc 1
eloc 19
nc 1
nop 1
1
<?php
2
3
namespace vipnytt\CleanParamFilter\Tests;
4
5
use vipnytt\CleanParamFilter;
6
7
class MultiHostTest extends \PHPUnit_Framework_TestCase
8
{
9
    /**
10
     * Basic usage test
11
     *
12
     * @dataProvider generateDataForTest
13
     * @param array $urls
14
     * @return void
15
     */
16 View Code Duplication
    public function testMultiHost($urls)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
44
     * @return array
45
     */
46
    public function generateDataForTest()
47
    {
48
        return array(
49
            array(
50
                array(
51
                    'http://example.com/',
52
                    'http://example.com/?ref=somewhere',
53
                    'http://example.com/?uid=12345',
54
                    'http://test.net/',
55
                    'http://test.net/?ref=somewhere',
56
                    'http://test.net/?uid=12345',
57
                    'http://somewhere.tld/?param=unknown'
58
                )
59
            )
60
        );
61
    }
62
}
63