|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Syntax\SteamApi\Exceptions\UnrecognizedId; |
|
4
|
|
|
|
|
5
|
|
|
require_once('BaseTester.php'); |
|
6
|
|
|
|
|
7
|
|
|
/** @group User */ |
|
8
|
|
|
class UserTest extends BaseTester { |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
/** @test */ |
|
11
|
|
|
public function it_accepts_an_array_of_steam_ids() |
|
12
|
|
|
{ |
|
13
|
|
|
$steamIds = [$this->id32, $this->altId64]; |
|
14
|
|
|
|
|
15
|
|
|
$userService = $this->steamClient->user($steamIds); |
|
16
|
|
|
|
|
17
|
|
|
$this->assertCount(2, $userService->getSteamId()); |
|
18
|
|
|
$this->assertEquals($this->id64, $userService->getSteamId()[0]); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @test |
|
23
|
|
|
* @throws UnrecognizedId |
|
24
|
|
|
*/ |
|
25
|
|
View Code Duplication |
public function it_throws_an_exception_when_no_display_name_is_provided() |
|
|
|
|
|
|
26
|
|
|
{ |
|
27
|
|
|
if (method_exists($this, 'setExpectedException')) { |
|
28
|
|
|
$this->setExpectedException('Syntax\SteamApi\Exceptions\UnrecognizedId'); |
|
|
|
|
|
|
29
|
|
|
} else { |
|
30
|
|
|
$this->expectException('Syntax\SteamApi\Exceptions\UnrecognizedId'); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
$steamObject = $this->steamClient->user($this->id64)->ResolveVanityURL(); |
|
34
|
|
|
|
|
35
|
|
|
$this->assertEquals('No match', $steamObject); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** @test |
|
39
|
|
|
* @throws UnrecognizedId |
|
40
|
|
|
*/ |
|
41
|
|
|
public function it_returns_no_match_from_an_invalid_display_name() |
|
42
|
|
|
{ |
|
43
|
|
|
$steamObject = $this->steamClient->user($this->id64)->ResolveVanityURL('stygiansabyssINVALID'); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertEquals('No match', $steamObject); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** @test |
|
49
|
|
|
* @throws UnrecognizedId |
|
50
|
|
|
*/ |
|
51
|
|
|
public function it_gets_the_steam_id_from_a_display_name() |
|
52
|
|
|
{ |
|
53
|
|
|
$steamObject = $this->steamClient->user($this->id64)->ResolveVanityURL('stygiansabyss'); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertEquals($this->id64, $steamObject->id64); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** @test */ |
|
59
|
|
|
public function it_gets_the_base_users_player_summary() |
|
60
|
|
|
{ |
|
61
|
|
|
$friendsList = $this->steamClient->user($this->id64)->GetPlayerSummaries(); |
|
62
|
|
|
|
|
63
|
|
|
$this->assertCount(1, $friendsList); |
|
|
|
|
|
|
64
|
|
|
$this->checkPlayerProperties($friendsList); |
|
65
|
|
|
$this->checkPlayerClasses($friendsList); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** @test */ |
|
69
|
|
|
public function it_gets_the_supplied_users_player_summary() |
|
70
|
|
|
{ |
|
71
|
|
|
$friendsList = $this->steamClient->user($this->id64)->GetPlayerSummaries($this->altId64); |
|
72
|
|
|
|
|
73
|
|
|
$this->assertCount(1, $friendsList); |
|
|
|
|
|
|
74
|
|
|
$this->checkPlayerProperties($friendsList); |
|
75
|
|
|
$this->checkPlayerClasses($friendsList); |
|
76
|
|
|
|
|
77
|
|
|
$this->assertNotEquals($friendsList[0]->steamId, $this->id64); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** @test */ |
|
81
|
|
View Code Duplication |
public function it_gets_all_users_in_friend_list() |
|
|
|
|
|
|
82
|
|
|
{ |
|
83
|
|
|
$friendsList = $this->steamClient->user($this->id64)->GetFriendList('all'); |
|
84
|
|
|
|
|
85
|
|
|
$this->assertGreaterThan(0, $friendsList); |
|
86
|
|
|
|
|
87
|
|
|
$this->checkPlayerProperties($friendsList); |
|
88
|
|
|
$this->checkPlayerClasses($friendsList); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** @test */ |
|
92
|
|
View Code Duplication |
public function it_gets_friend_users_in_friend_list() |
|
|
|
|
|
|
93
|
|
|
{ |
|
94
|
|
|
$friendsList = $this->steamClient->user($this->id64)->GetFriendList('friend'); |
|
95
|
|
|
|
|
96
|
|
|
$this->assertGreaterThan(0, $friendsList); |
|
97
|
|
|
|
|
98
|
|
|
$this->checkPlayerProperties($friendsList); |
|
99
|
|
|
$this->checkPlayerClasses($friendsList); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** @test */ |
|
103
|
|
View Code Duplication |
public function it_throws_exception_to_invalid_relationship_types() |
|
|
|
|
|
|
104
|
|
|
{ |
|
105
|
|
|
$expectedMessage = 'Provided relationship [nonFriend] is not valid. Please select from: all, friend'; |
|
106
|
|
|
|
|
107
|
|
|
if (method_exists($this, 'setExpectedException')) { |
|
108
|
|
|
$this->setExpectedException('InvalidArgumentException', $expectedMessage); |
|
|
|
|
|
|
109
|
|
|
} else { |
|
110
|
|
|
$this->expectException('InvalidArgumentException'); |
|
111
|
|
|
$this->expectExceptionMessage($expectedMessage); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
$this->steamClient->user($this->id64)->GetFriendList('nonFriend'); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** @test */ |
|
118
|
|
|
public function it_gets_the_bans_for_the_base_user() |
|
119
|
|
|
{ |
|
120
|
|
|
$bans = $this->steamClient->user($this->id64)->GetPlayerBans(); |
|
121
|
|
|
|
|
122
|
|
|
$this->assertCount(1, $bans); |
|
123
|
|
|
|
|
124
|
|
|
$attributes = ['SteamId', 'CommunityBanned', 'VACBanned', 'NumberOfVACBans', 'DaysSinceLastBan', 'EconomyBan']; |
|
125
|
|
|
$this->assertObjectHasAttributes($attributes, $bans[0]); |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** @test */ |
|
129
|
|
|
public function it_gets_the_bans_for_the_supplied_user() |
|
130
|
|
|
{ |
|
131
|
|
|
$bans = $this->steamClient->user($this->id64)->GetPlayerBans($this->altId64); |
|
132
|
|
|
|
|
133
|
|
|
$this->assertCount(1, $bans); |
|
134
|
|
|
|
|
135
|
|
|
$attributes = ['SteamId', 'CommunityBanned', 'VACBanned', 'NumberOfVACBans', 'DaysSinceLastBan', 'EconomyBan']; |
|
136
|
|
|
$this->assertObjectHasAttributes($attributes, $bans[0]); |
|
137
|
|
|
|
|
138
|
|
|
$this->assertNotEquals($bans[0]->SteamId, $this->id64); |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
private function checkPlayerClasses($friendsList) |
|
142
|
|
|
{ |
|
143
|
|
|
$this->assertInstanceOf('Syntax\SteamApi\Containers\Player', $friendsList[0]); |
|
144
|
|
|
$this->assertInstanceOf('Syntax\SteamApi\Containers\Id', $friendsList[0]->steamIds); |
|
145
|
|
|
} |
|
146
|
|
|
} |