Exemplo n.º 1
0
 /**
  * @covers \App\Http\Controllers\SteamGameController
  * @covers \App\SteamGame
  */
 public function test_parsing_json_and_storing_a_game_and_stats()
 {
     $game = json_decode($this->gameJson);
     $SteamGame = App\SteamGame::firstOrNew(['id' => $game->appid]);
     $SteamAPIGame = new App\Http\Controllers\Integration\SteamAPI\SteamAPIGame();
     $SteamAPIGame->parseAndSaveSteamGame($SteamGame, $game);
     $this->seeInDatabase('steam_games', ['name' => 'Creeper World 3: Arc Eternal']);
     $steamGameDescriptionJson = json_decode($this->steamGameDescriptionJson);
     $SteamAPIGameDescription = new App\Http\Controllers\Integration\SteamAPI\SteamAPIGameDescription(new App\SteamGame());
     $SteamAPIGameDescription->updateSteamGameWithNewDescription($SteamGame, $steamGameDescriptionJson);
     $this->seeInDatabase('steam_games', ['website' => 'http://knucklecracker.com']);
     $SteamGameSchemaFromAPI = json_decode($this->steamSchemaJson);
     $SteamAPIGameSchema = new App\Http\Controllers\Integration\SteamAPI\SteamAPIGameSchema(new App\SteamGame());
     $SteamAPIGameSchema->parseAndSaveAchievementSchema($SteamGame->id, $SteamGameSchemaFromAPI->achievements);
     $this->seeInDatabase('steam_game_achievements', ['steam_game_id' => '280220', 'display_name' => 'Training Wheels']);
     $SteamAPIGameSchema->parseAndSaveStatSchema($SteamGame->id, $SteamGameSchemaFromAPI->stats);
     $this->seeInDatabase('steam_game_stats', ['steam_game_id' => '280220', 'display_name' => 'Inhibitors destroyed in Tormented Space']);
     $this->visit('/')->click('Steam')->see('Steam Games')->seePageIs('/game/steam');
     $this->visit('/game/steam/280220')->see('Creeper World 3: Arc Eternal')->seePageIs('/game/steam/280220');
     $SteamGames = \App\SteamGame::ListGames()->get();
     $this->assertEquals('Creeper World 3: Arc Eternal', $SteamGames[0]['attributes']['name']);
     $SteamGame = \App\SteamGame::find($game->appid)->stats->first();
     $this->assertEquals('testStat1', $SteamGame['attributes']['name']);
     $SteamGame = \App\SteamGame::find($game->appid)->achievements->first();
     $this->assertEquals('ACH_0', $SteamGame['attributes']['name']);
 }
Exemplo n.º 2
0
 /**
  * Display the specified resource.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $SteamGame = SteamGame::find($id);
     $CompletedAchievements = $SteamGame->achievements->filter(function ($item, $key) {
         return $item['value'] == 1;
     });
     $NotCompletedAchievements = $SteamGame->achievements->filter(function ($item, $key) {
         return $item['value'] == 0;
     });
     return view('pages.SteamGame', ['SteamGame' => $SteamGame, 'CompletedAchievements' => $CompletedAchievements, 'NotCompletedAchievements' => $NotCompletedAchievements]);
 }
Exemplo n.º 3
0
 /**
  * @param $GameId
  *
  * @return mixed
  */
 private function setGameTimestampForSchema($GameId)
 {
     $SteamGame = SteamGame::find($GameId);
     $SteamGame->schema_updated_at = date('Y-m-d H:i:s');
     return $SteamGame->save();
 }
 /**
  * @param $GameId
  *
  * @return mixed
  */
 private function setGameTimestampForAchievement($GameId)
 {
     $SteamGame = SteamGame::find($GameId);
     $SteamGame->player_stats_updated_at = date('Y-m-d H:i:s');
     return $SteamGame->save();
 }