Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

Route::controller(UserController::class)->group(function () {
Route::post('users', 'create');
Route::put('users/{id}', 'update');
Route::delete('users/{id}', 'delete');
Route::get('users/{id}', 'get');
Route::put('users/{id}', 'update')->whereNumber('id');
Route::delete('users/{id}', 'delete')->whereNumber('id');
Route::get('users/{id}', 'get')->whereNumber('id');
Route::get('users', 'search');
Route::get('profile', 'profile');
Route::put('profile', 'updateProfile');
Expand Down
9 changes: 9 additions & 0 deletions tests/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ public function testGet()
$this->assertEqualsFixture('get_user', $response->json());
}

public function testGetWrongUrl()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if delete does not have wereNumber(id)?
Please add tests for delete and put also

Suggested change
public function testGetWrongUrl()
public function testGetIdParamAsString()

{
$response = $this->actingAs(self::$admin)->json('get', '/users/test');

$response->assertNotFound();

$response->assertJson(['error' => 'The route v0.1/users/test could not be found.']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is not necessary to check the default error messages

Suggested change
$response->assertJson(['error' => 'The route v0.1/users/test could not be found.']);

}

public function testGetNotExists()
{
$response = $this->actingAs(self::$admin)->json('get', '/users/0');
Expand Down