AbstractServiceTest   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 235
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
dl 0
loc 235
c 0
b 0
f 0
wmc 9
lcom 1
cbo 6
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructCorrectInterface() 0 15 1
A testConstructCorrectParent() 0 15 1
A testRequestRequestTokenBuildAuthHeaderTokenRequestWithoutParams() 0 17 1
A testGetAuthorizationUriWithoutParameters() 0 12 1
A testGetAuthorizationUriWithParameters() 0 15 1
A testRequestAccessTokenWithoutSecret() 0 23 1
A testRequestAccessTokenWithSecret() 0 22 1
A testRequest() 0 21 1
A testRequestNonArrayBody() 0 20 1
1
<?php
2
3
namespace OAuthTest\Unit\OAuth1\Service;
4
5
use OAuthTest\Mocks\OAuth1\Service\Mock;
6
use PHPUnit\Framework\Assert;
7
use PHPUnit\Framework\TestCase;
8
9
class AbstractServiceTest extends TestCase
10
{
11
    /**
12
     * @covers \AbstractService::__construct
13
     */
14
    public function testConstructCorrectInterface(): void
15
    {
16
        $service = $this->getMockForAbstractClass(
17
            '\\OAuth\\OAuth1\\Service\\AbstractService',
18
            [
19
                $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
20
                $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
21
                $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
22
                $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
23
                $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'),
24
            ]
25
        );
26
27
        self::assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service);
28
    }
29
30
    /**
31
     * @covers \AbstractService::__construct
32
     */
33
    public function testConstructCorrectParent(): void
34
    {
35
        $service = $this->getMockForAbstractClass(
36
            '\\OAuth\\OAuth1\\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
                $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
42
                $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'),
43
            ]
44
        );
45
46
        self::assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service);
47
    }
48
49
    /**
50
     * @covers \AbstractService::buildAuthorizationHeaderForTokenRequest
51
     * @covers \AbstractService::generateNonce
52
     * @covers \AbstractService::getBasicAuthorizationHeaderInfo
53
     * @covers \AbstractService::getExtraOAuthHeaders
54
     * @covers \AbstractService::getSignatureMethod
55
     * @covers \AbstractService::getVersion
56
     * @covers \AbstractService::parseRequestTokenResponse
57
     * @covers \AbstractService::requestRequestToken
58
     */
59
    public function testRequestRequestTokenBuildAuthHeaderTokenRequestWithoutParams(): void
60
    {
61
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
62
        $client->expects(self::once())->method('retrieveResponse')->willReturnCallback(function ($endpoint, $array, $headers): void {
0 ignored issues
show
Unused Code introduced by
The parameter $array is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $headers is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
63
            Assert::assertSame('http://pieterhordijk.com/token', $endpoint->getAbsoluteUri());
64
        });
65
66
        $service = new Mock(
67
            $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...
68
            $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...
69
            $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...
70
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...e\\SignatureInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\OAuth1\Signature\SignatureInterface>.

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...
71
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
72
        );
73
74
        self::assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken());
75
    }
76
77
    /**
78
     * @covers \AbstractService::getAuthorizationEndpoint
79
     * @covers \AbstractService::getAuthorizationUri
80
     */
81
    public function testGetAuthorizationUriWithoutParameters(): void
82
    {
83
        $service = new Mock(
84
            $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...
85
            $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...
86
            $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...
87
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...e\\SignatureInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\OAuth1\Signature\SignatureInterface>.

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...
88
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
89
        );
90
91
        self::assertSame('http://pieterhordijk.com/auth', $service->getAuthorizationUri()->getAbsoluteUri());
92
    }
93
94
    /**
95
     * @covers \AbstractService::getAuthorizationEndpoint
96
     * @covers \AbstractService::getAuthorizationUri
97
     */
98
    public function testGetAuthorizationUriWithParameters(): void
99
    {
100
        $service = new Mock(
101
            $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...
102
            $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...
103
            $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...
104
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...e\\SignatureInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\OAuth1\Signature\SignatureInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
105
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
106
        );
107
108
        self::assertSame('http://pieterhordijk.com/auth?foo=bar&baz=beer', $service->getAuthorizationUri([
109
            'foo' => 'bar',
110
            'baz' => 'beer',
111
        ])->getAbsoluteUri());
112
    }
113
114
    /**
115
     * @covers \AbstractService::buildAuthorizationHeaderForAPIRequest
116
     * @covers \AbstractService::generateNonce
117
     * @covers \AbstractService::getAccessTokenEndpoint
118
     * @covers \AbstractService::getBasicAuthorizationHeaderInfo
119
     * @covers \AbstractService::getExtraOAuthHeaders
120
     * @covers \AbstractService::getSignatureMethod
121
     * @covers \AbstractService::getVersion
122
     * @covers \AbstractService::parseAccessTokenResponse
123
     * @covers \AbstractService::requestAccessToken
124
     * @covers \AbstractService::service
125
     */
