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.

match_WithValidValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
namespace Fam\Util\UserAgentParser;
3
4
use PHPUnit\Framework\TestCase;
5
6
class AbstractOperatingSystemTest extends TestCase
7
{
8
    /**
9
     *
10
     * @var MockOperatingSystem
11
     */
12
    private $subject;
13
14
    protected function setUp()
15
    {
16
        parent::setUp();
17
18
        $this->subject = new MockOperatingSystem();
19
    }
20
21
    /**
22
     * @test
23
     */
24
    public function match_WithValidValue()
25
    {
26
        $this->subject->patterns = array(
27
            '/FreeBSD/i',
28
        );
29
        $this->assertTrue($this->subject->match(
30
            "Mozilla/5.0 (compatible; Konqueror/3.2; FreeBSD 2.6) (KHTML, like Gecko)"
31
        ));
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function match_WithInvalidValue()
38
    {
39
        $this->subject->patterns = array(
40
            '/FreeBSD/i',
41
        );
42
        $this->assertFalse($this->subject->match("Lynx/2.8.4rel.1 libwww-FM/2.14 SSL-MM/1.4.1 OpenSSL/0.9.6c"));
43
    }
44
45
    /**
46
     * @test
47
     */
48
    public function equals_WithValidStringValue()
49
    {
50
        $this->subject->name = "unix";
51
        $this->assertTrue($this->subject->equals("unix"));
52
    }
53
54
    /**
55
     * @test
56
     */
57
    public function equals_WithInvalidStringValue()
58
    {
59
        $this->subject->name = "unix";
60
        $this->assertFalse($this->subject->equals("windows"));
61
    }
62
63
    /**
64
     * @test
65
     */
66
    public function equals_WithValidOperatingSystem()
67
    {
68
        $this->subject->name = 'unix';
69
        $op = $this->getMockBuilder(OperatingSystem::class)->getMock();
70
71
        $op->expects($this->once())
72
            ->method('getName')
73
            ->will($this->returnValue('unix'));
74
75
        $this->assertTrue($this->subject->equals($op));
76
    }
77
78
    /**
79
     * @test
80
     * @expectedException \InvalidArgumentException
81
     */
82
    public function equals_ThorwsInvalidArgumentException()
83
    {
84
      $this->subject->equals(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\U...Parser\OperatingSystem>.

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...
85
    }
86
}
87