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.

AbstractWebClientTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
namespace Fam\Util\UserAgentParser;
3
4
use PHPUnit\Framework\TestCase;
5
6
class AbstractWebClientTest extends TestCase
7
{
8
    /**
9
     * @var MockWebClient
10
     */
11
    private $subject;
12
13
    protected function setUp()
14
    {
15
        parent::setUp();
16
17
        $this->subject = new MockWebClient();
18
    }
19
20
    /**
21
     * @test
22
     */
23
    public function match_WithValidValue()
24
    {
25
        $this->subject->patterns = [
26
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
27
        ];
28
        $this->assertTrue($this->subject->match(
29
            "Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9"
30
        ));
31
    }
32
33
    /**
34
     * @test
35
     */
36
    public function match_WithInvalidValue()
37
    {
38
        $this->subject->patterns = [
39
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
40
        ];
41
        $this->assertFalse($this->subject->match("Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6c"));
42
    }
43
44
    /**
45
     * @test
46
     */
47
    public function isNameEquals_WithVaildStringValue()
48
    {
49
        $this->subject->name = "firefox";
50
        $this->assertTrue($this->subject->isNameEquals("firefox"));
51
    }
52
53
    /**
54
     * @test
55
     */
56
    public function equals_WithValidOperatingSystem()
57
    {
58
        $this->subject->name = "firefox";
59
        $op = $this->getMockBuilder(WebClient::class)->getMock();
60
61
        $op->expects($this->once())
62
            ->method("getName")
63
            ->will($this->returnValue("firefox"));
64
65
        $this->assertTrue($this->subject->isNameEquals($op));
66
    }
67
68
    /**
69
     * @test
70
     * @expectedException \InvalidArgumentException
71
     */
72
    public function equals_ThorwsInvalidArgumentException()
73
    {
74
        $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...
75
    }
76
77
    /**
78
     * @test
79
     * @depends match_WithValidValue
80
     */
81
    public function getVersion()
82
    {
83
        $this->subject->patterns = [
84
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
85
        ];
86
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
87
        $this->assertEquals("9.99", $this->subject->getVersion());
88
    }
89
90
    /**
91
     * @test
92
     * @depends getVersion
93
     */
94
    public function isVersionEquals_WithValidVersion()
95
    {
96
        $this->subject->patterns = [
97
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
98
        ];
99
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
100
        $this->assertTrue($this->subject->isVersionEquals("9.99"));
101
    }
102
103
    /**
104
     * @test
105
     * @depends getVersion
106
     */
107
    public function isVersionEquals_WithInvalidVersion()
108
    {
109
        $this->subject->patterns = [
110
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
111
        ];
112
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
113
        $this->assertFalse($this->subject->isVersionEquals(__CLASS__));
114
    }
115
116
    /**
117
     * @test
118
     * @depends getVersion
119
     */
120
    public function isVersionBetween_WithValidVersions()
121
    {
122
        $this->subject->patterns = [
123
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
124
        ];
125
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
126
        $this->assertTrue($this->subject->isVersionBetween('9', '10'));
127
    }
128
129
    /**
130
     * @test
131
     * @depends getVersion
132
     */
133
    public function isVersionBetween_WithInvalidVersions()
134
    {
135
        $this->subject->patterns = [
136
            '#Opera[ /]([a-zA-Z0-9.]+)#i',
137
        ];
138
        $this->subject->match("Opera/9.99 (Windows NT 5.1; U; pl) Presto/9.9.9");
139
        $this->assertFalse($this->subject->isVersionBetween('10', '12'));
140
    }
141
}
142