UrlTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 52
c 3
b 0
f 0
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A filterNullPass() 0 3 1
A filter() 0 4 1
A filterNonString() 0 5 1
A filterNullFail() 0 5 1
A filterNotValid() 0 5 1
1
<?php
2
3
namespace TraderInteractive\Filter;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * @coversDefaultClass \TraderInteractive\Filter\Url
9
 * @covers ::<private>
10
 */
11
final class UrlTest extends TestCase
12
{
13
    /**
14
     * @test
15
     * @covers ::filter
16
     */
17
    public function filter()
18
    {
19
        $url = 'http://www.example.com';
20
        $this->assertSame($url, Url::filter($url));
21
    }
22
23
    /**
24
     * @test
25
     * @covers ::filter
26
     */
27
    public function filterNonString()
28
    {
29
        $this->expectException(\TraderInteractive\Exceptions\FilterException::class);
30
        $this->expectExceptionMessage("Value '1' is not a string");
31
        Url::filter(1);
32
    }
33
34
    /**
35
     * @test
36
     * @covers ::filter
37
     */
38
    public function filterNotValid()
39
    {
40
        $this->expectException(\TraderInteractive\Exceptions\FilterException::class);
41
        $this->expectExceptionMessage("Value 'www.example.com' is not a valid url");
42
        Url::filter('www.example.com');
43
    }
44
45
    /**
46
     * @test
47
     * @covers ::filter
48
     */
49
    public function filterNullPass()
50
    {
51
        $this->assertSame(null, Url::filter(null, true));
52
    }
53
54
    /**
55
     * @test
56
     * @covers ::filter
57
     */
58
    public function filterNullFail()
59
    {
60
        $this->expectException(\TraderInteractive\Exceptions\FilterException::class);
61
        $this->expectExceptionMessage('Value failed filtering, $allowNull is set to false');
62
        Url::filter(null);
63
    }
64
}
65