126
    public function testRequestAccessTokenWithoutSecret(): void
127
    {
128
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
129
        $client->expects(self::once())->method('retrieveResponse')->willReturnCallback(function ($endpoint, $array, $headers): void {
0 ignored issues
show
Unused Code introduced by
The parameter $array is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $headers is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
130
            Assert::assertSame('http://pieterhordijk.com/access', $endpoint->getAbsoluteUri());
131
        });
132
133
        $token = $this->createMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
134
        $token->expects(self::once())->method('getRequestTokenSecret')->willReturn('baz');
135
136
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
137
        $storage->expects(self::any())->method('retrieveAccessToken')->willReturn($token);
138
139
        $service = new Mock(
140
            $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...
141
            $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...
142
            $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...
143
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...e\\SignatureInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\OAuth1\Signature\SignatureInterface>.

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\\Http\\Uri\\UriInterface')
145
        );
146
147
        self::assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar'));
148
    }
149
150
    /**
151
     * @covers \AbstractService::buildAuthorizationHeaderForAPIRequest
152
     * @covers \AbstractService::generateNonce
153
     * @covers \AbstractService::getAccessTokenEndpoint
154
     * @covers \AbstractService::getBasicAuthorizationHeaderInfo
155
     * @covers \AbstractService::getExtraOAuthHeaders
156
     * @covers \AbstractService::getSignatureMethod
157
     * @covers \AbstractService::getVersion
158
     * @covers \AbstractService::parseAccessTokenResponse
159
     * @covers \AbstractService::requestAccessToken
160
     * @covers \AbstractService::service
161
     */
162
    public function testRequestAccessTokenWithSecret(): void
163
    {
164
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
165
        $client->expects(self::once())->method('retrieveResponse')->willReturnCallback(function ($endpoint, $array, $headers): void {
0 ignored issues
show
Unused Code introduced by
The parameter $array is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $headers is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
166
            Assert::assertSame('http://pieterhordijk.com/access', $endpoint->getAbsoluteUri());
167
        });
168
169
        $token = $this->createMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
170
171
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
172
        $storage->expects(self::any())->method('retrieveAccessToken')->willReturn($token);
173
174
        $service = new Mock(
175
            $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...
176
            $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...
177
            $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...
178
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...e\\SignatureInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\OAuth1\Signature\SignatureInterface>.

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...
179
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
180
        );
181
182
        self::assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token));
0 ignored issues
show
Documentation introduced by
$token is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a string|null.

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...
183
    }
184
185
    /**
186
     * @covers \AbstractService::buildAuthorizationHeaderForAPIRequest
187
     * @covers \AbstractService::determineRequestUriFromPath
188
     * @covers \AbstractService::generateNonce
189
     * @covers \AbstractService::getBasicAuthorizationHeaderInfo
190
     * @covers \AbstractService::getExtraApiHeaders
191
     * @covers \AbstractService::getSignatureMethod
192
     * @covers \AbstractService::getVersion
193
     * @covers \AbstractService::request
194
     * @covers \AbstractService::service
195
     */
196
    public function testRequest(): void
197
    {
198
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
199
        $client->expects(self::once())->method('retrieveResponse')->willReturn('response!');
200
201
        $token = $this->createMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
202
        //$token->expects($this->once())->method('getRequestTokenSecret')->will($this->returnValue('baz'));
203
204
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
205
        $storage->expects(self::any())->method('retrieveAccessToken')->willReturn($token);
206
207
        $service = new Mock(
208
            $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...
209
            $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...
210
            $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...
211
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...e\\SignatureInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\OAuth1\Signature\SignatureInterface>.

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...
212
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
213
        );
214
215
        self::assertSame('response!', $service->request('/my/awesome/path'));
216
    }
217
218
    /**
219
     * This test only captures a regression in php 5.3.
220
     *
221
     * @covers \AbstractService::request
222
     */
223
    public function testRequestNonArrayBody(): void
224
    {
225
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
226
        $client->expects(self::once())->method('retrieveResponse')->willReturn('response!');
227
228
        $token = $this->createMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
229
230
        $storage = $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
231
        $storage->expects(self::any())->method('retrieveAccessToken')->willReturn($token);
232
233
        $service = new Mock(
234
            $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...
235
            $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...
236
            $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...
237
            $this->createMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...e\\SignatureInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\OAuth1\Signature\SignatureInterface>.

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...
238
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
239
        );
240
241
        self::assertSame('response!', $service->request('/my/awesome/path', 'GET', 'A text body'));
0 ignored issues
show
Documentation introduced by
'A text body' is of type string, but the function expects a array|null.

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...
242
    }
243
}
244