Skip to content

Commit 7b38684

Browse files
committed
test: fix route names for testing
1 parent 489df85 commit 7b38684

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

routes/api_v1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
// User Routes
1616
Route::middleware(['auth:sanctum', 'ability:access-api'])->group(function () {
17-
Route::get('/me', \App\Http\Controllers\Api\V1\User\MeController::class);
17+
Route::get('/me', \App\Http\Controllers\Api\V1\User\MeController::class)->name('api.v1.me');
1818
Route::put('/profile', \App\Http\Controllers\Api\V1\User\UpdateProfileController::class)->name('api.v1.user.profile.update');
1919

2020
Route::post('/auth/logout', \App\Http\Controllers\Api\V1\Auth\LogoutController::class)->name('api.v1.auth.logout');

tests/Feature/API/V1/Article/ShowArticleControllerTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@
7373
});
7474

7575
it('returns 404 when article not found by slug', function () {
76-
$response = $this->getJson('/api/v1/articles/non-existent-slug');
77-
7876
$response = $this->getJson(route('api.v1.articles.show', ['slug' => 'non-existent-slug']));
7977
$response->assertStatus(404)
8078
->assertJson([

tests/Feature/API/V1/Category/GetCategoriesControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
it('can get all categories', function () {
99
Category::factory()->count(3)->create();
1010

11-
$response = $this->getJson('/api/v1/categories');
11+
$response = $this->getJson(route('api.v1.categories.index'));
1212

1313
$response->assertStatus(200)
1414
->assertJson(['status' => true])
@@ -32,7 +32,7 @@
3232
->andThrow(new Exception('fail'));
3333
});
3434

35-
$response = $this->getJson('/api/v1/categories');
35+
$response = $this->getJson(route('api.v1.categories.index'));
3636

3737
$response->assertStatus(500)
3838
->assertJson(['status' => false])

tests/Feature/API/V1/Tag/GetTagsControllerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
it('can get all tags', function () {
99
Tag::factory()->count(4)->create();
1010

11-
$response = $this->getJson('/api/v1/tags');
11+
$response = $this->getJson(route('api.v1.tags.index'));
1212

1313
$response->assertStatus(200)
1414
->assertJson(['status' => true])
@@ -32,7 +32,7 @@
3232
->andThrow(new Exception('fail'));
3333
});
3434

35-
$response = $this->getJson('/api/v1/tags');
35+
$response = $this->getJson(route('api.v1.tags.index'));
3636

3737
$response->assertStatus(500)
3838
->assertJson(['status' => false])

tests/Feature/API/V1/User/MeControllerTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
Sanctum::actingAs($user, ['access-api']);
1818

1919
// Make request to /me endpoint
20-
$response = $this->getJson('/api/v1/me');
20+
$response = $this->getJson(route('api.v1.me'));
2121

2222
// Assert response structure
2323
$response
@@ -51,7 +51,7 @@
5151

5252
it('returns 401 when not authenticated', function () {
5353
// Make request without authentication
54-
$response = $this->getJson('/api/v1/me');
54+
$response = $this->getJson(route('api.v1.me'));
5555

5656
// Assert unauthorized response
5757
$response->assertStatus(401);
@@ -68,7 +68,7 @@
6868
Sanctum::actingAs($user, ['read']);
6969

7070
// Make request to /me endpoint
71-
$response = $this->getJson('/api/v1/me');
71+
$response = $this->getJson(route('api.v1.me'));
7272

7373
// Assert unauthorized response
7474
$response->assertStatus(401);
@@ -92,7 +92,7 @@
9292
Sanctum::actingAs($user, ['access-api']);
9393

9494
// Make request to /me endpoint
95-
$response = $this->getJson('/api/v1/me');
95+
$response = $this->getJson(route('api.v1.me'));
9696

9797
// Assert response structure and content
9898
$response
@@ -132,7 +132,7 @@
132132
Sanctum::actingAs($user, ['access-api']);
133133

134134
// Make request to /me endpoint
135-
$response = $this->getJson('/api/v1/me');
135+
$response = $this->getJson(route('api.v1.me'));
136136

137137
// Assert response structure and content
138138
$response
@@ -166,7 +166,7 @@
166166
Sanctum::actingAs($user, ['access-api']);
167167

168168
// Make request to /me endpoint
169-
$response = $this->getJson('/api/v1/me');
169+
$response = $this->getJson(route('api.v1.me'));
170170

171171
// Assert response includes email verification
172172
$response
@@ -194,7 +194,7 @@
194194
Sanctum::actingAs($user, ['access-api']);
195195

196196
// Make request to /me endpoint
197-
$response = $this->getJson('/api/v1/me');
197+
$response = $this->getJson(route('api.v1.me'));
198198

199199
// Assert response includes null email verification
200200
$response
@@ -223,7 +223,7 @@
223223
Sanctum::actingAs($user, ['access-api']);
224224

225225
// Make request to /me endpoint
226-
$response = $this->getJson('/api/v1/me');
226+
$response = $this->getJson(route('api.v1.me'));
227227

228228
// Assert response includes long bio
229229
$response
@@ -250,7 +250,7 @@
250250
Sanctum::actingAs($user, ['access-api']);
251251

252252
// Make request to /me endpoint
253-
$response = $this->getJson('/api/v1/me');
253+
$response = $this->getJson(route('api.v1.me'));
254254

255255
// Assert response handles special characters
256256
$response
@@ -277,7 +277,7 @@
277277
Sanctum::actingAs($user, ['access-api']);
278278

279279
// Make request to /me endpoint
280-
$response = $this->getJson('/api/v1/me');
280+
$response = $this->getJson(route('api.v1.me'));
281281

282282
// Assert response handles long email
283283
$response
@@ -309,7 +309,7 @@
309309
Sanctum::actingAs($user, ['access-api']);
310310

311311
// Make request to /me endpoint
312-
$response = $this->getJson('/api/v1/me');
312+
$response = $this->getJson(route('api.v1.me'));
313313

314314
// Assert response structure
315315
$response
@@ -353,7 +353,7 @@
353353
Sanctum::actingAs($user, ['access-api']);
354354

355355
// Make request to /me endpoint
356-
$response = $this->getJson('/api/v1/me');
356+
$response = $this->getJson(route('api.v1.me'));
357357

358358
// Assert response includes banned status
359359
$response
@@ -380,7 +380,7 @@
380380
Sanctum::actingAs($user, ['access-api']);
381381

382382
// Make request to /me endpoint
383-
$response = $this->getJson('/api/v1/me');
383+
$response = $this->getJson(route('api.v1.me'));
384384

385385
// Assert response includes blocked status
386386
$response

0 commit comments

Comments
 (0)