FiveHundredPx::testGetAuthorizationEndpoint()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 12
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace OAuthTest\Unit\OAuth1\Service;
4
5
use OAuth\OAuth1\Service\FiveHundredPx;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, OAuthTest\Unit\OAuth1\Service\FiveHundredPx. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
6
use PHPUnit\Framework\TestCase;
7
8
class FiveHundredPx extends TestCase
9
{
10
    /**
11
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
12
     */
13
    public function testConstructCorrectInterfaceWithoutCustomUri(): void
14
    {
15
        $service = new self(
16
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
17
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
18
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
19
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
20
        );
21
22
        self::assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service);
23
    }
24
25
    /**
26
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
27
     */
28
    public function testConstructCorrectInstanceWithoutCustomUri(): void
29
    {
30
        $service = new self(
31
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
32
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
33
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
34
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
35
        );
36
37
        self::assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service);
38
    }
39
40
    /**
41
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
42
     */
43
    public function testConstructCorrectInstanceWithCustomUri(): void
44
    {
45
        $service = new self(
46
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
47
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
48
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
49
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
50
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
51
        );
52
53
        self::assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service);
54
    }
55
56
    /**
57
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
58
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getRequestTokenEndpoint
59
     */
60
    public function testGetRequestTokenEndpoint(): void
61
    {
62
        $service = new self(
63
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
64
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
65
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
66
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

66
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
67
        );
68
69
        self::assertSame(
70
            'https://api.500px.com/v1/oauth/request_token',
71
            $service->getRequestTokenEndpoint()->getAbsoluteUri()
0 ignored issues
show
Bug introduced by
The method getRequestTokenEndpoint() does not exist on OAuthTest\Unit\OAuth1\Service\FiveHundredPx. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

71
            $service->/** @scrutinizer ignore-call */ 
72
                      getRequestTokenEndpoint()->getAbsoluteUri()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
72
        );
73
    }
74
75
    /**
76
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
77
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getAuthorizationEndpoint
78
     */
79
    public function testGetAuthorizationEndpoint(): void
80
    {
81
        $service = new self(
82
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
83
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
84
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
85
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

85
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
86
        );
87
88
        self::assertSame(
89
            'https://api.500px.com/v1/oauth/authorize',
90
            $service->getAuthorizationEndpoint()->getAbsoluteUri()
0 ignored issues
show
Bug introduced by
The method getAuthorizationEndpoint() does not exist on OAuthTest\Unit\OAuth1\Service\FiveHundredPx. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

90
            $service->/** @scrutinizer ignore-call */ 
91
                      getAuthorizationEndpoint()->getAbsoluteUri()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
91
        );
92
    }
93
94
    /**
95
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
96
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getAccessTokenEndpoint
97
     */
98
    public function testGetAccessTokenEndpoint(): void
99
    {
100
        $service = new self(
101
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
102
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
103
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
104
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

104
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
105
        );
106
107
        self::assertSame(
108
            'https://api.500px.com/v1/oauth/access_token',
109
            $service->getAccessTokenEndpoint()->getAbsoluteUri()
0 ignored issues
show
Bug introduced by
The method getAccessTokenEndpoint() does not exist on OAuthTest\Unit\OAuth1\Service\FiveHundredPx. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

109
            $service->/** @scrutinizer ignore-call */ 
110
                      getAccessTokenEndpoint()->getAbsoluteUri()

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
110
        );
111
    }
112
113
    /**
114
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
115
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getRequestTokenEndpoint
116
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::parseRequestTokenResponse
117
     */
118
    public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse(): void
119
    {
120
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
121
        $client->expects(self::once())->method('retrieveResponse')->willReturn(null);
122
123
        $service = new self(
124
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
125
            $client,
126
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
127
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

127
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
128
        );
129
130
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
131
132
        $service->requestRequestToken();
0 ignored issues
show
Bug introduced by
The method requestRequestToken() does not exist on OAuthTest\Unit\OAuth1\Service\FiveHundredPx. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

132
        $service->/** @scrutinizer ignore-call */ 
133
                  requestRequestToken();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
133
    }
