-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathVkTest.php
More file actions
65 lines (58 loc) · 1.73 KB
/
VkTest.php
File metadata and controls
65 lines (58 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* SocialConnect project
* @author: Patsura Dmitry https://github.com/ovr <talk@dmtry.me>
*/
namespace Test\OAuth2\Provider;
use Psr\Http\Message\ResponseInterface;
use SocialConnect\OAuth2\AccessToken;
class VkTest extends AbstractProviderTestCase
{
/**
* {@inheritdoc}
*/
protected function getProviderClassName()
{
return \SocialConnect\OAuth2\Provider\Vk::class;
}
public function testGetIdentitySuccess()
{
$mockedHttpClient = $this->mockClientResponse(
json_encode(
[
'response' => [
[
'id' => $expectedId = 12321312312312,
'first_name' => $expectedFirstname = 'Dmitry',
'last_name' => $expectedLastname = 'Patsura',
'sex' => 1,
]
]
]
)
);
$result = $this->getProvider($mockedHttpClient)->getIdentity(
new AccessToken(
[
'access_token' => '123456789'
]
)
);
parent::assertInstanceOf(\SocialConnect\Common\Entity\User::class, $result);
parent::assertSame($expectedId, $result->id);
parent::assertSame($expectedFirstname, $result->firstname);
parent::assertSame($expectedLastname, $result->lastname);
parent::assertSame('female', $result->getGender());
}
/**
* {@inheritDoc}
*/
protected function getTestResponseForGetIdentity(): ResponseInterface
{
return $this->createResponse(
json_encode([
'id' => 12345,
])
);
}
}