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
|
|
|
public function testCreateGameDeliveryEntity() |
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']; |
|
|
|
|
57
|
|
|
static::$gameDeliveryEntitySku = $this->gameDeliveryEntityTemplate['sku']; |
|
|
|
|
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
|
|
|
|
Let’s assume you have a class which uses late-static binding:
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:In the case above, it makes sense to update
SomeClass
to useself
instead: