GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( a5b504...99f733 )
by Dejan
02:54
created

isVersionBetween_WithInvalidVersions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 8 and the first side effect is on line 6.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace Fam\Util\UserAgentParser;
3
4
use PHPUnit\Framework\TestCase;
5
6
require_once __DIR__ . "/MockWebClient.php";
7
8
class AbstractWebClientTest extends TestCase
9
{
10
    /**
11
     * @var MockWebClient
12
     */
13
    private $subject;
14
15
    protected function setUp()
16
    {
17
        parent::setUp();
18
19
        $this->subject = new MockWebClient();
20
    }
21
22
    /**
23
     * @test
24
     */
25
    public function match_WithValidValue()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::match_WithValidValue" is not in camel caps format
Loading history...
26
    {
27
        $this->subject->patterns = [
28
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
29
        ];
30
        $this->assertTrue($this->subject->match(
31
            "Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9"
32
        ));
33
    }
34
35
    /**
36
     * @test
37
     */
38
    public function match_WithInvalidValue()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::match_WithInvalidValue" is not in camel caps format
Loading history...
39
    {
40
        $this->subject->patterns = [
41
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
42
        ];
43
        $this->assertFalse($this->subject->match("Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6c"));
44
    }
45
46
    /**
47
     * @test
48
     */
49
    public function isNameEquals_WithVaildStringValue()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::isNameEquals_WithVaildStringValue" is not in camel caps format
Loading history...
50
    {
51
        $this->subject->name = "firefox";
52
        $this->assertTrue($this->subject->isNameEquals("firefox"));
53
    }
54
55
    /**
56
     * @test
57
     */
58
    public function equals_WithValidOperatingSystem()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::equals_WithValidOperatingSystem" is not in camel caps format
Loading history...
59
    {
60
        $this->subject->name = "firefox";
61
        $op = $this->getMockBuilder(WebClient::class)->getMock();
62
63
        $op->expects($this->once())
64
            ->method("getName")
65
            ->will($this->returnValue("firefox"));
66
67
        $this->assertTrue($this->subject->isNameEquals($op));
68
    }
69
70
    /**
71
     * @test
72
     * @expectedException \InvalidArgumentException
73
     */
74
    public function equals_ThorwsInvalidArgumentException()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::equals_ThorwsInvalidArgumentException" is not in camel caps format
Loading history...
75
    {
76
        $this->subject->isNameEquals(new \stdClass());
0 ignored issues
show
Documentation introduced by
new \stdClass() is of type object<stdClass>, but the function expects a string|object<Fam\Util\UserAgentParser\WebClient>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
77
    }
78
79
    /**
80
     * @test
81
     * @depends match_WithValidValue
82
     */
83
    public function getVersion()
84
    {
85
        $this->subject->patterns = [
86
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
87
        ];
88
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
89
        $this->assertEquals("9.99", $this->subject->getVersion());
90
    }
91
92
    /**
93
     * @test
94
     * @depends getVersion
95
     */
96
    public function isVersionEquals_WithValidVersion()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::isVersionEquals_WithValidVersion" is not in camel caps format
Loading history...
97
    {
98
        $this->subject->patterns = [
99
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
100
        ];
101
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
102
        $this->assertTrue($this->subject->isVersionEquals("9.99"));
103
    }
104
105
    /**
106
     * @test
107
     * @depends getVersion
108
     */
109
    public function isVersionEquals_WithInvalidVersion()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::isVersionEquals_WithInvalidVersion" is not in camel caps format
Loading history...
110
    {
111
        $this->subject->patterns = [
112
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
113
        ];
114
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
115
        $this->assertFalse($this->subject->isVersionEquals(__CLASS__));
116
    }
117
118
    /**
119
     * @test
120
     * @depends getVersion
121
     */
122
    public function isVersionBetween_WithValidVersions()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::isVersionBetween_WithValidVersions" is not in camel caps format
Loading history...
123
    {
124
        $this->subject->patterns = [
125
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
126
        ];
127
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
128
        $this->assertTrue($this->subject->isVersionBetween('9', '10'));
129
    }
130
131
    /**
132
     * @test
133
     * @depends getVersion
134
     */
135
    public function isVersionBetween_WithInvalidVersions()
1 ignored issue
show
Coding Style introduced by
Method name "AbstractWebClientTest::isVersionBetween_WithInvalidVersions" is not in camel caps format
Loading history...
136
    {
137
        $this->subject->patterns = [
138
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
139
        ];
140
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
141
        $this->assertFalse($this->subject->isVersionBetween('10', '12'));
142
    }
143
}
144