VirtualItemsTest::testGetVirtualItem()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
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 VirtualItemsTest extends AbstractAPITest
9
{
10
    protected static $virtualItemSku;
11
12
    protected static $virtualItemId;
13
14
    protected static $virtualItemsGroupId;
15
16
    protected static $virtualItem;
17
18
    protected $virtualItemsGroup = [
19
        'name' => [
20
            'en' => 'Virtual Item Group',
21
        ],
22
        'description' => [
23
            'en' => 'Virtual Item Group Description',
24
        ],
25
        'enabled' => true,
26
    ];
27
28
    public function setUp()
29
    {
30
        parent::setUp();
31
        if (!static::$virtualItemSku) {
32
            static::$virtualItemSku = uniqid('virtual_item_', false);
33
            static::$virtualItem = $this->generateVirtualItemTemplate(static::$virtualItemSku);
34
        }
35
    }
36
37
    public function testListVirtualItemsGroups()
38
    {
39
        $response = static::$xsollaClient->ListVirtualItemsGroups([
40
            'project_id' => static::$projectId,
41
        ]);
42
        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...
43
    }
44
45
    public function testListVirtualItems()
46
    {
47
        $response = static::$xsollaClient->ListVirtualItems([
48
            'project_id' => static::$projectId,
49
        ]);
50
        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...
51
    }
52
53 View Code Duplication
    public function testListVirtualItemsWithParams()
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...
54
    {
55
        $response = static::$xsollaClient->ListVirtualItems([
56
            'project_id' => static::$projectId,
57
            'offset' => 0,
58
            'limit' => 100,
59
            'has_price' => 'virtual_currency',
60
        ]);
61
        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...
62
    }
63
64 View Code Duplication
    public function testCreateVirtualItemsGroup()
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...
65
    {
66
        $response = static::$xsollaClient->CreateVirtualItemsGroup([
67
            'project_id' => static::$projectId,
68
            'request' => $this->virtualItemsGroup,
69
        ]);
70
        static::assertArrayHasKey('group_id', $response);
71
        static::$virtualItemsGroupId = $response['group_id'];
72
        static::$virtualItem['groups'] = [static::$virtualItemsGroupId];
73
    }
74
75
    /**
76
     * @depends testCreateVirtualItemsGroup
77
     */
78
    public function testGetVirtualItemsGroup()
79
    {
80
        $response = static::$xsollaClient->GetVirtualItemsGroup([
81
            'project_id' => static::$projectId,
82
            'group_id' => static::$virtualItemsGroupId,
83
        ]);
84
        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...
85
    }
86
87
    /**
88
     * @depends testGetVirtualItemsGroup
89
     */
90
    public function testUpdateVirtualItemsGroup()
91
    {
92
        static::$xsollaClient->UpdateVirtualItemsGroup([
93
            'project_id' => static::$projectId,
94
            'group_id' => static::$virtualItemsGroupId,
95
            'request' => $this->virtualItemsGroup,
96
        ]);
97
        static::assertTrue(true);
98
    }
99
100
    /**
101
     * @depends testUpdateVirtualItemsGroup
102
     */
103 View Code Duplication
    public function testCreateVirtualItem()
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...
104
    {
105
        $response = static::$xsollaClient->CreateVirtualItem([
106
            'project_id' => static::$projectId,
107
            'request' => static::$virtualItem,
108
        ]);
109
        static::assertArrayHasKey('item_id', $response);
110
        static::$virtualItemId = $response['item_id'];
111
    }
112
113
    /**
114
     * @depends testCreateVirtualItem
115
     */
116
    public function testGetVirtualItem()
117
    {
118
        $response = static::$xsollaClient->GetVirtualItem([
119
            'project_id' => static::$projectId,
120
            'item_id' => static::$virtualItemId,
121
        ]);
122
        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...
123
    }
124
125
    /**
126
     * @depends testGetVirtualItem
127
     */
128
    public function testUpdateVirtualItem()
129
    {
130
        static::$xsollaClient->UpdateVirtualItem([
131
            'project_id' => static::$projectId,
132
            'item_id' => static::$virtualItemId,
133
            'request' => static::$virtualItem,
134
        ]);
135
        static::assertTrue(true);
136
    }
137
138
    /**
139
     * @depends testUpdateVirtualItemsGroup
140
     */
141 View Code Duplication
    public function testUpdateVirtualItemOrderInGroup()
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...
142
    {
143
        static::$xsollaClient->UpdateVirtualItemOrderInGroup([
144
            'project_id' => static::$projectId,
145
            'request' => [
146
                'group_id' => static::$virtualItemsGroupId,
147
                'virtual_items' => [static::$virtualItemSku],
148
            ],
149
        ]);
150
        static::assertTrue(true);
151
    }
152
153
    /**
154
     * @depends testUpdateVirtualItemOrderInGroup
155
     */
156
    public function testDeleteVirtualItem()
157
    {
158
        static::$xsollaClient->DeleteVirtualItem([
159
            'project_id' => static::$projectId,
160
            'item_id' => static::$virtualItemId,
161
        ]);
162
        static::assertTrue(true);
163
    }
164
165
    /**
166
     * @depends testDeleteVirtualItem
167
     */
168
    public function testDeleteVirtualItemsGroup()
169
    {
170
        static::$xsollaClient->DeleteVirtualItemsGroup([
171
            'project_id' => static::$projectId,
172
            'group_id' => static::$virtualItemsGroupId,
173
        ]);
174
        static::assertTrue(true);
175
    }
176
}
177