Failed Conditions
Pull Request — master (#1)
by
unknown
02:11
created

UrlTest::filterNonString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TraderInteractive\Filter;
4
5
use PHPUnit\Framework\TestCase;
6
7
/**
8
 * @coversDefaultClass \TraderInteractive\Filter\Url
9
 */
10
final class UrlTest extends TestCase
11
{
12
    /**
13
     * @test
14
     * @covers ::filter
15
     */
16
    public function filter()
17
    {
18
        $url = 'http://www.example.com';
19
        $this->assertSame($url, Url::filter($url));
20
    }
21
22
    /**
23
     * @test
24
     * @expectedException \TraderInteractive\Exceptions\FilterException
25
     * @expectedExceptionMessage Value '1' is not a valid url
26
     * @covers ::filter
27
     */
28
    public function filterNonString()
29
    {
30
        Url::filter(1);
31
    }
32
33
    /**
34
     * @test
35
     * @expectedException \TraderInteractive\Exceptions\FilterException
36
     * @expectedExceptionMessage Value 'www.example.com' is not a valid url
37
     * @covers ::filter
38
     */
39
    public function filterNotValid()
40
    {
41
        Url::filter('www.example.com');
42
    }
43
44
    /**
45
     * @test
46
     * @covers ::filter
47
     */
48
    public function filterNullPass()
49
    {
50
        $this->assertSame(null, Url::filter(null, true));
0 ignored issues
show
Bug introduced by
Are you sure the usage of TraderInteractive\Filter\Url::filter(null, true) targeting TraderInteractive\Filter\Url::filter() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
51
    }
52
53
    /**
54
     * @test
55
     * @expectedException \TraderInteractive\Exceptions\FilterException
56
     * @expectedExceptionMessage Value failed filtering, $allowNull is set to false
57
     * @covers ::filter
58
     */
59
    public function filterNullFail()
60
    {
61
        Url::filter(null);
62
    }
63
}
64