Skip to content

Commit f8cd104

Browse files
committed
Minor fixes. Added user stats tests
1 parent 7b8ae24 commit f8cd104

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ Name | Type | Description | Required | Default
247247
appId| int | The id of the game you want the user's achievements in | Yes |
248248

249249

250-
> Example Output: [GetGlobalAchievementPercentagesForApp](./examples/user/stats/GetGlobalAchievementPercentagesForApp.txt)
250+
> Example Output: [GetGlobalAchievementPercentagesForApp](./examples/user/stats/GetGlobalAchievementPercentageForApp.txt)
251251
252252
#### GetUserStatsForGame
253253
Returns a list of achievements for this user by app id.

tests/BaseTester.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ protected function checkPlayerProperties($friendsList)
7272
$this->checkSteamIdsProperties($friendsList[0]->steamIds);
7373
}
7474

75+
protected function checkAchievementProperties($achievement)
76+
{
77+
$attributes = [
78+
'apiName', 'achieved', 'name', 'description'
79+
];
80+
$this->assertObjectHasAttributes($attributes, $achievement);
81+
}
82+
7583
protected function checkAppProperties($app)
7684
{
7785
$this->checkMainAppProperties($app);

tests/PlayerTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ public function it_gets_the_badges_by_user_id()
3737
$this->assertObjectHasAttributes($attributes, $badges->badges[0]);
3838
}
3939

40+
/** @test */
41+
public function it_gets_the_badge_progress_by_user_id()
42+
{
43+
$progress = $this->steamClient->player($this->id64)->GetCommunityBadgeProgress();
44+
45+
$this->assertObjectHasAttribute('quests', $progress);
46+
47+
$attributes = ['questid', 'completed'];
48+
$this->assertObjectHasAttributes($attributes, $progress->quests[0]);
49+
}
50+
4051
/** @test */
4152
public function it_gets_the_owned_games_by_user_id()
4253
{

tests/UserStatsTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/** @group UserStats */
4+
class UserStatsTest extends BaseTester {
5+
6+
/** @test */
7+
public function it_gets_the_users_achievements_for_a_game()
8+
{
9+
$achievements = $this->steamClient->userStats($this->id64)->GetPlayerAchievements($this->appId);
10+
11+
$this->assertInstanceOf('Syntax\SteamApi\Containers\Achievement', $achievements[0]);
12+
$this->checkAchievementProperties($achievements[0]);
13+
}
14+
15+
/** @test */
16+
public function it_gets_the_global_achievement_percentage_for_a_game()
17+
{
18+
$achievements = $this->steamClient->userStats($this->id64)->GetGlobalAchievementPercentagesForApp($this->appId);
19+
20+
$this->assertGreaterThan(0, $achievements);
21+
22+
$attributes = ['name', 'percent'];
23+
$this->assertObjectHasAttributes($attributes, $achievements[0]);
24+
}
25+
26+
/** @test */
27+
public function it_gets_the_user_stats_for_a_game()
28+
{
29+
$stats = $this->steamClient->userStats($this->id64)->GetUserStatsForGame($this->appId);
30+
31+
$this->assertTrue(is_array($stats));
32+
33+
$attributes = ['name', 'achieved'];
34+
$this->assertObjectHasAttributes($attributes, $stats[0]);
35+
}
36+
37+
}

0 commit comments

Comments
 (0)