Completed
Push — master ( 8bc6ad...b2c48e )
by Vitaliy
16:26 queued 13:19
created

WalletTest::testAddVirtualItemToWalletUser()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
namespace Xsolla\SDK\Tests\Integration\API;
4
5
/**
6
 * @group api
7
 */
8
class WalletTest extends AbstractAPITest
9
{
10
    protected static $virtualItemId;
11
    protected static $virtualItemSku;
12
13
    public function testCreateWalletUser()
14
    {
15
        static::markTestIncomplete('Delete user API method not implemented yet. We should not create new users infinitely.');
16
    }
17
18 View Code Duplication
    public function testGetWalletUser()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
    {
20
        $response = static::$xsollaClient->GetWalletUser(array(
21
            'project_id' => static::$projectId,
22
            'user_id' => static::$userId,
23
        ));
24
        static::assertInternalType('array', $response);
25
    }
26
27
    public function testUpdateWalletUser()
28
    {
29
        static::$xsollaClient->UpdateWalletUser(array(
30
            'project_id' => static::$projectId,
31
            'user_id' => static::$userId,
32
            'request' => array(
33
                'enabled' => true,
34
            ),
35
        ));
36
    }
37
38
    public function testListWalletUsers()
39
    {
40
        $response = static::$xsollaClient->ListWalletUsers(array(
41
            'project_id' => static::$projectId,
42
            'limit' => 1,
43
            'offset' => 0,
44
        ));
45
        static::assertInternalType('array', $response);
46
    }
47
48 View Code Duplication
    public function testListWalletUserOperations()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
    {
50
        $response = static::$xsollaClient->ListWalletUserOperations(array(
51
            'project_id' => static::$projectId,
52
            'user_id' => static::$userId,
53
            'datetime_from' => '2015-01-01T00:00:00 UTC',
54
            'datetime_to' => '2016-01-01T00:00:00 UTC',
55
        ));
56
        static::assertInternalType('array', $response);
57
    }
58
59 View Code Duplication
    public function testRechargeWalletUserBalance()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
60
    {
61
        $response = static::$xsollaClient->RechargeWalletUserBalance(array(
62
            'project_id' => static::$projectId,
63
            'user_id' => static::$userId,
64
            'request' => array(
65
                'amount' => 10,
66
                'comment' => 'Comment',
67
            ),
68
        ));
69
        static::assertArrayHasKey('amount', $response);
70
    }
71
72
    public function testAddVirtualItemToWalletUser()
73
    {
74
        static::$virtualItemSku = uniqid('virtual_item_', false);
75
        $virtualItemTemplate = $this->generateVirtualItemTemplate(static::$virtualItemSku);
76
        $virtualItem = static::$xsollaClient->CreateVirtualItem(array(
77
            'project_id' => static::$projectId,
78
            'request' => $virtualItemTemplate,
79
        ));
80
        static::$virtualItemId = $virtualItem['item_id'];
81
82
        static::$xsollaClient->AddVirtualItemToWalletUser(array(
83
            'project_id' => static::$projectId,
84
            'user_id' => static::$userId,
85
            'request' => array(
86
                'virtual_items' => array(
87
                    array(
88
                        'virtual_item' => array(
89
                            'sku' => static::$virtualItemSku,
90
                        ),
91
                        'amount' => 2,
92
                    ),
93
                ),
94
            ),
95
        ));
96
    }
97
98
    /**
99
     * @depends testAddVirtualItemToWalletUser
100
     */
101 View Code Duplication
    public function testListWalletUserVirtualItems()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
102
    {
103
        $response = static::$xsollaClient->ListWalletUserVirtualItems(array(
104
            'project_id' => static::$projectId,
105
            'user_id' => static::$userId,
106
            'limit' => 1,
107
            'offset' => 0,
108
        ));
109
        static::assertInternalType('array', $response);
110
    }
111
112
    /**
113
     * @depends testAddVirtualItemToWalletUser
114
     */
115
    public function testDeleteVirtualItemFromWalletUser()
116
    {
117
        static::$xsollaClient->DeleteVirtualItemFromWalletUser(array(
118
            'project_id' => static::$projectId,
119
            'user_id' => static::$userId,
120
            'request' => array(
121
                'virtual_items' => array(
122
                    array(
123
                        'virtual_item' => array(
124
                            'sku' => static::$virtualItemSku,
125
                        ),
126
                        'amount' => 2,
127
                    ),
128
                ),
129
            ),
130
        ));
131
        static::$xsollaClient->DeleteVirtualItem(array(
132
            'project_id' => static::$projectId,
133
            'item_id' => static::$virtualItemId,
134
        ));
135
    }
136
}
137