Skip to content

Commit

Permalink
Fixing the xml grabbing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stygiansabyss committed Feb 3, 2017
1 parent 3d52f4d commit f0a91a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
8 changes: 8 additions & 0 deletions src/Syntax/SteamApi/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ protected function setUpXml(array $arguments = [])

// Pass the results back
return simplexml_load_file($steamUrl . '?' . $parameters);
libxml_use_internal_errors(true);
$result = simplexml_load_file($steamUrl . '?' . $parameters);

if (! $result) {
return null;
}

return $result;
}

public function getRedirectUrl()
Expand Down
14 changes: 9 additions & 5 deletions src/Syntax/SteamApi/Steam/User/Stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,17 @@ public function GetPlayerAchievements($appId)
if (is_int($appId)) {
$this->getRedirectUrl();

// Get the client
$client = $this->setUpXml($arguments);
try {
// Get the client
$client = $this->setUpXml($arguments);

// Clean up the games
$achievements = $this->convertToObjects($client->achievements->achievement);
// Clean up the games
$achievements = $this->convertToObjects($client->achievements->achievement);

return $achievements;
return $achievements;
} catch (\Exception $exception) {
return null;
}
}

// If the name and ID fail, return null.
Expand Down
2 changes: 1 addition & 1 deletion tests/UserStatsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class UserStatsTest extends BaseTester {
/** @test */
public function it_returns_null_when_there_are_no_achievements_for_a_game()
{
$achievements = $this->steamClient->userStats($this->id64)->GetPlayerAchievements(42690);
$achievements = $this->steamClient->userStats($this->id64)->GetPlayerAchievements(359320);

$this->assertNull($achievements);
}
Expand Down

0 comments on commit f0a91a3

Please sign in to comment.