Completed
Push — master ( 66631d...a00063 )
by
unknown
9s
created

UserSearchResponseTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 1
cbo 4
dl 0
loc 57
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testUserIdHasInvalidType() 0 9 1
A testUserIdIsEmptyString() 0 9 1
A testUserIdIsNull() 0 8 1
A testShortResponseFormat() 0 9 1
A testFullResponseFormat() 0 15 1
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(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

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.

Loading history...
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(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

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.

Loading history...
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(
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

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.

Loading history...
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