134
135
    /**
136
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
137
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getRequestTokenEndpoint
138
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::parseRequestTokenResponse
139
     */
140
    public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray(): void
141
    {
142
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
143
        $client->expects(self::once())->method('retrieveResponse')->willReturn('notanarray');
144
145
        $service = new self(
146
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
147
            $client,
148
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
149
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

149
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
150
        );
151
152
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
153
154
        $service->requestRequestToken();
155
    }
156
157
    /**
158
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
159
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getRequestTokenEndpoint
160
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::parseRequestTokenResponse
161
     */
162
    public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet(): void
163
    {
164
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
165
        $client->expects(self::once())->method('retrieveResponse')->willReturn('foo=bar');
166
167
        $service = new self(
168
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
169
            $client,
170
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
171
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

171
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
172
        );
173
174
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
175
176
        $service->requestRequestToken();
177
    }
178
179
    /**
180
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
181
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getRequestTokenEndpoint
182
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::parseRequestTokenResponse
183
     */
184
    public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue(): void
185
    {
186
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
187
        $client->expects(self::once())->method('retrieveResponse')->willReturn(
188
            'oauth_callback_confirmed=false'
189
        );
190
191
        $service = new self(
192
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
193
            $client,
194
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
195
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

195
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
196
        );
197
198
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
199
200
        $service->requestRequestToken();
201
    }
202
203
    /**
204
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
205
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getRequestTokenEndpoint
206
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::parseAccessTokenResponse
207
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::parseRequestTokenResponse
208
     */
209
    public function testParseRequestTokenResponseValid(): void
210
    {
211
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
212
        $client->expects(self::once())->method('retrieveResponse')->willReturn(
213
            'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar'
214
        );
215
216
        $service = new self(
217
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
218
            $client,
219
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
220
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

220
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
221
        );
222
223
        self::assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken());
224
    }
225
226
    /**
227
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
228
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getRequestTokenEndpoint
229
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::parseAccessTokenResponse
230
     */
231
    public function testParseAccessTokenResponseThrowsExceptionOnError(): void
232
    {
233
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
234
        $client->expects(self::once())->method('retrieveResponse')->willReturn('error=bar');
235
236
        $token = $this->createMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
237
238
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
239
        $storage->expects(self::any())->method('retrieveAccessToken')->willReturn($token);
240
241
        $service = new self(
242
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
243
            $client,
244
            $storage,
245
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

245
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
246
        );
247
248
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
249
250
        $service->requestAccessToken('foo', 'bar', $token);
0 ignored issues
show
Bug introduced by
The method requestAccessToken() does not exist on OAuthTest\Unit\OAuth1\Service\FiveHundredPx. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

250
        $service->/** @scrutinizer ignore-call */ 
251
                  requestAccessToken('foo', 'bar', $token);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
251
    }
252
253
    /**
254
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::__construct
255
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::getRequestTokenEndpoint
256
     * @covers \OAuth\OAuth1\Service\FiveHundredPx::parseAccessTokenResponse
257
     */
258
    public function testParseAccessTokenResponseValid(): void
259
    {
260
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
261
        $client->expects(self::once())->method('retrieveResponse')->willReturn(
262
            'oauth_token=foo&oauth_token_secret=bar'
263
        );
264
265
        $token = $this->createMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
266
267
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
268
        $storage->expects(self::any())->method('retrieveAccessToken')->willReturn($token);
269
270
        $service = new self(
271
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
272
            $client,
273
            $storage,
274
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
0 ignored issues
show
Unused Code introduced by
The call to OAuthTest\Unit\OAuth1\Se...undredPx::__construct() has too many arguments starting with $this->createMock('\OAut...re\SignatureInterface'). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

274
        $service = /** @scrutinizer ignore-call */ new self(

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. Please note the @ignore annotation hint above.

Loading history...
275
        );
276
277
        self::assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token));
278
    }
279
}
280