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 a listing of the resource.
  *
  * @method void scopeListGames()
  *
  * @return \BladeView|bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function index()
 {
     $SteamGames = SteamGame::ListGames()->get();
     $averagePlaytimePerDay = round(SteamGame::where('playtime_2weeks', '>', 0)->sum('playtime_2weeks') / 60 / 14, 2);
     return view('pages.SteamGames', ['SteamGames' => $SteamGames, 'averageplaytimeperday' => $averagePlaytimePerDay]);
 }