testParseAccessTokenResponseThrowsExceptionOnNulledResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace OAuthTest\Unit\OAuth2\Service;
4
5
use OAuth\Common\Token\TokenInterface;
6
use OAuth\OAuth2\Service\Box;
7
use PHPUnit\Framework\TestCase;
8
9
class BoxTest extends TestCase
10
{
11
    /**
12
     * @covers \OAuth\OAuth2\Service\Box::__construct
13
     */
14
    public function testConstructCorrectInterfaceWithoutCustomUri(): void
15
    {
16
        $service = new Box(
17
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
18
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...ient\\ClientInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
19
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
20
        );
21
22
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service);
23
    }
24
25
    /**
26
     * @covers \OAuth\OAuth2\Service\Box::__construct
27
     */
28
    public function testConstructCorrectInstanceWithoutCustomUri(): void
29
    {
30
        $service = new Box(
31
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
32
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...ient\\ClientInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
33
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
34
        );
35
36
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service);
37
    }
38
39
    /**
40
     * @covers \OAuth\OAuth2\Service\Box::__construct
41
     */
42
    public function testConstructCorrectInstanceWithCustomUri(): void
43
    {
44
        $service = new Box(
45
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
46
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...ient\\ClientInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
47
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
48
            [],
49
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
50
        );
51
52
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service);
53
    }
54
55
    /**
56
     * @covers \OAuth\OAuth2\Service\Box::__construct
57
     * @covers \OAuth\OAuth2\Service\Box::getAuthorizationEndpoint
58
     */
59
    public function testGetAuthorizationEndpoint(): void
60
    {
61
        $service = new Box(
62
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
63
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...ient\\ClientInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
64
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
65
        );
66
67
        self::assertSame('https://www.box.com/api/oauth2/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri());
68
    }
69
70
    /**
71
     * @covers \OAuth\OAuth2\Service\Box::__construct
72
     * @covers \OAuth\OAuth2\Service\Box::getAccessTokenEndpoint
73
     */
74
    public function testGetAccessTokenEndpoint(): void
75
    {
76
        $service = new Box(
77
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
78
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...ient\\ClientInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
79
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
80
        );
81
82
        self::assertSame('https://www.box.com/api/oauth2/token', $service->getAccessTokenEndpoint()->getAbsoluteUri());
83
    }
84
85
    /**
86
     * @covers \OAuth\OAuth2\Service\Box::__construct
87
     * @covers \OAuth\OAuth2\Service\Box::getAuthorizationMethod
88
     */
89
    public function testGetAuthorizationMethod(): void
90
    {
91
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
92
        $client->expects(self::once())->method('retrieveResponse')->willReturnArgument(2);
93
94
        $token = $this->createMock('\\OAuth\\OAuth2\\Token\\TokenInterface');
95
        $token->expects(self::once())->method('getEndOfLife')->willReturn(TokenInterface::EOL_NEVER_EXPIRES);
96
        $token->expects(self::once())->method('getAccessToken')->willReturn('foo');
97
98
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
99
        $storage->expects(self::once())->method('retrieveAccessToken')->willReturn($token);
100
101
        $service = new Box(
102
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
103
            $client,
0 ignored issues
show
Documentation introduced by
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
104
            $storage
0 ignored issues
show
Documentation introduced by
$storage is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
105
        );
106
107
        $headers = $service->request('https://pieterhordijk.com/my/awesome/path');
108
109
        self::assertArrayHasKey('Authorization', $headers);
0 ignored issues
show
Documentation introduced by
$headers is of type string, but the function expects a array|object<ArrayAccess>.

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...
110
        self::assertTrue(in_array('Bearer foo', $headers, true));
111
    }
112
113
    /**
114
     * @covers \OAuth\OAuth2\Service\Box::__construct
115
     * @covers \OAuth\OAuth2\Service\Box::parseAccessTokenResponse
116
     */
117
    public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse(): void
118
    {
119
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
120
        $client->expects(self::once())->method('retrieveResponse')->willReturn(null);
121
122
        $service = new Box(
123
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
124
            $client,
0 ignored issues
show
Documentation introduced by
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
125
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
126
        );
127
128
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
129
130
        $service->requestAccessToken('foo');
131
    }
132
133
    /**
134
     * @covers \OAuth\OAuth2\Service\Box::__construct
135
     * @covers \OAuth\OAuth2\Service\Box::parseAccessTokenResponse
136
     */
137
    public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription(): void
138
    {
139
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
140
        $client->expects(self::once())->method('retrieveResponse')->willReturn('error_description=some_error');
141
142
        $service = new Box(
143
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
144
            $client,
0 ignored issues
show
Documentation introduced by
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
145
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
146
        );
147
148
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
149
150
        $service->requestAccessToken('foo');
151
    }
152
153
    /**
154
     * @covers \OAuth\OAuth2\Service\Box::__construct
155
     * @covers \OAuth\OAuth2\Service\Box::parseAccessTokenResponse
156
     */
157
    public function testParseAccessTokenResponseThrowsExceptionOnError(): void
158
    {
159
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
160
        $client->expects(self::once())->method('retrieveResponse')->willReturn('error=some_error');
161
162
        $service = new Box(
163
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
164
            $client,
0 ignored issues
show
Documentation introduced by
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
165
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
166
        );
167
168
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
169
170
        $service->requestAccessToken('foo');
171
    }
172
173
    /**
174
     * @covers \OAuth\OAuth2\Service\Box::__construct
175
     * @covers \OAuth\OAuth2\Service\Box::parseAccessTokenResponse
176
     */
177
    public function testParseAccessTokenResponseValidWithoutRefreshToken(): void
178
    {
179
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
180
        $client->expects(self::once())->method('retrieveResponse')->willReturn('{"access_token":"foo","expires_in":"bar"}');
181
182
        $service = new Box(
183
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
184
            $client,
0 ignored issues
show
Documentation introduced by
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
185
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
186
        );
187
188
        self::assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo'));
189
    }
190
191
    /**
192
     * @covers \OAuth\OAuth2\Service\Box::__construct
193
     * @covers \OAuth\OAuth2\Service\Box::parseAccessTokenResponse
194
     */
195
    public function testParseAccessTokenResponseValidWithRefreshToken(): void
196
    {
197
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
198
        $client->expects(self::once())->method('retrieveResponse')->willReturn('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}');
199
200
        $service = new Box(
201
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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...
202
            $client,
0 ignored issues
show
Documentation introduced by
$client is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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...
203
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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...
204
        );
205
206
        self::assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo'));
207
    }
208
}
209