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

UndefinedHostTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 47
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testUndefinedHost() 0 18 1
A generateDataForTest() 0 13 1
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