UserStatsTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 0
loc 71
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A it_returns_null_when_there_are_no_achievements_for_a_game() 0 6 1
A it_gets_the_users_achievements_for_a_game() 0 7 1
A it_gets_the_global_achievement_percentage_for_a_game() 0 9 1
A it_gets_the_user_stats_for_a_game() 0 11 1
A it_gets_all_the_user_stats_for_a_game() 0 14 1
A it_gets_all_the_stats_for_a_game() 0 9 1
1
<?php
2
3
require_once('BaseTester.php');
4
5
/** @group UserStats */
6
class UserStatsTest extends BaseTester {
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: artisan, be, call, seed
Loading history...
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);
0 ignored issues
show
Unused Code introduced by
$stats is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
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);
0 ignored issues
show
Unused Code introduced by
$stats is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
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);
0 ignored issues
show
Unused Code introduced by
The call to Stats::GetSchemaForGame() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
69
70
        $this->assertTrue(is_object($stats));
71
72
        $attributes = ['gameName', 'gameVersion', 'availableGameStats'];
73
        $this->assertObjectHasAttributes($attributes, $stats->game);
74
    }
75
76
}
77