Issues (2014)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/Unit/ServiceFactoryTest.php (24 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @author     David Desberg <[email protected]>
4
 * @author     Chris Heng <[email protected]>
5
 * @author     Pieter Hordijk <[email protected]>
6
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
7
 */
8
9
namespace OAuth\Unit;
10
11
use OAuth\ServiceFactory;
12
use PHPUnit\Framework\TestCase;
13
14
class ServiceFactoryTest extends TestCase
15
{
16
    /**
17
     * @covers \OAuth\ServiceFactory::setHttpClient
18
     */
19
    public function testSetHttpClient(): void
20
    {
21
        $factory = new ServiceFactory();
22
23
        self::assertInstanceOf(
24
            '\\OAuth\\ServiceFactory',
25
            $factory->setHttpClient($this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'))
0 ignored issues
show
$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...
26
        );
27
    }
28
29
    /**
30
     * @covers \OAuth\ServiceFactory::registerService
31
     */
32
    public function testRegisterServiceThrowsExceptionNonExistentClass(): void
33
    {
34
        $this->expectException('\\OAuth\Common\Exception\Exception');
35
36
        $factory = new ServiceFactory();
37
        $factory->registerService('foo', 'bar');
38
    }
39
40
    /**
41
     * @covers \OAuth\ServiceFactory::registerService
42
     */
43
    public function testRegisterServiceThrowsExceptionWithClassIncorrectImplementation(): void
44
    {
45
        $this->expectException('\\OAuth\Common\Exception\Exception');
46
47
        $factory = new ServiceFactory();
48
        $factory->registerService('foo', 'OAuth\\ServiceFactory');
49
    }
50
51
    /**
52
     * @covers \OAuth\ServiceFactory::registerService
53
     */
54
    public function testRegisterServiceSuccessOAuth1(): void
55
    {
56
        $factory = new ServiceFactory();
57
58
        self::assertInstanceOf(
59
            '\\OAuth\\ServiceFactory',
60
            $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake')
61
        );
62
    }
63
64
    /**
65
     * @covers \OAuth\ServiceFactory::registerService
66
     */
67
    public function testRegisterServiceSuccessOAuth2(): void
68
    {
69
        $factory = new ServiceFactory();
70
71
        self::assertInstanceOf(
72
            '\\OAuth\\ServiceFactory',
73
            $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake')
74
        );
75
    }
76
77
    /**
78
     * @covers \OAuth\ServiceFactory::buildV1Service
79
     * @covers \OAuth\ServiceFactory::createService
80
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
81
     */
82
    public function testCreateServiceOAuth1NonRegistered(): void
83
    {
84
        $factory = new ServiceFactory();
85
86
        $service = $factory->createService(
87
            'twitter',
88
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
89
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
$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...
90
        );
91
92
        self::assertInstanceOf('\\OAuth\\OAuth1\\Service\\Twitter', $service);
93
    }
94
95
    /**
96
     * @covers \OAuth\ServiceFactory::buildV1Service
97
     * @covers \OAuth\ServiceFactory::createService
98
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
99
     * @covers \OAuth\ServiceFactory::registerService
100
     */
101
    public function testCreateServiceOAuth1Registered(): void
102
    {
103
        $factory = new ServiceFactory();
104
105
        $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake');
106
107
        $service = $factory->createService(
108
            'foo',
109
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
110
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
$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...
111
        );
112
113
        self::assertInstanceOf('\\OAuth\OAuth1\Service\\ServiceInterface', $service);
114
        self::assertInstanceOf('\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake', $service);
115
    }
116
117
    /**
118
     * @covers \OAuth\ServiceFactory::buildV1Service
119
     * @covers \OAuth\ServiceFactory::createService
120
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
121
     * @covers \OAuth\ServiceFactory::registerService
122
     */
123
    public function testCreateServiceOAuth1RegisteredAndNonRegisteredSameName(): void
124
    {
125
        $factory = new ServiceFactory();
126
127
        $factory->registerService('twitter', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake');
128
129
        $service = $factory->createService(
130
            'twitter',
131
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
132
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
$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...
133
        );
134
135
        self::assertInstanceOf('\\OAuth\OAuth1\Service\\ServiceInterface', $service);
136
        self::assertInstanceOf('\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake', $service);
137
    }
138
139
    /**
140
     * @covers \OAuth\ServiceFactory::buildV2Service
141
     * @covers \OAuth\ServiceFactory::createService
142
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
143
     * @covers \OAuth\ServiceFactory::resolveScopes
144
     */
145
    public function testCreateServiceOAuth2NonRegistered(): void
146
    {
147
        $factory = new ServiceFactory();
148
149
        $service = $factory->createService(
150
            'facebook',
151
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
152
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
$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...
153
        );
154
155
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\Facebook', $service);
156
    }
157
158
    /**
159
     * @covers \OAuth\ServiceFactory::buildV2Service
160
     * @covers \OAuth\ServiceFactory::createService
161
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
162
     * @covers \OAuth\ServiceFactory::resolveScopes
163
     */
164
    public function testCreateServiceOAuth2Registered(): void
165
    {
166
        $factory = new ServiceFactory();
167
168
        $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake');
169
170
        $service = $factory->createService(
171
            'foo',
172
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
173
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
$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...
174
        );
175
176
        self::assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service);
177
        self::assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service);
178
    }
179
180
    /**
181
     * @covers \OAuth\ServiceFactory::buildV2Service
182
     * @covers \OAuth\ServiceFactory::createService
183
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
184
     * @covers \OAuth\ServiceFactory::resolveScopes
185
     */
186
    public function testCreateServiceOAuth2RegisteredAndNonRegisteredSameName(): void
187
    {
188
        $factory = new ServiceFactory();
189
190
        $factory->registerService('facebook', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake');
191
192
        $service = $factory->createService(
193
            'facebook',
194
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
195
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
$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...
196
        );
197
198
        self::assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service);
199
        self::assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service);
200
    }
201
202
    /**
203
     * @covers \OAuth\ServiceFactory::buildV1Service
204
     * @covers \OAuth\ServiceFactory::createService
205
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
206
     * @covers \OAuth\ServiceFactory::registerService
207
     */
208
    public function testCreateServiceThrowsExceptionOnPassingScopesToV1Service(): void
209
    {
210
        $this->expectException('\\OAuth\Common\Exception\Exception');
211
212
        $factory = new ServiceFactory();
213
214
        $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake');
215
216
        $service = $factory->createService(
0 ignored issues
show
$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...
217
            'foo',
218
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
219
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
0 ignored issues
show
$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...
220
            ['bar']
221
        );
222
    }
223
224
    /**
225
     * @covers \OAuth\ServiceFactory::createService
226
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
227
     */
228
    public function testCreateServiceNonExistentService(): void
229
    {
230
        $factory = new ServiceFactory();
231
232
        $service = $factory->createService(
233
            'foo',
234
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
235
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
$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...
236
        );
237
238
        self::assertNull($service);
239
    }
240
241
    /**
242
     * @covers \OAuth\ServiceFactory::buildV2Service
243
     * @covers \OAuth\ServiceFactory::createService
244
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
245
     * @covers \OAuth\ServiceFactory::registerService
246
     * @covers \OAuth\ServiceFactory::resolveScopes
247
     */
248
    public function testCreateServicePrefersOauth2(): void
249
    {
250
        $factory = new ServiceFactory();
251
252
        $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth1\\Service\\Fake');
253
        $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake');
254
255
        $service = $factory->createService(
256
            'foo',
257
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
258
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
$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...
259
        );
260
261
        self::assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service);
262
        self::assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service);
