@@ -4,10 +4,10 @@ |
||
| 4 | 4 | require_once("vendor/autoload.php");
|
| 5 | 5 | |
| 6 | 6 | |
| 7 | -use App\Lib\DsManager\Helpers\MatchSimulator; |
|
| 8 | -use App\Lib\DsManager\Models\Orm\League; |
|
| 9 | -use App\Lib\DsManager\Models\Orm\LeagueRound; |
|
| 10 | -use App\Lib\DsManager\Models\Orm\Match; |
|
| 7 | +use App\Lib\DsManager\Helpers\MatchSimulator; |
|
| 8 | +use App\Lib\DsManager\Models\Orm\League; |
|
| 9 | +use App\Lib\DsManager\Models\Orm\LeagueRound; |
|
| 10 | +use App\Lib\DsManager\Models\Orm\Match; |
|
| 11 | 11 | use App\Lib\DsManager\Models\Orm\MatchResult; |
| 12 | 12 | use \App\Lib\Helpers\Responder; |
| 13 | 13 | use \App\Lib\DsManager\Models\Orm\Player; |
@@ -15,190 +15,190 @@ |
||
| 15 | 15 | use \App\Lib\DsManager\Models\Orm\Coach; |
| 16 | 16 | |
| 17 | 17 | $configuration = [ |
| 18 | - 'settings' => [ |
|
| 19 | - 'displayErrorDetails' => true, |
|
| 20 | - ], |
|
| 18 | + 'settings' => [ |
|
| 19 | + 'displayErrorDetails' => true, |
|
| 20 | + ], |
|
| 21 | 21 | ]; |
| 22 | 22 | $c = new \Slim\Container($configuration); |
| 23 | 23 | $api = new \Slim\App($c); |
| 24 | 24 | |
| 25 | 25 | $api->get('/ping', function ($request, $response, $args) {
|
| 26 | - $jsonResp = json_encode( |
|
| 27 | - [ |
|
| 28 | - "status" => "service up", |
|
| 29 | - "message" => "in a bottle" |
|
| 30 | - ] |
|
| 31 | - ); |
|
| 32 | - return Responder::getJsonResponse($jsonResp, $response); |
|
| 26 | + $jsonResp = json_encode( |
|
| 27 | + [ |
|
| 28 | + "status" => "service up", |
|
| 29 | + "message" => "in a bottle" |
|
| 30 | + ] |
|
| 31 | + ); |
|
| 32 | + return Responder::getJsonResponse($jsonResp, $response); |
|
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | 35 | $api->get('/players', function ($request, $response, $args) {
|
| 36 | - $json = json_encode(Player::all()); |
|
| 37 | - return Responder::getJsonResponse($json, $response); |
|
| 36 | + $json = json_encode(Player::all()); |
|
| 37 | + return Responder::getJsonResponse($json, $response); |
|
| 38 | 38 | }); |
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | $api->get('/players/{id}', function ($request, $response, $args) {
|
| 42 | - return Responder::getJsonResponse( |
|
| 43 | - Player::findOrFail($args['id']), |
|
| 44 | - $response |
|
| 45 | - ); |
|
| 42 | + return Responder::getJsonResponse( |
|
| 43 | + Player::findOrFail($args['id']), |
|
| 44 | + $response |
|
| 45 | + ); |
|
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | 48 | $api->get('/coaches', function ($request, $response, $args) {
|
| 49 | - return Responder::getJsonResponse( |
|
| 50 | - Coach::all(), |
|
| 51 | - $response |
|
| 52 | - ); |
|
| 49 | + return Responder::getJsonResponse( |
|
| 50 | + Coach::all(), |
|
| 51 | + $response |
|
| 52 | + ); |
|
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | 55 | $api->get('/teams', function ($request, $response, $args) {
|
| 56 | - return Responder::getJsonResponse( |
|
| 57 | - Team::all(), |
|
| 58 | - $response |
|
| 59 | - ); |
|
| 56 | + return Responder::getJsonResponse( |
|
| 57 | + Team::all(), |
|
| 58 | + $response |
|
| 59 | + ); |
|
| 60 | 60 | }); |
| 61 | 61 | |
| 62 | 62 | $api->get('/teams/{id}', function ($request, $response, $args) {
|
| 63 | - return Responder::getJsonResponse( |
|
| 64 | - Team::complete() |
|
| 65 | - ->where( |
|
| 66 | - [ |
|
| 67 | - 'id' => $args['id'] |
|
| 68 | - ] |
|
| 69 | - )->get(), |
|
| 70 | - $response |
|
| 71 | - ); |
|
| 63 | + return Responder::getJsonResponse( |
|
| 64 | + Team::complete() |
|
| 65 | + ->where( |
|
| 66 | + [ |
|
| 67 | + 'id' => $args['id'] |
|
| 68 | + ] |
|
| 69 | + )->get(), |
|
| 70 | + $response |
|
| 71 | + ); |
|
| 72 | 72 | }); |
| 73 | 73 | |
| 74 | 74 | $api->get('/teams/{id}/players', function ($request, $response, $args) {
|
| 75 | - return Responder::getJsonResponse( |
|
| 76 | - Team::with( |
|
| 77 | - 'roster' |
|
| 78 | - )->where( |
|
| 79 | - [ |
|
| 80 | - 'id' => $args['id'] |
|
| 81 | - ] |
|
| 82 | - )->get(), |
|
| 83 | - $response |
|
| 84 | - ); |
|
| 75 | + return Responder::getJsonResponse( |
|
| 76 | + Team::with( |
|
| 77 | + 'roster' |
|
| 78 | + )->where( |
|
| 79 | + [ |
|
| 80 | + 'id' => $args['id'] |
|
| 81 | + ] |
|
| 82 | + )->get(), |
|
| 83 | + $response |
|
| 84 | + ); |
|
| 85 | 85 | }); |
| 86 | 86 | |
| 87 | 87 | $api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) {
|
| 88 | - return Responder::getJsonResponse( |
|
| 89 | - Player::statistics()->where( |
|
| 90 | - [ |
|
| 91 | - 'id' => $args['playerId'], |
|
| 92 | - 'team_id' => $args['id'] |
|
| 93 | - ] |
|
| 94 | - )->get(), |
|
| 95 | - $response |
|
| 96 | - ); |
|
| 88 | + return Responder::getJsonResponse( |
|
| 89 | + Player::statistics()->where( |
|
| 90 | + [ |
|
| 91 | + 'id' => $args['playerId'], |
|
| 92 | + 'team_id' => $args['id'] |
|
| 93 | + ] |
|
| 94 | + )->get(), |
|
| 95 | + $response |
|
| 96 | + ); |
|
| 97 | 97 | }); |
| 98 | 98 | |
| 99 | 99 | $api->get('/teams/{id}/coach', function ($request, $response, $args) {
|
| 100 | - return Responder::getJsonResponse( |
|
| 101 | - Team::with( |
|
| 102 | - 'coach' |
|
| 103 | - )->where( |
|
| 104 | - [ |
|
| 105 | - 'id' => $args['id'] |
|
| 106 | - ] |
|
| 107 | - )->get(), |
|
| 108 | - $response |
|
| 109 | - ); |
|
| 100 | + return Responder::getJsonResponse( |
|
| 101 | + Team::with( |
|
| 102 | + 'coach' |
|
| 103 | + )->where( |
|
| 104 | + [ |
|
| 105 | + 'id' => $args['id'] |
|
| 106 | + ] |
|
| 107 | + )->get(), |
|
| 108 | + $response |
|
| 109 | + ); |
|
| 110 | 110 | }); |
| 111 | 111 | |
| 112 | 112 | $api->get('/leagues', function ($request, $response, $args) {
|
| 113 | - return Responder::getJsonResponse( |
|
| 114 | - League::all(), |
|
| 115 | - $response |
|
| 116 | - ); |
|
| 113 | + return Responder::getJsonResponse( |
|
| 114 | + League::all(), |
|
| 115 | + $response |
|
| 116 | + ); |
|
| 117 | 117 | }); |
| 118 | 118 | |
| 119 | 119 | $api->get('/leagues/{id}', function ($request, $response, $args) {
|
| 120 | - return Responder::getJsonResponse( |
|
| 121 | - League::with('rounds')
|
|
| 122 | - ->where( |
|
| 123 | - [ |
|
| 124 | - 'id' => $args['id'] |
|
| 125 | - ] |
|
| 126 | - )->first(), |
|
| 127 | - $response |
|
| 128 | - ); |
|
| 120 | + return Responder::getJsonResponse( |
|
| 121 | + League::with('rounds')
|
|
| 122 | + ->where( |
|
| 123 | + [ |
|
| 124 | + 'id' => $args['id'] |
|
| 125 | + ] |
|
| 126 | + )->first(), |
|
| 127 | + $response |
|
| 128 | + ); |
|
| 129 | 129 | }); |
| 130 | 130 | |
| 131 | 131 | $api->get('/leagues/{id}/rounds/{roundId}', function ($request, $response, $args) {
|
| 132 | - return Responder::getJsonResponse( |
|
| 133 | - LeagueRound::complete() |
|
| 134 | - ->where( |
|
| 135 | - [ |
|
| 136 | - 'id' => $args['roundId'], |
|
| 137 | - ] |
|
| 138 | - )->first(), |
|
| 139 | - $response |
|
| 140 | - ); |
|
| 132 | + return Responder::getJsonResponse( |
|
| 133 | + LeagueRound::complete() |
|
| 134 | + ->where( |
|
| 135 | + [ |
|
| 136 | + 'id' => $args['roundId'], |
|
| 137 | + ] |
|
| 138 | + )->first(), |
|
| 139 | + $response |
|
| 140 | + ); |
|
| 141 | 141 | }); |
| 142 | 142 | |
| 143 | 143 | $api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) {
|
| 144 | - return Responder::getJsonResponse( |
|
| 145 | - MatchSimulator::simulateRound( |
|
| 146 | - $args['roundId'] |
|
| 147 | - ), |
|
| 148 | - $response |
|
| 149 | - ); |
|
| 144 | + return Responder::getJsonResponse( |
|
| 145 | + MatchSimulator::simulateRound( |
|
| 146 | + $args['roundId'] |
|
| 147 | + ), |
|
| 148 | + $response |
|
| 149 | + ); |
|
| 150 | 150 | }); |
| 151 | 151 | |
| 152 | 152 | $api->get('/matches', function ($request, $response, $args) {
|
| 153 | - return Responder::getJsonResponse( |
|
| 154 | - Match::teams()->get(), |
|
| 155 | - $response |
|
| 156 | - ); |
|
| 153 | + return Responder::getJsonResponse( |
|
| 154 | + Match::teams()->get(), |
|
| 155 | + $response |
|
| 156 | + ); |
|
| 157 | 157 | }); |
| 158 | 158 | |
| 159 | 159 | $api->post('/matches', function ($request, $response, $args) {
|
| 160 | - $json = $request->getBody(); |
|
| 161 | - $json = json_decode($json, true); |
|
| 162 | - return Responder::getJsonResponse( |
|
| 163 | - Match::create( |
|
| 164 | - $json |
|
| 165 | - ), |
|
| 166 | - $response |
|
| 167 | - ); |
|
| 160 | + $json = $request->getBody(); |
|
| 161 | + $json = json_decode($json, true); |
|
| 162 | + return Responder::getJsonResponse( |
|
| 163 | + Match::create( |
|
| 164 | + $json |
|
| 165 | + ), |
|
| 166 | + $response |
|
| 167 | + ); |
|
| 168 | 168 | }); |
| 169 | 169 | |
| 170 | 170 | $api->get('/matches/{id}', function ($request, $response, $args) {
|
| 171 | - return Responder::getJsonResponse( |
|
| 172 | - Match::complete() |
|
| 173 | - ->where( |
|
| 174 | - [ |
|
| 175 | - 'id' => $args['id'] |
|
| 176 | - ] |
|
| 177 | - )->first(), |
|
| 178 | - $response |
|
| 179 | - ); |
|
| 171 | + return Responder::getJsonResponse( |
|
| 172 | + Match::complete() |
|
| 173 | + ->where( |
|
| 174 | + [ |
|
| 175 | + 'id' => $args['id'] |
|
| 176 | + ] |
|
| 177 | + )->first(), |
|
| 178 | + $response |
|
| 179 | + ); |
|
| 180 | 180 | }); |
| 181 | 181 | |
| 182 | 182 | $api->get('/matches/{id}/result', function ($request, $response, $args) {
|
| 183 | - $result = MatchResult::complete() |
|
| 184 | - ->where( |
|
| 185 | - [ |
|
| 186 | - 'id' => $args['id'] |
|
| 187 | - ] |
|
| 188 | - )->first(); |
|
| 183 | + $result = MatchResult::complete() |
|
| 184 | + ->where( |
|
| 185 | + [ |
|
| 186 | + 'id' => $args['id'] |
|
| 187 | + ] |
|
| 188 | + )->first(); |
|
| 189 | 189 | |
| 190 | - return Responder::getJsonResponse( |
|
| 191 | - $result, |
|
| 192 | - $response |
|
| 193 | - ); |
|
| 190 | + return Responder::getJsonResponse( |
|
| 191 | + $result, |
|
| 192 | + $response |
|
| 193 | + ); |
|
| 194 | 194 | }); |
| 195 | 195 | |
| 196 | 196 | $api->put('/matches/{id}/simulate', function ($request, $response, $args) {
|
| 197 | - return Responder::getJsonResponse( |
|
| 198 | - MatchSimulator::simulateCompleteResult( |
|
| 199 | - $args['id'] |
|
| 200 | - ), |
|
| 201 | - $response |
|
| 202 | - ); |
|
| 197 | + return Responder::getJsonResponse( |
|
| 198 | + MatchSimulator::simulateCompleteResult( |
|
| 199 | + $args['id'] |
|
| 200 | + ), |
|
| 201 | + $response |
|
| 202 | + ); |
|
| 203 | 203 | }); |
| 204 | 204 | $api->run(); |
| 205 | 205 | \ No newline at end of file |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | $c = new \Slim\Container($configuration); |
| 23 | 23 | $api = new \Slim\App($c); |
| 24 | 24 | |
| 25 | -$api->get('/ping', function ($request, $response, $args) {
|
|
| 25 | +$api->get('/ping', function($request, $response, $args) {
|
|
| 26 | 26 | $jsonResp = json_encode( |
| 27 | 27 | [ |
| 28 | 28 | "status" => "service up", |
@@ -32,34 +32,34 @@ discard block |
||
| 32 | 32 | return Responder::getJsonResponse($jsonResp, $response); |
| 33 | 33 | }); |
| 34 | 34 | |
| 35 | -$api->get('/players', function ($request, $response, $args) {
|
|
| 35 | +$api->get('/players', function($request, $response, $args) {
|
|
| 36 | 36 | $json = json_encode(Player::all()); |
| 37 | 37 | return Responder::getJsonResponse($json, $response); |
| 38 | 38 | }); |
| 39 | 39 | |
| 40 | 40 | |
| 41 | -$api->get('/players/{id}', function ($request, $response, $args) {
|
|
| 41 | +$api->get('/players/{id}', function($request, $response, $args) {
|
|
| 42 | 42 | return Responder::getJsonResponse( |
| 43 | 43 | Player::findOrFail($args['id']), |
| 44 | 44 | $response |
| 45 | 45 | ); |
| 46 | 46 | }); |
| 47 | 47 | |
| 48 | -$api->get('/coaches', function ($request, $response, $args) {
|
|
| 48 | +$api->get('/coaches', function($request, $response, $args) {
|
|
| 49 | 49 | return Responder::getJsonResponse( |
| 50 | 50 | Coach::all(), |
| 51 | 51 | $response |
| 52 | 52 | ); |
| 53 | 53 | }); |
| 54 | 54 | |
| 55 | -$api->get('/teams', function ($request, $response, $args) {
|
|
| 55 | +$api->get('/teams', function($request, $response, $args) {
|
|
| 56 | 56 | return Responder::getJsonResponse( |
| 57 | 57 | Team::all(), |
| 58 | 58 | $response |
| 59 | 59 | ); |
| 60 | 60 | }); |
| 61 | 61 | |
| 62 | -$api->get('/teams/{id}', function ($request, $response, $args) {
|
|
| 62 | +$api->get('/teams/{id}', function($request, $response, $args) {
|
|
| 63 | 63 | return Responder::getJsonResponse( |
| 64 | 64 | Team::complete() |
| 65 | 65 | ->where( |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | ); |
| 72 | 72 | }); |
| 73 | 73 | |
| 74 | -$api->get('/teams/{id}/players', function ($request, $response, $args) {
|
|
| 74 | +$api->get('/teams/{id}/players', function($request, $response, $args) {
|
|
| 75 | 75 | return Responder::getJsonResponse( |
| 76 | 76 | Team::with( |
| 77 | 77 | 'roster' |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | ); |
| 85 | 85 | }); |
| 86 | 86 | |
| 87 | -$api->get('/teams/{id}/players/{playerId}', function ($request, $response, $args) {
|
|
| 87 | +$api->get('/teams/{id}/players/{playerId}', function($request, $response, $args) {
|
|
| 88 | 88 | return Responder::getJsonResponse( |
| 89 | 89 | Player::statistics()->where( |
| 90 | 90 | [ |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | }); |
| 98 | 98 | |
| 99 | -$api->get('/teams/{id}/coach', function ($request, $response, $args) {
|
|
| 99 | +$api->get('/teams/{id}/coach', function($request, $response, $args) {
|
|
| 100 | 100 | return Responder::getJsonResponse( |
| 101 | 101 | Team::with( |
| 102 | 102 | 'coach' |
@@ -109,14 +109,14 @@ discard block |
||
| 109 | 109 | ); |
| 110 | 110 | }); |
| 111 | 111 | |
| 112 | -$api->get('/leagues', function ($request, $response, $args) {
|
|
| 112 | +$api->get('/leagues', function($request, $response, $args) {
|
|
| 113 | 113 | return Responder::getJsonResponse( |
| 114 | 114 | League::all(), |
| 115 | 115 | $response |
| 116 | 116 | ); |
| 117 | 117 | }); |
| 118 | 118 | |
| 119 | -$api->get('/leagues/{id}', function ($request, $response, $args) {
|
|
| 119 | +$api->get('/leagues/{id}', function($request, $response, $args) {
|
|
| 120 | 120 | return Responder::getJsonResponse( |
| 121 | 121 | League::with('rounds')
|
| 122 | 122 | ->where( |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | ); |
| 129 | 129 | }); |
| 130 | 130 | |
| 131 | -$api->get('/leagues/{id}/rounds/{roundId}', function ($request, $response, $args) {
|
|
| 131 | +$api->get('/leagues/{id}/rounds/{roundId}', function($request, $response, $args) {
|
|
| 132 | 132 | return Responder::getJsonResponse( |
| 133 | 133 | LeagueRound::complete() |
| 134 | 134 | ->where( |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | ); |
| 141 | 141 | }); |
| 142 | 142 | |
| 143 | -$api->put('/leagues/{id}/rounds/{roundId}/simulate', function ($request, $response, $args) {
|
|
| 143 | +$api->put('/leagues/{id}/rounds/{roundId}/simulate', function($request, $response, $args) {
|
|
| 144 | 144 | return Responder::getJsonResponse( |
| 145 | 145 | MatchSimulator::simulateRound( |
| 146 | 146 | $args['roundId'] |
@@ -149,14 +149,14 @@ discard block |
||
| 149 | 149 | ); |
| 150 | 150 | }); |
| 151 | 151 | |
| 152 | -$api->get('/matches', function ($request, $response, $args) {
|
|
| 152 | +$api->get('/matches', function($request, $response, $args) {
|
|
| 153 | 153 | return Responder::getJsonResponse( |
| 154 | 154 | Match::teams()->get(), |
| 155 | 155 | $response |
| 156 | 156 | ); |
| 157 | 157 | }); |
| 158 | 158 | |
| 159 | -$api->post('/matches', function ($request, $response, $args) {
|
|
| 159 | +$api->post('/matches', function($request, $response, $args) {
|
|
| 160 | 160 | $json = $request->getBody(); |
| 161 | 161 | $json = json_decode($json, true); |
| 162 | 162 | return Responder::getJsonResponse( |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | ); |
| 168 | 168 | }); |
| 169 | 169 | |
| 170 | -$api->get('/matches/{id}', function ($request, $response, $args) {
|
|
| 170 | +$api->get('/matches/{id}', function($request, $response, $args) {
|
|
| 171 | 171 | return Responder::getJsonResponse( |
| 172 | 172 | Match::complete() |
| 173 | 173 | ->where( |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | ); |
| 180 | 180 | }); |
| 181 | 181 | |
| 182 | -$api->get('/matches/{id}/result', function ($request, $response, $args) {
|
|
| 182 | +$api->get('/matches/{id}/result', function($request, $response, $args) {
|
|
| 183 | 183 | $result = MatchResult::complete() |
| 184 | 184 | ->where( |
| 185 | 185 | [ |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | ); |
| 194 | 194 | }); |
| 195 | 195 | |
| 196 | -$api->put('/matches/{id}/simulate', function ($request, $response, $args) {
|
|
| 196 | +$api->put('/matches/{id}/simulate', function($request, $response, $args) {
|
|
| 197 | 197 | return Responder::getJsonResponse( |
| 198 | 198 | MatchSimulator::simulateCompleteResult( |
| 199 | 199 | $args['id'] |
@@ -8,74 +8,74 @@ |
||
| 8 | 8 | { |
| 9 | 9 | |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @group Helpers |
|
| 13 | - * @group FixtureGenerator |
|
| 14 | - * @group generatefixture |
|
| 15 | - */ |
|
| 16 | - public function testFixtureGenerator() |
|
| 17 | - { |
|
| 18 | - $teams = \App\Lib\DsManager\Models\Orm\Team::all(); |
|
| 19 | - $rounds = \App\Lib\DsManager\Helpers\LeagueFixtureGenerator::generate( |
|
| 20 | - $teams->toArray() |
|
| 21 | - ); |
|
| 22 | - //Number of rounds |
|
| 23 | - $this->assertCount($teams->count() - 1, $rounds); |
|
| 24 | - //Matches for each round |
|
| 25 | - foreach ($rounds as $round) { |
|
| 26 | - $this->assertCount($teams->count() / 2, $round); |
|
| 27 | - } |
|
| 28 | - } |
|
| 11 | + /** |
|
| 12 | + * @group Helpers |
|
| 13 | + * @group FixtureGenerator |
|
| 14 | + * @group generatefixture |
|
| 15 | + */ |
|
| 16 | + public function testFixtureGenerator() |
|
| 17 | + { |
|
| 18 | + $teams = \App\Lib\DsManager\Models\Orm\Team::all(); |
|
| 19 | + $rounds = \App\Lib\DsManager\Helpers\LeagueFixtureGenerator::generate( |
|
| 20 | + $teams->toArray() |
|
| 21 | + ); |
|
| 22 | + //Number of rounds |
|
| 23 | + $this->assertCount($teams->count() - 1, $rounds); |
|
| 24 | + //Matches for each round |
|
| 25 | + foreach ($rounds as $round) { |
|
| 26 | + $this->assertCount($teams->count() / 2, $round); |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * @group Helpers |
|
| 32 | - * @group MatchSimulator |
|
| 33 | - */ |
|
| 34 | - public function testMatchSimulator() |
|
| 35 | - { |
|
| 36 | - $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
| 37 | - [ |
|
| 38 | - 'simulated' => false |
|
| 39 | - ] |
|
| 40 | - )->get()->random(1); |
|
| 41 | - $this->assertNotEmpty($match); |
|
| 42 | - $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateCompleteResult($match->id); |
|
| 43 | - $this->assertNotEmpty($result); |
|
| 44 | - $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
| 45 | - [ |
|
| 46 | - 'id' => $match->id, |
|
| 47 | - 'simulated' => true |
|
| 48 | - ] |
|
| 49 | - )->first(); |
|
| 50 | - $this->assertNotEmpty($match); |
|
| 51 | - } |
|
| 30 | + /** |
|
| 31 | + * @group Helpers |
|
| 32 | + * @group MatchSimulator |
|
| 33 | + */ |
|
| 34 | + public function testMatchSimulator() |
|
| 35 | + { |
|
| 36 | + $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
| 37 | + [ |
|
| 38 | + 'simulated' => false |
|
| 39 | + ] |
|
| 40 | + )->get()->random(1); |
|
| 41 | + $this->assertNotEmpty($match); |
|
| 42 | + $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateCompleteResult($match->id); |
|
| 43 | + $this->assertNotEmpty($result); |
|
| 44 | + $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
| 45 | + [ |
|
| 46 | + 'id' => $match->id, |
|
| 47 | + 'simulated' => true |
|
| 48 | + ] |
|
| 49 | + )->first(); |
|
| 50 | + $this->assertNotEmpty($match); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @group Helpers |
|
| 55 | - * @group RoundSimulator |
|
| 56 | - */ |
|
| 57 | - public function testRoundSimulator() |
|
| 58 | - { |
|
| 59 | - $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
| 60 | - [ |
|
| 61 | - 'simulated' => false |
|
| 62 | - ] |
|
| 63 | - )->whereNotNull( |
|
| 64 | - 'league_round_id' |
|
| 65 | - )->get()->random(1); |
|
| 66 | - $this->assertNotEmpty($match); |
|
| 67 | - $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id); |
|
| 68 | - $this->assertNotEmpty($result); |
|
| 69 | - $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
| 70 | - [ |
|
| 71 | - 'id' => $match->id, |
|
| 72 | - 'simulated' => true |
|
| 73 | - ] |
|
| 74 | - )->first(); |
|
| 75 | - $this->assertNotEmpty($match); |
|
| 76 | - $round = \App\Lib\DsManager\Models\Orm\LeagueRound::find($match->league_round_id); |
|
| 77 | - $this->assertNotEmpty($round); |
|
| 78 | - $this->assertTrue($round->simulated); |
|
| 79 | - } |
|
| 53 | + /** |
|
| 54 | + * @group Helpers |
|
| 55 | + * @group RoundSimulator |
|
| 56 | + */ |
|
| 57 | + public function testRoundSimulator() |
|
| 58 | + { |
|
| 59 | + $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
| 60 | + [ |
|
| 61 | + 'simulated' => false |
|
| 62 | + ] |
|
| 63 | + )->whereNotNull( |
|
| 64 | + 'league_round_id' |
|
| 65 | + )->get()->random(1); |
|
| 66 | + $this->assertNotEmpty($match); |
|
| 67 | + $result = \App\Lib\DsManager\Helpers\MatchSimulator::simulateRound($match->league_round_id); |
|
| 68 | + $this->assertNotEmpty($result); |
|
| 69 | + $match = \App\Lib\DsManager\Models\Orm\Match::where( |
|
| 70 | + [ |
|
| 71 | + 'id' => $match->id, |
|
| 72 | + 'simulated' => true |
|
| 73 | + ] |
|
| 74 | + )->first(); |
|
| 75 | + $this->assertNotEmpty($match); |
|
| 76 | + $round = \App\Lib\DsManager\Models\Orm\LeagueRound::find($match->league_round_id); |
|
| 77 | + $this->assertNotEmpty($round); |
|
| 78 | + $this->assertTrue($round->simulated); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | 81 | } |
@@ -9,54 +9,54 @@ |
||
| 9 | 9 | class LeagueRound extends DsManagerOrm |
| 10 | 10 | { |
| 11 | 11 | |
| 12 | - /** |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $table = 'league_rounds'; |
|
| 16 | - |
|
| 17 | - /** |
|
| 18 | - * @var array |
|
| 19 | - */ |
|
| 20 | - protected $fillable = [ |
|
| 21 | - 'league_id', |
|
| 22 | - 'day', |
|
| 23 | - 'simulated' |
|
| 24 | - ]; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var array |
|
| 28 | - */ |
|
| 29 | - protected $casts = [ |
|
| 30 | - 'simulated' => 'boolean' |
|
| 31 | - ]; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @return \Illuminate\Database\Eloquent\Relations\HasOne |
|
| 35 | - */ |
|
| 36 | - public function league() |
|
| 37 | - { |
|
| 38 | - return $this->belongsTo(League::class); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
| 43 | - */ |
|
| 44 | - public function matches() |
|
| 45 | - { |
|
| 46 | - return $this->hasMany(Match::class); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param $query |
|
| 51 | - * @return mixed |
|
| 52 | - */ |
|
| 53 | - public function scopeComplete($query) |
|
| 54 | - { |
|
| 55 | - return $query->with( |
|
| 56 | - 'league', |
|
| 57 | - 'matches', |
|
| 58 | - 'matches.homeTeam', |
|
| 59 | - 'matches.AwayTeam' |
|
| 60 | - ); |
|
| 61 | - } |
|
| 12 | + /** |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $table = 'league_rounds'; |
|
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * @var array |
|
| 19 | + */ |
|
| 20 | + protected $fillable = [ |
|
| 21 | + 'league_id', |
|
| 22 | + 'day', |
|
| 23 | + 'simulated' |
|
| 24 | + ]; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var array |
|
| 28 | + */ |
|
| 29 | + protected $casts = [ |
|
| 30 | + 'simulated' => 'boolean' |
|
| 31 | + ]; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @return \Illuminate\Database\Eloquent\Relations\HasOne |
|
| 35 | + */ |
|
| 36 | + public function league() |
|
| 37 | + { |
|
| 38 | + return $this->belongsTo(League::class); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @return \Illuminate\Database\Eloquent\Relations\HasMany |
|
| 43 | + */ |
|
| 44 | + public function matches() |
|
| 45 | + { |
|
| 46 | + return $this->hasMany(Match::class); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param $query |
|
| 51 | + * @return mixed |
|
| 52 | + */ |
|
| 53 | + public function scopeComplete($query) |
|
| 54 | + { |
|
| 55 | + return $query->with( |
|
| 56 | + 'league', |
|
| 57 | + 'matches', |
|
| 58 | + 'matches.homeTeam', |
|
| 59 | + 'matches.AwayTeam' |
|
| 60 | + ); |
|
| 61 | + } |
|
| 62 | 62 | } |
| 63 | 63 | \ No newline at end of file |