|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
require_once('BaseTester.php'); |
|
4
|
|
|
|
|
5
|
|
|
/** @group UserStats */ |
|
6
|
|
|
class UserStatsTest extends BaseTester { |
|
|
|
|
|
|
7
|
|
|
|
|
8
|
|
|
/** @test */ |
|
9
|
|
|
public function it_returns_null_when_there_are_no_achievements_for_a_game() |
|
10
|
|
|
{ |
|
11
|
|
|
$achievements = $this->steamClient->userStats($this->id64)->GetPlayerAchievements(359320); |
|
12
|
|
|
|
|
13
|
|
|
$this->assertNull($achievements); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
/** @test */ |
|
17
|
|
|
public function it_gets_the_users_achievements_for_a_game() |
|
18
|
|
|
{ |
|
19
|
|
|
$achievements = $this->steamClient->userStats($this->id64)->GetPlayerAchievements(252950); |
|
20
|
|
|
|
|
21
|
|
|
$this->assertInstanceOf('Syntax\SteamApi\Containers\Achievement', $achievements[0]); |
|
22
|
|
|
$this->checkAchievementProperties($achievements[0]); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** @test */ |
|
26
|
|
|
public function it_gets_the_global_achievement_percentage_for_a_game() |
|
27
|
|
|
{ |
|
28
|
|
|
$achievements = $this->steamClient->userStats($this->id64)->GetGlobalAchievementPercentagesForApp($this->appId); |
|
29
|
|
|
|
|
30
|
|
|
$this->assertGreaterThan(0, $achievements); |
|
31
|
|
|
|
|
32
|
|
|
$attributes = ['name', 'percent']; |
|
33
|
|
|
$this->assertObjectHasAttributes($attributes, $achievements[0]); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** @test */ |
|
37
|
|
|
public function it_gets_the_user_stats_for_a_game() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->expectException(Syntax\SteamApi\Exceptions\ApiCallFailedException::class); |
|
40
|
|
|
|
|
41
|
|
|
$stats = $this->steamClient->userStats(76561198159417876)->GetUserStatsForGame(730); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
// $this->assertTrue(is_array($stats)); |
|
44
|
|
|
|
|
45
|
|
|
// $attributes = ['name', 'achieved']; |
|
46
|
|
|
// $this->assertObjectHasAttributes($attributes, $stats[0]); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** @test */ |
|
50
|
|
|
public function it_gets_all_the_user_stats_for_a_game() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->expectException(Syntax\SteamApi\Exceptions\ApiCallFailedException::class); |
|
53
|
|
|
|
|
54
|
|
|
$stats = $this->steamClient->userStats(76561198159417876)->GetUserStatsForGame(730, true); |
|
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
// $this->assertTrue(is_object($stats)); |
|
57
|
|
|
|
|
58
|
|
|
// $attributes = ['name', 'achieved']; |
|
59
|
|
|
// $this->assertObjectHasAttributes($attributes, $stats->achievements[0]); |
|
60
|
|
|
|
|
61
|
|
|
// $attributes = ['name', 'value']; |
|
62
|
|
|
// $this->assertObjectHasAttributes($attributes, $stats->stats[0]); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** @test */ |
|
66
|
|
|
public function it_gets_all_the_stats_for_a_game() |
|
67
|
|
|
{ |
|
68
|
|
|
$stats = $this->steamClient->userStats(76561198159417876)->GetSchemaForGame(730, true); |
|
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
$this->assertTrue(is_object($stats)); |
|
71
|
|
|
|
|
72
|
|
|
$attributes = ['gameName', 'gameVersion', 'availableGameStats']; |
|
73
|
|
|
$this->assertObjectHasAttributes($attributes, $stats->game); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|