AbstractServiceTest   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 393
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 393
c 0
b 0
f 0
wmc 17
lcom 1
cbo 5
rs 10

17 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructCorrectInterface() 0 14 1
A testConstructCorrectParent() 0 14 1
A testConstructCorrectParentCustomUri() 0 15 1
A testConstructThrowsExceptionOnInvalidScope() 0 11 1
A testGetAuthorizationUriWithoutParametersOrScopes() 0 17 1
A testGetAuthorizationUriWithParametersWithoutScopes() 0 17 1
A testGetAuthorizationUriWithParametersAndScopes() 0 18 1
A testRequestAccessToken() 0 10 1
A testRequestThrowsExceptionWhenTokenIsExpired() 0 20 1
A testRequestOauthAuthorizationMethod() 0 23 1
A testRequestQueryStringMethod() 0 25 1
A testRequestQueryStringTwoMethod() 0 25 1
A testRequestBearerMethod() 0 25 1
A testGetStorage() 0 10 1
A testRefreshAccessTokenSuccess() 0 13 1
A testIsValidScopeTrue() 0 10 1
A testIsValidScopeFalse() 0 10 1
1
<?php
2
3
namespace OAuthTest\Unit\OAuth2\Service;
4
5
use DateTime;
6
use OAuth\Common\Token\TokenInterface;
7
use OAuthTest\Mocks\OAuth2\Service\Mock;
8
use PHPUnit\Framework\TestCase;
9
10
class AbstractServiceTest extends TestCase
11
{
12
    /**
13
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
14
     */
15
    public function testConstructCorrectInterface(): void
16
    {
17
        $service = $this->getMockForAbstractClass(
18
            '\\OAuth\\OAuth2\\Service\\AbstractService',
19
            [
20
                $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
21
                $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
22
                $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
23
                [],
24
            ]
25
        );
26
27
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service);
28
    }
29
30
    /**
31
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
32
     */
33
    public function testConstructCorrectParent(): void
34
    {
35
        $service = $this->getMockForAbstractClass(
36
            '\\OAuth\\OAuth2\\Service\\AbstractService',
37
            [
38
                $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
39
                $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
40
                $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
41
                [],
42
            ]
43
        );
44
45
        self::assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service);
46
    }
47
48
    /**
49
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
50
     */
51
    public function testConstructCorrectParentCustomUri(): void
52
    {
53
        $service = $this->getMockForAbstractClass(
54
            '\\OAuth\\OAuth2\\Service\\AbstractService',
55
            [
56
                $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
57
                $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
58
                $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
59
                [],
60
                $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'),
61
            ]
62
        );
63
64
        self::assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service);
65
    }
66
67
    /**
68
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
69
     * @covers \OAuth\OAuth2\Service\AbstractService::isValidScope
70
     */
71
    public function testConstructThrowsExceptionOnInvalidScope(): void
72
    {
73
        $this->expectException('\\OAuth\\OAuth2\\Service\\Exception\\InvalidScopeException');
74
75
        $service = new Mock(
0 ignored issues
show
Unused Code introduced by
$service is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
76
            $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...
77
            $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...
78
            $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...
79
            ['invalidscope']
80
        );
81
    }
82
83
    /**
84
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
85
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint
86
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationUri
87
     */
88
    public function testGetAuthorizationUriWithoutParametersOrScopes(): void
89
    {
90
        $credentials = $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface');
91
        $credentials->expects(self::once())->method('getConsumerId')->willReturn('foo');
92
        $credentials->expects(self::once())->method('getCallbackUrl')->willReturn('bar');
93
94
        $service = new Mock(
95
            $credentials,
0 ignored issues
show
Documentation introduced by
$credentials 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...
96
            $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...
97
            $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...
98
        );
99
100
        self::assertSame(
101
            'http://pieterhordijk.com/auth?type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=',
102
            $service->getAuthorizationUri()->getAbsoluteUri()
103
        );
104
    }
105
106
    /**
107
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
108
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint
109
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationUri
110
     */
111
    public function testGetAuthorizationUriWithParametersWithoutScopes(): void
112
    {
113
        $credentials = $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface');
114
        $credentials->expects(self::once())->method('getConsumerId')->willReturn('foo');
115
        $credentials->expects(self::once())->method('getCallbackUrl')->willReturn('bar');
116
117
        $service = new Mock(
118
            $credentials,
0 ignored issues
show
Documentation introduced by
$credentials 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...
119
            $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...
120
            $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...
121
        );
122
123
        self::assertSame(
124
            'http://pieterhordijk.com/auth?foo=bar&baz=beer&type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=',
125
            $service->getAuthorizationUri(['foo' => 'bar', 'baz' => 'beer'])->getAbsoluteUri()
126
        );
127
    }
128
129
    /**
130
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
131
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint
132
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationUri
133
     * @covers \OAuth\OAuth2\Service\AbstractService::isValidScope
134
     */
135
    public function testGetAuthorizationUriWithParametersAndScopes(): void