263
    }
264
265
    /**
266
     * @covers \OAuth\ServiceFactory::buildV2Service
267
     * @covers \OAuth\ServiceFactory::createService
268
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
269
     * @covers \OAuth\ServiceFactory::resolveScopes
270
     */
271
    public function testCreateServiceOAuth2RegisteredWithClassConstantsAsScope(): void
272
    {
273
        $factory = new ServiceFactory();
274
275
        $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake');
276
277
        $service = $factory->createService(
278
            'foo',
279
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
280
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
0 ignored issues
show
$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...
281
            ['FOO']
282
        );
283
284
        self::assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service);
285
        self::assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service);
286
    }
287
288
    /**
289
     * @covers \OAuth\ServiceFactory::buildV2Service
290
     * @covers \OAuth\ServiceFactory::createService
291
     * @covers \OAuth\ServiceFactory::getFullyQualifiedServiceName
292
     * @covers \OAuth\ServiceFactory::resolveScopes
293
     */
294
    public function testCreateServiceOAuth2RegisteredWithCustomScope(): void
295
    {
296
        $factory = new ServiceFactory();
297
298
        $factory->registerService('foo', '\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake');
299
300
        $service = $factory->createService(
301
            'foo',
302
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
$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...
303
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
0 ignored issues
show
$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...
304
            ['custom']
305
        );
306
307
        self::assertInstanceOf('\\OAuth\OAuth2\Service\\ServiceInterface', $service);
308
        self::assertInstanceOf('\\OAuthTest\\Mocks\\OAuth2\\Service\\Fake', $service);
309
    }
310
}
311