Skip to content

Commit 5fe40f4

Browse files
authored
Merge pull request #131 from artengin/update-routes
task: Update routes
2 parents 8bb8ed2 + 285735d commit 5fe40f4

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

routes/api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
Route::controller(UserController::class)->group(function () {
1616
Route::post('users', 'create');
17-
Route::put('users/{id}', 'update');
18-
Route::delete('users/{id}', 'delete');
19-
Route::get('users/{id}', 'get');
17+
Route::put('users/{id}', 'update')->whereNumber('id');
18+
Route::delete('users/{id}', 'delete')->whereNumber('id');
19+
Route::get('users/{id}', 'get')->whereNumber('id');
2020
Route::get('users', 'search');
2121
Route::get('profile', 'profile');
2222
Route::put('profile', 'updateProfile');

tests/UserTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,27 @@ public function testGet()
260260
$this->assertEqualsFixture('get_user', $response->json());
261261
}
262262

263+
public function testGetIdParamAsString()
264+
{
265+
$response = $this->actingAs(self::$admin)->json('get', '/users/test');
266+
267+
$response->assertNotFound();
268+
}
269+
270+
public function testPutIdParamAsString()
271+
{
272+
$response = $this->actingAs(self::$admin)->json('put', '/users/test');
273+
274+
$response->assertNotFound();
275+
}
276+
277+
public function testDeleteIdParamAsString()
278+
{
279+
$response = $this->actingAs(self::$admin)->json('delete', '/users/test');
280+
281+
$response->assertNotFound();
282+
}
283+
263284
public function testGetNotExists()
264285
{
265286
$response = $this->actingAs(self::$admin)->json('get', '/users/0');

0 commit comments

Comments
 (0)