136
    {
137
        $credentials = $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface');
138
        $credentials->expects(self::once())->method('getConsumerId')->willReturn('foo');
139
        $credentials->expects(self::once())->method('getCallbackUrl')->willReturn('bar');
140
141
        $service = new Mock(
142
            $credentials,
0 ignored issues
show
Documentation introduced by
$credentials 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...
143
            $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...
144
            $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...
145
            ['mock', 'mock2']
146
        );
147
148
        self::assertSame(
149
            'http://pieterhordijk.com/auth?foo=bar&baz=beer&type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=mock+mock2',
150
            $service->getAuthorizationUri(['foo' => 'bar', 'baz' => 'beer'])->getAbsoluteUri()
151
        );
152
    }
153
154
    /**
155
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
156
     * @covers \OAuth\OAuth2\Service\AbstractService::getAccessTokenEndpoint
157
     * @covers \OAuth\OAuth2\Service\AbstractService::getExtraOAuthHeaders
158
     * @covers \OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse
159
     * @covers \OAuth\OAuth2\Service\AbstractService::requestAccessToken
160
     * @covers \OAuth\OAuth2\Service\AbstractService::service
161
     */
162
    public function testRequestAccessToken(): void
163
    {
164
        $service = new Mock(
165
            $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...
166
            $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...
167
            $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...
168
        );
169
170
        $this->assertInstanceof('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('code'));
171
    }
172
173
    /**
174
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
175
     * @covers \OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath
176
     * @covers \OAuth\OAuth2\Service\AbstractService::request
177
     */
178
    public function testRequestThrowsExceptionWhenTokenIsExpired(): void
179
    {
180
        $tokenExpiration = new DateTime('26-03-1984 00:00:00');
181
182
        $token = $this->createMock('\\OAuth\\OAuth2\\Token\\TokenInterface');
183
        $token->expects(self::any())->method('getEndOfLife')->willReturn($tokenExpiration->format('U'));
184
185
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
186
        $storage->expects(self::once())->method('retrieveAccessToken')->willReturn($token);
187
188
        $service = new Mock(
189
            $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...
190
            $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...
191
            $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...
192
        );
193
194
        $this->expectException('\\OAuth\\Common\\Token\\Exception\\ExpiredTokenException', 'Token expired on 03/26/1984 at 12:00:00 AM');
0 ignored issues
show
Unused Code introduced by
The call to AbstractServiceTest::expectException() has too many arguments starting with 'Token expired on 03/26/1984 at 12:00:00 AM'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
195
196
        $service->request('https://pieterhordijk.com/my/awesome/path');
197
    }
198
199
    /**
200
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
201
     * @covers \OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath
202
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod
203
     * @covers \OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders
204
     * @covers \OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse
205
     * @covers \OAuth\OAuth2\Service\AbstractService::request
206
     * @covers \OAuth\OAuth2\Service\AbstractService::service
207
     */
208
    public function testRequestOauthAuthorizationMethod(): void
209
    {
210
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
211
        $client->expects(self::once())->method('retrieveResponse')->willReturnArgument(2);
212
213
        $token = $this->createMock('\\OAuth\\OAuth2\\Token\\TokenInterface');
214
        $token->expects(self::once())->method('getEndOfLife')->willReturn(TokenInterface::EOL_NEVER_EXPIRES);
215
        $token->expects(self::once())->method('getAccessToken')->willReturn('foo');
216
217
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
218
        $storage->expects(self::once())->method('retrieveAccessToken')->willReturn($token);
219
220
        $service = new Mock(
221
            $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...
222
            $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...
223
            $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...
224
        );
225
226
        $headers = $service->request('https://pieterhordijk.com/my/awesome/path');
227
228
        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...
229
        self::assertTrue(in_array('OAuth foo', $headers, true));
230
    }
231
232
    /**
233
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
234
     * @covers \OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath
235
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod
236
     * @covers \OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders
237
     * @covers \OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse
238
     * @covers \OAuth\OAuth2\Service\AbstractService::request
239
     * @covers \OAuth\OAuth2\Service\AbstractService::service
240
     */
241
    public function testRequestQueryStringMethod(): void
242
    {
243
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
244
        $client->expects(self::once())->method('retrieveResponse')->willReturnArgument(0);
245
246
        $token = $this->createMock('\\OAuth\\OAuth2\\Token\\TokenInterface');
247
        $token->expects(self::once())->method('getEndOfLife')->willReturn(TokenInterface::EOL_NEVER_EXPIRES);
248
        $token->expects(self::once())->method('getAccessToken')->willReturn('foo');
249
250
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
251
        $storage->expects(self::once())->method('retrieveAccessToken')->willReturn($token);
252
253
        $service = new Mock(
254
            $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...
255
            $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...
256
            $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...
257
        );
258
259
        $service->setAuthorizationMethod('querystring');
260
261
        $uri = $service->request('https://pieterhordijk.com/my/awesome/path');
262
        $absoluteUri = parse_url($uri->getAbsoluteUri());
0 ignored issues
show
Bug introduced by
The method getAbsoluteUri cannot be called on $uri (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
263
264
        self::assertSame('access_token=foo', $absoluteUri['query']);
265
    }
266
267
    /**
268
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
269
     * @covers \OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath
270
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod
271
     * @covers \OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders
272
     * @covers \OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse
273
     * @covers \OAuth\OAuth2\Service\AbstractService::request
274
     * @covers \OAuth\OAuth2\Service\AbstractService::service
275
     */
276
    public function testRequestQueryStringTwoMethod(): void
277
    {
278
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
279
        $client->expects(self::once())->method('retrieveResponse')->willReturnArgument(0);
280
281
        $token = $this->createMock('\\OAuth\\OAuth2\\Token\\TokenInterface');
282
        $token->expects(self::once())->method('getEndOfLife')->willReturn(TokenInterface::EOL_NEVER_EXPIRES);
283
        $token->expects(self::once())->method('getAccessToken')->willReturn('foo');
284
285
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
286
        $storage->expects(self::once())->method('retrieveAccessToken')->willReturn($token);
287
288
        $service = new Mock(
289
            $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...
290
            $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...
291
            $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...
292
        );
293
294
        $service->setAuthorizationMethod('querystring2');
295
296
        $uri = $service->request('https://pieterhordijk.com/my/awesome/path');
297
        $absoluteUri = parse_url($uri->getAbsoluteUri());
0 ignored issues
show
Bug introduced by
The method getAbsoluteUri cannot be called on $uri (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
298
299
        self::assertSame('oauth2_access_token=foo', $absoluteUri['query']);
300
    }
301
302
    /**
303
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
304
     * @covers \OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath
305
     * @covers \OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod
306
     * @covers \OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders
307
     * @covers \OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse
308
     * @covers \OAuth\OAuth2\Service\AbstractService::request
309
     * @covers \OAuth\OAuth2\Service\AbstractService::service
310
     */
311
    public function testRequestBearerMethod(): void
312
    {
313
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
314
        $client->expects(self::once())->method('retrieveResponse')->willReturnArgument(2);
315
316
        $token = $this->createMock('\\OAuth\\OAuth2\\Token\\TokenInterface');
317
        $token->expects(self::once())->method('getEndOfLife')->willReturn(TokenInterface::EOL_NEVER_EXPIRES);
318
        $token->expects(self::once())->method('getAccessToken')->willReturn('foo');
319
320
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
321
        $storage->expects(self::once())->method('retrieveAccessToken')->willReturn($token);
322
323
        $service = new Mock(
324
            $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...
325
            $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...
326
            $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...
327
        );
328
329
        $service->setAuthorizationMethod('bearer');
330
331
        $headers = $service->request('https://pieterhordijk.com/my/awesome/path');
332
333
        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...
334
        self::assertTrue(in_array('Bearer foo', $headers, true));
335
    }
336
337
    /**
338
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
339
     * @covers \OAuth\OAuth2\Service\AbstractService::getStorage
340
     */
341
    public function testGetStorage(): void
342
    {
343
        $service = new Mock(
344
            $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...
345
            $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...
346
            $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...
347
        );
348
349
        self::assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $service->getStorage());
350
    }
351
352
    /**
353
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
354
     * @covers \OAuth\OAuth2\Service\AbstractService::getAccessTokenEndpoint
355
     * @covers \OAuth\OAuth2\Service\AbstractService::getExtraOAuthHeaders
356
     * @covers \OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse
357
     * @covers \OAuth\OAuth2\Service\AbstractService::refreshAccessToken
358
     */
359
    public function testRefreshAccessTokenSuccess(): void
360
    {
361
        $service = new Mock(
362
            $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...
363
            $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...
364
            $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...
365
        );
366
367
        $token = $this->createMock('\\OAuth\\OAuth2\\Token\\StdOAuth2Token');
368
        $token->expects(self::once())->method('getRefreshToken')->willReturn('foo');
369
370
        self::assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->refreshAccessToken($token));
0 ignored issues
show
Documentation introduced by
$token is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Token\TokenInterface>.

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...
371
    }
372
373
    /**
374
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
375
     * @covers \OAuth\OAuth2\Service\AbstractService::isValidScope
376
     */
377
    public function testIsValidScopeTrue(): void
378
    {
379
        $service = new Mock(
380
            $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...
381
            $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...
382
            $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...
383
        );
384
385
        self::assertTrue($service->isValidScope('mock'));
386
    }
387
388
    /**
389
     * @covers \OAuth\OAuth2\Service\AbstractService::__construct
390
     * @covers \OAuth\OAuth2\Service\AbstractService::isValidScope
391
     */
392
    public function testIsValidScopeFalse(): void
393
    {
394
        $service = new Mock(
395
            $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...
396
            $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...
397
            $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...
398
        );
399
400
        self::assertFalse($service->isValidScope('invalid'));
401
    }
402
}
403