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
|
|
|
new UserResponse((new User())->setId(new \stdClass())); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function testUserIdIsEmptyString() |
23
|
|
|
{ |
24
|
|
|
$this->setExpectedException( |
|
|
|
|
25
|
|
|
'\Xsolla\SDK\Exception\Webhook\XsollaWebhookException', |
26
|
|
|
'User id should be non-empty string. Empty string given' |
27
|
|
|
); |
28
|
|
|
new UserResponse((new User())->setId('')); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testUserIdIsNull() |
32
|
|
|
{ |
33
|
|
|
$this->setExpectedException( |
|
|
|
|
34
|
|
|
'\Xsolla\SDK\Exception\Webhook\XsollaWebhookException', |
35
|
|
|
'User id should be non-empty string. NULL given' |
36
|
|
|
); |
37
|
|
|
new UserResponse(new User()); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testShortResponseFormat() |
41
|
|
|
{ |
42
|
|
|
$response = new UserResponse((new User())->setId('user_id')); |
43
|
|
|
$this->assertJsonStringEqualsJsonString( |
44
|
|
|
'{"user":{"id":"user_id"}}', |
45
|
|
|
$response->getSymfonyResponse()->getContent() |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testFullResponseFormat() |
50
|
|
|
{ |
51
|
|
|
$response = new UserResponse( |
52
|
|
|
(new User()) |
53
|
|
|
->setId('user_id') |
54
|
|
|
->setEmail('user_email') |
55
|
|
|
->setPhone('user_phone') |
56
|
|
|
->setName('user_name') |
57
|
|
|
->setPublicId('user_public_id') |
58
|
|
|
); |
59
|
|
|
$this->assertJsonStringEqualsJsonString( |
60
|
|
|
'{"user":{"id":"user_id","email":"user_email","phone":"user_phone","name":"user_name","public_id":"user_public_id"}}', |
61
|
|
|
$response->getSymfonyResponse()->getContent() |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
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.