Completed
Push — Laravel4 ( 02d48b...8c5149 )
by Travis
03:47 queued 03:02
created

PlayerTest   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 136
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 10
c 3
b 1
f 2
lcom 1
cbo 2
dl 0
loc 136
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A it_gets_the_steam_level_by_user_id() 0 6 1
A it_gets_the_player_details_by_user_id() 0 12 1
A it_gets_the_badges_by_user_id() 0 10 1
A it_gets_the_owned_games_by_user_id() 0 13 1
A it_gets_the_owned_games_by_user_id_without_app_details() 0 17 1
A it_filters_the_owned_games_by_user_id() 0 14 1
A it_gets_recently_played_games_by_user_id() 0 13 1
A it_gets_a_single_recently_played_game_by_user_id() 0 14 1
A it_checks_if_playing_a_shared_game_by_user_and_app_id() 0 6 1
A it_gets_the_badge_progress_by_user_id() 0 9 1
1
<?php
2
3
/** @group Player */
4
class PlayerTest extends BaseTester {
5
6
    /** @test */
7
    public function it_gets_the_steam_level_by_user_id()
8
    {
9
        $steamLevel = $this->steamClient->player($this->id64)->GetSteamLevel();
10
11
        $this->assertInternalType('int', $steamLevel);
12
    }
13
14
    /** @test */
15
    public function it_gets_the_player_details_by_user_id()
16
    {
17
        $details = $this->steamClient->player($this->id64)->GetPlayerLevelDetails();
18
19
        $this->assertInstanceOf('Syntax\SteamApi\Containers\Player\Level', $details);
20
21
        $attributes = [
22
            'playerXp', 'playerLevel', 'xpToLevelUp', 'xpForCurrentLevel', 'currentLevelFloor',
23
            'currentLevelCeiling', 'percentThroughLevel'
24
        ];
25
        $this->assertObjectHasAttributes($attributes, $details);
26
    }
27
28
    /** @test */
29
    public function it_gets_the_badges_by_user_id()
30
    {
31
        $badges = $this->steamClient->player($this->id64)->GetBadges();
32
33
        $attributes = ['badges', 'player_xp', 'player_level', 'player_xp_needed_to_level_up', 'player_xp_needed_current_level'];
34
        $this->assertObjectHasAttributes($attributes, $badges);
35
36
        $attributes = ['badgeid', 'level', 'completion_time', 'xp', 'scarcity'];
37
        $this->assertObjectHasAttributes($attributes, $badges->badges[0]);
38
    }
39
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
51
    /** @test */
52
    public function it_gets_the_owned_games_by_user_id()
53
    {
54
        $games = $this->steamClient->player($this->id64)->GetOwnedGames();
55
56
        $this->assertInstanceOf('Syntax\SteamApi\Collection', $games);
57
        $this->assertInstanceOf('Syntax\SteamApi\Containers\Game', $games->first());
58
59
        $attributes = [
60
            'appId', 'name', 'playtimeTwoWeeks', 'playtimeForever', 'playtimeForeverReadable',
61
            'icon', 'logo', 'header', 'hasCommunityVisibleStats'
62
        ];
63
        $this->assertObjectHasAttributes($attributes, $games->first());
64
    }
65
66
    /** @test */
67
    public function it_gets_the_owned_games_by_user_id_without_app_details()
68
    {
69
        $games = $this->steamClient->player($this->id64)->GetOwnedGames(false);
70
71
        $this->assertInstanceOf('Syntax\SteamApi\Collection', $games);
72
        $this->assertInstanceOf('Syntax\SteamApi\Containers\Game', $games->first());
73
74
        $attributes = [
75
            'appId', 'name', 'playtimeTwoWeeks', 'playtimeForever', 'playtimeForeverReadable',
76
            'icon', 'logo', 'header', 'hasCommunityVisibleStats'
77
        ];
78
        $this->assertObjectHasAttributes($attributes, $games->first());
79
80
        $this->assertNull($games->first()->name);
81
        $this->assertNull($games->first()->icon);
82
        $this->assertNull($games->first()->logo);
83
    }
84
85
    /** @test */
86
    public function it_filters_the_owned_games_by_user_id()
87
    {
88
        $games = $this->steamClient->player($this->id64)->GetOwnedGames(true, false, $this->appId);
89
90
        $this->assertInstanceOf('Syntax\SteamApi\Collection', $games);
91
        $this->assertInstanceOf('Syntax\SteamApi\Containers\Game', $games->first());
92
        $this->assertEquals(1, $games->count());
93
94
        $attributes = [
95
            'appId', 'name', 'playtimeTwoWeeks', 'playtimeForever', 'playtimeForeverReadable',
96
            'icon', 'logo', 'header', 'hasCommunityVisibleStats'
97
        ];
98
        $this->assertObjectHasAttributes($attributes, $games->first());
99
    }
100
101
    /** @test */
102
    public function it_gets_recently_played_games_by_user_id()
103
    {
104
        $games = $this->steamClient->player($this->id64)->GetRecentlyPlayedGames();
105
106
        $this->assertInstanceOf('Syntax\SteamApi\Collection', $games);
107
        $this->assertInstanceOf('Syntax\SteamApi\Containers\Game', $games->first());
108
109
        $attributes = [
110
            'appId', 'name', 'playtimeTwoWeeks', 'playtimeForever', 'playtimeForeverReadable',
111
            'icon', 'logo', 'header', 'hasCommunityVisibleStats'
112
        ];
113
        $this->assertObjectHasAttributes($attributes, $games->first());
114
    }
115
116
    /** @test */
117
    public function it_gets_a_single_recently_played_game_by_user_id()
118
    {
119
        $games = $this->steamClient->player($this->id64)->GetRecentlyPlayedGames(1);
120
121
        $this->assertInstanceOf('Syntax\SteamApi\Collection', $games);
122
        $this->assertInstanceOf('Syntax\SteamApi\Containers\Game', $games->first());
123
        $this->assertEquals(1, $games->count());
124
125
        $attributes = [
126
            'appId', 'name', 'playtimeTwoWeeks', 'playtimeForever', 'playtimeForeverReadable',
127
            'icon', 'logo', 'header', 'hasCommunityVisibleStats'
128
        ];
129
        $this->assertObjectHasAttributes($attributes, $games->first());
130
    }
131
132
    /** @test */
133
    public function it_checks_if_playing_a_shared_game_by_user_and_app_id()
134
    {
135
        $playingSharedGame = $this->steamClient->player($this->id64)->IsPlayingSharedGame($this->appId);
136
137
        $this->assertNotNull($playingSharedGame);
138
    }
139
}