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.

ExpirationVerifierTest::testValid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 16
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 16
loc 16
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace Emarref\Jwt\Verification;
4
5
class ExpirationVerifierTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * @var \PHPUnit_Framework_MockObject_MockObject|\Emarref\Jwt\Token\Payload
9
     */
10
    private $payload;
11
12
    /**
13
     * @var \PHPUnit_Framework_MockObject_MockObject|\Emarref\Jwt\Token
14
     */
15
    private $token;
16
17
    /**
18
     * @var ExpirationVerifier
19
     */
20
    private $verifier;
21
22 View Code Duplication
    public function setUp()
23
    {
24
        $this->payload = $this->getMockBuilder('Emarref\Jwt\Token\Payload')->getMock();
25
26
        $this->token = $this->getMockBuilder('Emarref\Jwt\Token')->getMock();
27
28
        $this->token->expects($this->any())
29
            ->method('getPayload')
30
            ->will($this->returnValue($this->payload));
31
32
        $this->verifier = new ExpirationVerifier();
33
    }
34
35 View Code Duplication
    public function testMissingExpiry()
36
    {
37
        $this->payload->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Emarref\Jwt\Token\Payload.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
38
                      ->method('findClaimByName')
39
                      ->will($this->returnValue(null));
40
41
        $this->verifier->verify($this->token);
42
    }
43
44
    /**
45
     * @expectedException \Emarref\Jwt\Exception\ExpiredException
46
     * @expectedExceptionMessage Token expired at "Sat, 08 Nov 2014 00:00:00 +0000"
47
     */
48 View Code Duplication
    public function testExpired()
49
    {
50
        $dateTime = new \DateTime('Sat, 08 Nov 2014 00:00:00 +0000');
51
52
        $expirationClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Expiration')->getMock();
53
54
        $expirationClaim->expects($this->exactly(3))
55
            ->method('getValue')
56
            ->will($this->returnValue($dateTime->getTimestamp()));
57
58
        $this->payload->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Emarref\Jwt\Token\Payload.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
59
            ->method('findClaimByName')
60
            ->will($this->returnValue($expirationClaim));
61
62
        $this->verifier->verify($this->token);
63
    }
64
65
    /**
66
     * @expectedException \InvalidArgumentException
67
     * @expectedExceptionMessage Invalid expiration timestamp "foobar"
68
     */
69 View Code Duplication
    public function testUnexpectedValue()
70
    {
71
        $expirationClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Expiration')->getMock();
72
73
        $expirationClaim->expects($this->exactly(3))
74
                        ->method('getValue')
75
                        ->will($this->returnValue('foobar'));
76
77
        $this->payload->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Emarref\Jwt\Token\Payload.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
78
                      ->method('findClaimByName')
79
                      ->will($this->returnValue($expirationClaim));
80
81
        $this->verifier->verify($this->token);
82
    }
83
84 View Code Duplication
    public function testValid()
85
    {
86
        $future = new \DateTime('5 minutes', new \DateTimeZone('UTC'));
87
88
        $expirationClaim = $this->getMockBuilder('Emarref\Jwt\Claim\Expiration')->getMock();
89
90
        $expirationClaim->expects($this->once())
91
            ->method('getValue')
92
            ->will($this->returnValue($future->getTimestamp()));
93
94
        $this->payload->expects($this->once())
0 ignored issues
show
Bug introduced by
The method expects does only exist in PHPUnit_Framework_MockObject_MockObject, but not in Emarref\Jwt\Token\Payload.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
95
            ->method('findClaimByName')
96
            ->will($this->returnValue($expirationClaim));
97
98
        $this->verifier->verify($this->token);
99
    }
100
}
101