Skip to content

Commit

Permalink
#82: Moved status api out of versioning routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ulin-evgeny committed Jun 3, 2024
1 parent bddff48 commit e98d178
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 4 additions & 2 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
Route::post('auth/forgot-password', [AuthController::class, 'forgotPassword']);
Route::post('auth/restore-password', [AuthController::class, 'restorePassword']);
Route::post('auth/token/check', [AuthController::class, 'checkRestoreToken']);

Route::get('status', [StatusController::class, 'status']);
});
});
});

Route::group(['middleware' => 'guest_group'], function () {
Route::get('status', [StatusController::class, 'status']);
});
4 changes: 2 additions & 2 deletions tests/StatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class StatusTest extends TestCase
{
public function testStatusOk()
{
$response = $this->json('get', '/status');
$response = $this->json('get', '/status', [], [], 0, false);

$response->assertOk();
}
Expand All @@ -23,7 +23,7 @@ public function testStatusServiceUnavailable()
DB::shouldReceive('connection')->andReturn($connection);
DB::shouldReceive('getPdo')->andThrow(Exception::class);

$response = $this->json('get', '/status');
$response = $this->json('get', '/status', [], [], 0, false);

$response->assertStatus(Response::HTTP_SERVICE_UNAVAILABLE);
}
Expand Down
9 changes: 6 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ public function call($method, $uri, $parameters = [], $cookies = [], $files = []
return parent::call($method, $uri, $parameters, $cookies, $files, $server, $content);
}

public function json($method, $uri, array $data = [], array $headers = [], $options = 0, ?VersionEnum $apiVersion = null): TestResponse
public function json($method, $uri, array $data = [], array $headers = [], $options = 0, VersionEnum|bool|null $apiVersion = null): TestResponse
{
$apiVersion = (empty($apiVersion)) ? last(VersionEnum::values()) : $apiVersion->value;
if ($apiVersion !== false) {
$apiVersion = (empty($apiVersion)) ? last(VersionEnum::values()) : $apiVersion->value;
$uri = "/v{$apiVersion}{$uri}";
}

return parent::json($method, "/v{$apiVersion}{$uri}", $data, $headers);
return parent::json($method, $uri, $data, $headers);
}
}

0 comments on commit e98d178

Please sign in to comment.