Completed
Push — game_delivery ( 066dca )
by Vitaliy
07:23
created

GameDeliveryTest::testGetGameDeliveryEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6667
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace Xsolla\SDK\Tests\Integration\API;
4
5
/**
6
 * @group api
7
 */
8
class GameDeliveryTest extends AbstractAPITest
9
{
10
    private static $gameDeliveryEntityId;
11
12
    private static $gameDeliveryEntitySku;
13
14
    private $gameDeliveryEntityTemplate;
15
16
    public function setUp()
17
    {
18
        parent::setUp();
19
        $this->gameDeliveryEntityTemplate = array(
20
            'sku' => uniqid('sdk-test', true),
21
            'name' => array(
22
                'en' => 'sdk-test name-en',
23
            ),
24
            'description' => array(
25
                'en' => 'sdk-test description-en',
26
            ),
27
            'system_requirements' => 'sdk-test system_requirements',
28
            'default_currency' => 'USD',
29
            'drm' => array(
30
                array(
31
                    'id' => 1,
32
                    'platforms' => array(
33
                        array(
34
                            'id' => 1,
35
                        ),
36
                    ),
37
                ),
38
            ),
39
        );
40
    }
41
42
    public function testListGameDeliveryDrmPlatforms()
43
    {
44
        $response = $this->xsollaClient->ListGameDeliveryDrmPlatforms();
45
        static::assertArrayHasKey('platforms', $response);
46
        static::assertArrayHasKey('drm', $response);
47
    }
48
49 View Code Duplication
    public function testCreateGameDeliveryEntity()
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 = $this->xsollaClient->CreateGameDeliveryEntity(array(
52
            'project_id' => $this->projectId,
53
            'request' => $this->gameDeliveryEntityTemplate,
54
        ));
55
        static::assertArrayHasKey('id', $response);
56
        static::$gameDeliveryEntityId = $response['id'];
0 ignored issues
show
Bug introduced by
Since $gameDeliveryEntityId is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $gameDeliveryEntityId to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
57
        static::$gameDeliveryEntitySku = $this->gameDeliveryEntityTemplate['sku'];
0 ignored issues
show
Bug introduced by
Since $gameDeliveryEntitySku is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $gameDeliveryEntitySku to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
58
    }
59
60
    /**
61
     * @depends testCreateGameDeliveryEntity
62
     */
63
    public function testListGameDeliveryEntities()
64
    {
65
        $response = $this->xsollaClient->ListGameDeliveryEntities(array(
66
            'project_id' => $this->projectId,
67
        ));
68
        static::assertInternalType('array', $response);
69
        static::assertArrayHasKey('id', current($response));
70
    }
71
72
    /**
73
     * @depends testCreateGameDeliveryEntity
74
     */
75
    public function testGetGameDeliveryEntity()
76
    {
77
        $response = $this->xsollaClient->GetGameDeliveryEntity(array(
78
            'project_id' => $this->projectId,
79
            'game_delivery_id' => self::$gameDeliveryEntityId,
80
        ));
81
        static::assertSame(self::$gameDeliveryEntityId, $response['id']);
82
        static::assertSame(self::$gameDeliveryEntitySku, $response['sku']);
83
    }
84
85
    /**
86
     * @depends testCreateGameDeliveryEntity
87
     */
88
    public function testUpdateGameDeliveryEntity()
89
    {
90
        $this->xsollaClient->UpdateGameDeliveryEntity(array(
91
            'project_id' => $this->projectId,
92
            'game_delivery_id' => self::$gameDeliveryEntityId,
93
            'request' => $this->gameDeliveryEntityTemplate,
94
        ));
95
    }
96
}
97