testListWalletUserOperationsWithParams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
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([
21
            'project_id' => static::$projectId,
22
            'user_id' => static::$userId,
23
        ]);
24
        static::assertInternalType('array', $response);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

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...
25
    }
26
27 View Code Duplication
    public function testUpdateWalletUser()
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...
28
    {
29
        static::$xsollaClient->UpdateWalletUser([
30
            'project_id' => static::$projectId,
31
            'user_id' => static::$userId,
32
            'request' => [
33
                'enabled' => true,
34
            ],
35
        ]);
36
        static::assertTrue(true);
37
    }
38
39 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...
40
    {
41
        $response = static::$xsollaClient->ListWalletUsers([
42
            'project_id' => static::$projectId,
43
            'limit' => 1,
44
            'offset' => 0,
45
        ]);
46
        static::assertInternalType('array', $response);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

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...
47
    }
48
49 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...
50
    {
51
        $response = static::$xsollaClient->ListWalletUsers([
52
            'project_id' => static::$projectId,
53
            'limit' => 1,
54
            'offset' => 0,
55
            'user_requisites' => static::$userId,
56
        ]);
57
        static::assertInternalType('array', $response);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

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...
58
    }
59
60 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...
61
    {
62
        $response = static::$xsollaClient->ListWalletUserOperations([
63
            'project_id' => static::$projectId,
64
            'user_id' => static::$userId,
65
            'datetime_from' => '2015-01-01T00:00:00Z',
66
            'datetime_to' => '2016-01-01T00:00:00Z',
67
        ]);
68
        static::assertInternalType('array', $response);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

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...
69
    }
70
71 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...
72
    {
73
        $response = static::$xsollaClient->ListWalletUserOperations([
74
            'project_id' => static::$projectId,
75
            'user_id' => static::$userId,
76
            'datetime_from' => '2015-01-01T00:00:00Z',
77
            'datetime_to' => '2016-01-01T00:00:00Z',
78
            'transaction_type' => 'payment',
79
        ]);
80
        static::assertInternalType('array', $response);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

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...
81
    }
82
83
    public function testRechargeWalletUserBalance()
84
    {
85
        $response = static::$xsollaClient->RechargeWalletUserBalance([
86
            'project_id' => static::$projectId,
87
            'user_id' => static::$userId,
88
            'request' => [
89
                'amount' => 10,
90
                'comment' => 'Comment',
91
            ],
92
        ]);
93
        static::assertArrayHasKey('amount', $response);
94
    }
95
96
    public function testAddVirtualItemToWalletUser()
97
    {
98
        static::$virtualItemSku = uniqid('virtual_item_', false);
99
        $virtualItemTemplate = $this->generateVirtualItemTemplate(static::$virtualItemSku);
100
        $virtualItem = static::$xsollaClient->CreateVirtualItem([
101
            'project_id' => static::$projectId,
102
            'request' => $virtualItemTemplate,
103
        ]);
104
        static::$virtualItemId = $virtualItem['item_id'];
105
106
        static::$xsollaClient->AddVirtualItemToWalletUser([
107
            'project_id' => static::$projectId,
108
            'user_id' => static::$userId,
109
            'request' => [
110
                'virtual_items' => [
111
                    [
112
                        'virtual_item' => [
113
                            'sku' => static::$virtualItemSku,
114
                        ],
115
                        'amount' => 2,
116
                    ],
117
                ],
118
            ],
119
        ]);
120
        static::assertTrue(true);
121
    }
122
123
    /**
124
     * @depends testAddVirtualItemToWalletUser
125
     */
126 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...
127
    {
128
        $response = static::$xsollaClient->ListWalletUserVirtualItems([
129
            'project_id' => static::$projectId,
130
            'user_id' => static::$userId,
131
            'limit' => 1,
132
            'offset' => 0,
133
        ]);
134
        static::assertInternalType('array', $response);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369

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...
135
    }
136
137
    /**
138
     * @depends testAddVirtualItemToWalletUser
139
     */
140
    public function testDeleteVirtualItemFromWalletUser()
141
    {
142
        static::$xsollaClient->DeleteVirtualItemFromWalletUser([
143
            'project_id' => static::$projectId,
144
            'user_id' => static::$userId,
145
            'request' => [
146
                'virtual_items' => [
147
                    [
148
                        'virtual_item' => [
149
                            'sku' => static::$virtualItemSku,
150
                        ],
151
                        'amount' => 2,
152
                    ],
153
                ],
154
            ],
155
        ]);
156
        static::$xsollaClient->DeleteVirtualItem([
157
            'project_id' => static::$projectId,
158
            'item_id' => static::$virtualItemId,
159
        ]);
160
        static::assertTrue(true);
161
    }
162
}
163