1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Xsolla\SDK\Tests\Webhook\Message; |
4
|
|
|
|
5
|
|
|
use Xsolla\SDK\Webhook\Response\UserResponse; |
6
|
|
|
use Xsolla\SDK\Webhook\User; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* @group unit |
10
|
|
|
*/ |
11
|
|
|
class UserSearchResponseTest extends \PHPUnit_Framework_TestCase |
12
|
|
|
{ |
13
|
|
|
public function testUserIdHasInvalidType() |
14
|
|
|
{ |
15
|
|
|
$this->setExpectedException( |
|
|
|
|
16
|
|
|
'\Xsolla\SDK\Exception\Webhook\XsollaWebhookException', |
17
|
|
|
'User id should be non-empty string. stdClass given' |
18
|
|
|
); |
19
|
|
|
$user = new User(); |
20
|
|
|
new UserResponse($user->setId(new \stdClass())); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testUserIdIsEmptyString() |
24
|
|
|
{ |
25
|
|
|
$this->setExpectedException( |
|
|
|
|
26
|
|
|
'\Xsolla\SDK\Exception\Webhook\XsollaWebhookException', |
27
|
|
|
'User id should be non-empty string. Empty string given' |
28
|
|
|
); |
29
|
|
|
$user = new User(); |
30
|
|
|
new UserResponse($user->setId('')); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testUserIdIsNull() |
34
|
|
|
{ |
35
|
|
|
$this->setExpectedException( |
|
|
|
|
36
|
|
|
'\Xsolla\SDK\Exception\Webhook\XsollaWebhookException', |
37
|
|
|
'User id should be non-empty string. NULL given' |
38
|
|
|
); |
39
|
|
|
new UserResponse(new User()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testShortResponseFormat() |
43
|
|
|
{ |
44
|
|
|
$user = new User(); |
45
|
|
|
$response = new UserResponse($user->setId('user_id')); |
46
|
|
|
$this->assertJsonStringEqualsJsonString( |
47
|
|
|
'{"user":{"id":"user_id"}}', |
48
|
|
|
$response->getSymfonyResponse()->getContent() |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testFullResponseFormat() |
53
|
|
|
{ |
54
|
|
|
$user = new User(); |
55
|
|
|
$response = new UserResponse( |
56
|
|
|
$user->setId('user_id') |
57
|
|
|
->setEmail('user_email') |
58
|
|
|
->setPhone('user_phone') |
59
|
|
|
->setName('user_name') |
60
|
|
|
->setPublicId('user_public_id') |
61
|
|
|
); |
62
|
|
|
$this->assertJsonStringEqualsJsonString( |
63
|
|
|
'{"user":{"id":"user_id","email":"user_email","phone":"user_phone","name":"user_name","public_id":"user_public_id"}}', |
64
|
|
|
$response->getSymfonyResponse()->getContent() |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.