1 | <?php |
||
8 | class LinkedinTest extends \PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | /** |
||
11 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
12 | */ |
||
13 | public function testConstructCorrectInterfaceWithoutCustomUri() |
||
14 | { |
||
15 | $service = new Linkedin( |
||
16 | $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), |
||
17 | $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), |
||
18 | $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') |
||
19 | ); |
||
20 | |||
21 | $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
26 | */ |
||
27 | public function testConstructCorrectInstanceWithoutCustomUri() |
||
28 | { |
||
29 | $service = new Linkedin( |
||
30 | $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), |
||
31 | $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), |
||
32 | $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') |
||
33 | ); |
||
34 | |||
35 | $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); |
||
36 | } |
||
37 | |||
38 | /** |
||
39 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
40 | */ |
||
41 | public function testConstructCorrectInstanceWithCustomUri() |
||
42 | { |
||
43 | $service = new Linkedin( |
||
44 | $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), |
||
45 | $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), |
||
46 | $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), |
||
47 | array(), |
||
48 | $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') |
||
49 | ); |
||
50 | |||
51 | $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
56 | * @covers OAuth\OAuth2\Service\Linkedin::getAuthorizationEndpoint |
||
57 | */ |
||
58 | public function testGetAuthorizationEndpoint() |
||
59 | { |
||
60 | $service = new Linkedin( |
||
61 | $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), |
||
62 | $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), |
||
63 | $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') |
||
64 | ); |
||
65 | |||
66 | $this->assertSame( |
||
67 | 'https://www.linkedin.com/uas/oauth2/authorization', |
||
68 | $service->getAuthorizationEndpoint()->getAbsoluteUri() |
||
69 | ); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
74 | * @covers OAuth\OAuth2\Service\Linkedin::getAccessTokenEndpoint |
||
75 | */ |
||
76 | public function testGetAccessTokenEndpoint() |
||
77 | { |
||
78 | $service = new Linkedin( |
||
79 | $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), |
||
80 | $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), |
||
81 | $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') |
||
82 | ); |
||
83 | |||
84 | $this->assertSame( |
||
85 | 'https://www.linkedin.com/uas/oauth2/accessToken', |
||
86 | $service->getAccessTokenEndpoint()->getAbsoluteUri() |
||
87 | ); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
92 | * @covers OAuth\OAuth2\Service\Linkedin::getAuthorizationMethod |
||
93 | */ |
||
94 | public function testGetAuthorizationMethod() |
||
116 | |||
117 | /** |
||
118 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
119 | * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse |
||
120 | */ |
||
121 | public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() |
||
136 | |||
137 | /** |
||
138 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
139 | * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse |
||
140 | */ |
||
141 | public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() |
||
156 | |||
157 | /** |
||
158 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
159 | * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse |
||
160 | */ |
||
161 | public function testParseAccessTokenResponseThrowsExceptionOnError() |
||
176 | |||
177 | /** |
||
178 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
179 | * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse |
||
180 | */ |
||
181 | public function testParseAccessTokenResponseValidWithoutRefreshToken() |
||
194 | |||
195 | /** |
||
196 | * @covers OAuth\OAuth2\Service\Linkedin::__construct |
||
197 | * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse |
||
198 | */ |
||
199 | public function testParseAccessTokenResponseValidWithRefreshToken() |
||
212 | } |
||
213 |