Completed
Push — master ( 313249...11f8f0 )
by
unknown
12s
created

WalletTest   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 152
Duplicated Lines 46.05 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
c 1
b 0
f 0
lcom 1
cbo 2
dl 70
loc 152
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreateWalletUser() 0 4 1
A testGetWalletUser() 8 8 1
A testUpdateWalletUser() 0 10 1
A testListWalletUsers() 9 9 1
A testListWalletUserOperations() 10 10 1
A testRechargeWalletUserBalance() 12 12 1
B testAddVirtualItemToWalletUser() 0 25 1
A testListWalletUserVirtualItems() 10 10 1
A testDeleteVirtualItemFromWalletUser() 0 21 1
A testListWalletUserOperationsWithParams() 11 11 1
A testListWalletUsersWithParams() 10 10 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 testListWalletUsersWithParams()
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->ListWalletUsers(array(
51
            'project_id' => static::$projectId,
52
            'limit' => 1,
53
            'offset' => 0,
54
            'user_requisites' => static::$userId,
55
        ));
56
        static::assertInternalType('array', $response);
57
    }
58
59 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...
60
    {
61
        $response = static::$xsollaClient->ListWalletUserOperations(array(
62
            'project_id' => static::$projectId,
63
            'user_id' => static::$userId,
64
            'datetime_from' => '2015-01-01T00:00:00Z',
65
            'datetime_to' => '2016-01-01T00:00:00Z',
66
        ));
67
        static::assertInternalType('array', $response);
68
    }
69
70 View Code Duplication
    public function testListWalletUserOperationsWithParams()
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...
71
    {
72
        $response = static::$xsollaClient->ListWalletUserOperations(array(
73
            'project_id' => static::$projectId,
74
            'user_id' => static::$userId,
75
            'datetime_from' => '2015-01-01T00:00:00Z',
76
            'datetime_to' => '2016-01-01T00:00:00Z',
77
            'transaction_type' => 'payment',
78
        ));
79
        static::assertInternalType('array', $response);
80
    }
81
82 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...
83
    {
84
        $response = static::$xsollaClient->RechargeWalletUserBalance(array(
85
            'project_id' => static::$projectId,
86
            'user_id' => static::$userId,
87
            'request' => array(
88
                'amount' => 10,
89
                'comment' => 'Comment',
90
            ),
91
        ));
92
        static::assertArrayHasKey('amount', $response);
93
    }
94
95
    public function testAddVirtualItemToWalletUser()
96
    {
97
        static::$virtualItemSku = uniqid('virtual_item_', false);
98
        $virtualItemTemplate = $this->generateVirtualItemTemplate(static::$virtualItemSku);
99
        $virtualItem = static::$xsollaClient->CreateVirtualItem(array(
100
            'project_id' => static::$projectId,
101
            'request' => $virtualItemTemplate,
102
        ));
103
        static::$virtualItemId = $virtualItem['item_id'];
104
105
        static::$xsollaClient->AddVirtualItemToWalletUser(array(
106
            'project_id' => static::$projectId,
107
            'user_id' => static::$userId,
108
            'request' => array(
109
                'virtual_items' => array(
110
                    array(
111
                        'virtual_item' => array(
112
                            'sku' => static::$virtualItemSku,
113
                        ),
114
                        'amount' => 2,
115
                    ),
116
                ),
117
            ),
118
        ));
119
    }
120
121
    /**
122
     * @depends testAddVirtualItemToWalletUser
123
     */
124 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...
125
    {
126
        $response = static::$xsollaClient->ListWalletUserVirtualItems(array(
127
            'project_id' => static::$projectId,
128
            'user_id' => static::$userId,
129
            'limit' => 1,
130
            'offset' => 0,
131
        ));
132
        static::assertInternalType('array', $response);
133
    }
134
135
    /**
136
     * @depends testAddVirtualItemToWalletUser
137
     */
138
    public function testDeleteVirtualItemFromWalletUser()
139
    {
140
        static::$xsollaClient->DeleteVirtualItemFromWalletUser(array(
141
            'project_id' => static::$projectId,
142
            'user_id' => static::$userId,
143
            'request' => array(
144
                'virtual_items' => array(
145
                    array(
146
                        'virtual_item' => array(
147
                            'sku' => static::$virtualItemSku,
148
                        ),
149
                        'amount' => 2,
150
                    ),
151
                ),
152
            ),
153
        ));
154
        static::$xsollaClient->DeleteVirtualItem(array(
155
            'project_id' => static::$projectId,
156
            'item_id' => static::$virtualItemId,
157
        ));
158
    }
159
}
160