Completed
Pull Request — master (#37)
by Vitaliy
06:49 queued 04:18
created

WalletTest::testAddVirtualItemToWalletUser()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 39
rs 8.8571
cc 1
eloc 26
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 View Code Duplication
    public function testListWalletUsers()
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...
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
        $virtualItem = static::$xsollaClient->CreateVirtualItem(array(
76
            'project_id' => static::$projectId,
77
            'request' => array(
78
                'sku' => static::$virtualItemSku,
79
                'name' => array(
80
                    'en' => 'Virtual Item',
81
                ),
82
                'description' => array(
83
                    'en' => 'Virtual Item Description',
84
                ),
85
                'prices' => array(
86
                    'USD' => 1,
87
                ),
88
                'default_currency' => 'USD',
89
                'enabled' => true,
90
                'disposable' => false,
91
                'item_type' => 'Consumable',
92
            ),
93
        ));
94
        static::$virtualItemId = $virtualItem['item_id'];
95
96
        static::$xsollaClient->AddVirtualItemToWalletUser(array(
97
            'project_id' => static::$projectId,
98
            'user_id' => static::$userId,
99
            'request' => array(
100
                'virtual_items' => array(
101
                    array(
102
                        'virtual_item' => array(
103
                            'sku' => static::$virtualItemSku,
104
                        ),
105
                        'amount' => 2,
106
                    ),
107
                ),
108
            ),
109
        ));
110
    }
111
112
    /**
113
     * @depends testAddVirtualItemToWalletUser
114
     */
115 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...
116
    {
117
        $response = static::$xsollaClient->ListWalletUserVirtualItems(array(
118
            'project_id' => static::$projectId,
119
            'user_id' => static::$userId,
120
            'limit' => 1,
121
            'offset' => 0,
122
        ));
123
        static::assertInternalType('array', $response);
124
    }
125
126
    /**
127
     * @depends testAddVirtualItemToWalletUser
128
     */
129
    public function testDeleteVirtualItemFromWalletUser()
130
    {
131
        static::$xsollaClient->DeleteVirtualItemFromWalletUser(array(
132
            'project_id' => static::$projectId,
133
            'user_id' => static::$userId,
134
            'request' => array(
135
                'virtual_items' => array(
136
                    array(
137
                        'virtual_item' => array(
138
                            'sku' => static::$virtualItemSku,
139
                        ),
140
                        'amount' => 2,
141
                    ),
142
                ),
143
            ),
144
        ));
145
        static::$xsollaClient->DeleteVirtualItem(array(
146
            'project_id' => static::$projectId,
147
            'item_id' => static::$virtualItemId,
148
        ));
149
    }
150
}
151