Completed
Pull Request — master (#75)
by
unknown
01:26
created

UrlTest::filterNullFail()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace TraderInteractive\Filter;
4
5
use InvalidArgumentException;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * @coversDefaultClass \TraderInteractive\Filter\Url
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
     * @expectedException \TraderInteractive\Filter\Exception
26
     * @expectedExceptionMessage Value '1' is not a string
27
     * @covers ::filter
28
     */
29
    public function filterNonString()
30
    {
31
        Url::filter(1);
32
    }
33
34
    /**
35
     * @test
36
     * @expectedException \TraderInteractive\Filter\Exception
37
     * @expectedExceptionMessage Value 'www.example.com' is not a valid url
38
     * @covers ::filter
39
     */
40
    public function filterNotValid()
41
    {
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
     * @expectedException Exception
57
     * @expectedExceptionMessage Value 'NULL' is not a string
58
     * @covers ::filter
59
     */
60
    public function filterNullFail()
61
    {
62
        Url::filter(null);
63
    }
64
}
65