/** * @group Stats */ public function testGetStats() { $match = \App\Lib\DsManager\Models\Orm\Match::where(['simulated' => false])->whereNotNull('league_round_id')->get()->random(1); $this->assertNotEmpty($match); $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id); $this->assertNotEmpty($result); $players = \App\Lib\DsManager\Models\Orm\Player::getBest(); $this->assertNotEmpty($players); $teams = \App\Lib\DsManager\Models\Orm\Team::getBest(); $this->assertNotEmpty($teams); }
use App\Lib\DsManager\Models\Orm\LeagueRound; use App\Lib\DsManager\Models\Orm\Match; use App\Lib\DsManager\Models\Orm\MatchResult; use App\Lib\Helpers\Responder; use App\Lib\DsManager\Models\Orm\Player; use App\Lib\DsManager\Models\Orm\Team; use App\Lib\DsManager\Models\Orm\Coach; $configuration = ['settings' => ['displayErrorDetails' => true]]; $c = new \Slim\Container($configuration); $api = new \Slim\App($c); $api->get('/ping', function ($request, $response, $args) { $jsonResp = json_encode(["status" => "service up", "message" => "in a bottle"]); return Responder::getJsonResponse($jsonResp, $response); }); $api->get('/statistics', function ($request, $response, $args) { return Responder::getJsonResponse(json_encode(['players' => Player::getBest(), 'teams' => Team::getBest()], JSON_NUMERIC_CHECK), $response); }); $api->get('/coaches', function ($request, $response, $args) { return Responder::getJsonResponse(Coach::all(), $response); }); $api->get('/teams', function ($request, $response, $args) { return Responder::getJsonResponse(Team::all(), $response); }); $api->get('/teams/{id}', function ($request, $response, $args) { return Responder::getJsonResponse(Team::complete()->where(['id' => $args['id']])->get(), $response); }); $api->get('/teams/{id}/players', function ($request, $response, $args) { return Responder::getJsonResponse(Team::with('roster')->where(['id' => $args['id']])->get(), $response); }); $api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) { return Responder::getJsonResponse(Player::statistics()->where(['id' => $args['playerId'], 'team_id' => $args['id']])->get(), $response);