Completed
Push — master ( 97a5f4...919181 )
by Georgio
29:58 queued 28:20
created

testConstructCorrectInstanceWithoutCustomUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace OAuthTest\Unit\OAuth2\Service;
4
5
use OAuth\OAuth2\Service\Xing;
6
use PHPUnit\Framework\TestCase;
7
8
class XingTest extends TestCase
9
{
10
    /**
11
     * @covers \OAuth\OAuth2\Service\Xing::__construct
12
     */
13
    public function testConstructCorrectInterfaceWithoutCustomUri(): void
14
    {
15
        $service = new Xing(
16
            $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...
17
            $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...
18
            $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...
19
        );
20
21
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service);
22
    }
23
24
    /**
25
     * @covers \OAuth\OAuth2\Service\Xing::__construct
26
     */
27
    public function testConstructCorrectInstanceWithoutCustomUri(): void
28
    {
29
        $service = new Xing(
30
            $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...
31
            $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...
32
            $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...
33
        );
34
35
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service);
36
    }
37
38
    /**
39
     * @covers \OAuth\OAuth2\Service\Xing::__construct
40
     */
41
    public function testConstructCorrectInstanceWithCustomUri(): void
42
    {
43
        $service = new Xing(
44
            $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...
45
            $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...
46
            $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...
47
            [],
48
            $this->createMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
49
        );
50
51
        self::assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service);
52
    }
53
54
    /**
55
     * @covers \OAuth\OAuth2\Service\Xing::__construct
56
     * @covers \OAuth\OAuth2\Service\Xing::getAuthorizationEndpoint
57
     */
58
    public function testGetAuthorizationEndpoint(): void
59
    {
60
        $service = new Xing(
61
            $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...
62
            $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...
63
            $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...
64
        );
65
66
        self::assertSame('https://api.xing.com/auth/oauth2/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri());
67
    }
68
69
    /**
70
     * @covers \OAuth\OAuth2\Service\Xing::__construct
71
     * @covers \OAuth\OAuth2\Service\Xing::getAccessTokenEndpoint
72
     */
73
    public function testGetAccessTokenEndpoint(): void
74
    {
75
        $service = new Xing(
76
            $this->createMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...\CredentialsInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Cons...r\CredentialsInterface>.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
77
            $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...ient\\ClientInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Http\Client\ClientInterface>.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
78
            $this->createMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')
0 ignored issues
show
Documentation introduced by
$this->createMock('\\OAu...TokenStorageInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<OAuth\Common\Stor...\TokenStorageInterface>.

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

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

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

function acceptsInteger($int) { }

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

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
79
        );
80
81
        self::assertSame('https://api.xing.com/auth/oauth2/token', $service->getAccessTokenEndpoint()->getAbsoluteUri());
82
    }
83
84
    /**
85
     * @covers \OAuth\OAuth2\Service\Xing::__construct
86
     * @covers \OAuth\OAuth2\Service\Xing::parseAccessTokenResponse
87
     */
88
    public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse(): void
89
    {
90
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
91
        $client->expects(self::once())->method('retrieveResponse')->willReturn(null);
92
93
        $service = new Xing(
94
            $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...
95
            $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...
96
            $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...
97
        );
98
99
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
100
101
        $service->requestAccessToken('foo');
102
    }
103
104
    /**
105
     * @covers \OAuth\OAuth2\Service\Xing::__construct
106
     * @covers \OAuth\OAuth2\Service\Xing::parseAccessTokenResponse
107
     */
108
    public function testParseAccessTokenResponseThrowsExceptionOnError(): void
109
    {
110
        $error = [
111
            'error' => 'some_error',
112
            'error_description' => 'something went very wrong',
113
            'error_uri' => 'this imaginary link contains more information',
114
        ];
115
116
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
117
        $client->expects(self::once())->method('retrieveResponse')->willReturn(json_encode($error));
118
119
        $service = new Xing(
120
            $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...
121
            $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...
122
            $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...
123
        );
124
125
        $this->expectException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException');
126
127
        $service->requestAccessToken('foo');
128
    }
129
130
    /**
131
     * @covers \OAuth\OAuth2\Service\Xing::__construct
132
     * @covers \OAuth\OAuth2\Service\Xing::parseAccessTokenResponse
133
     */
134
    public function testParseAccessTokenResponseValidWithRefreshToken(): void
135
    {
136
        $client = $this->createMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
137
        $client->expects(self::once())->method('retrieveResponse')->willReturn('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}');
138
139
        $service = new Xing(
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
            $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...
143
        );
144
145
        self::assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo'));
146
    }
147
}
148