From 2c80fbd8146e1ac35fa55acae309e805138a1494 Mon Sep 17 00:00:00 2001 From: Victor Turra Date: Sat, 3 Feb 2024 13:33:17 -0300 Subject: [PATCH] refactor: endpoint resources in plural --- routes/api.php | 4 ++-- tests/Feature/OrderControllerTest.php | 6 +++--- tests/Feature/SellerControllerTest.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/routes/api.php b/routes/api.php index 81a4f06..d41eab2 100644 --- a/routes/api.php +++ b/routes/api.php @@ -21,12 +21,12 @@ return $request->user(); }); -Route::apiResource('seller', SellerController::class)->only([ +Route::apiResource('sellers', SellerController::class)->only([ 'index', 'store', ]); -Route::apiResource('order', OrderController::class)->only([ +Route::apiResource('orders', OrderController::class)->only([ 'index', 'store' ]); diff --git a/tests/Feature/OrderControllerTest.php b/tests/Feature/OrderControllerTest.php index 192d5e7..4555218 100644 --- a/tests/Feature/OrderControllerTest.php +++ b/tests/Feature/OrderControllerTest.php @@ -26,8 +26,8 @@ public function testCreateOrderEndpoint() // Add other attributes as needed ]; - // Send a POST request to the /api/order endpoint - $response = $this->postJson('/api/order', $orderData); + // Send a POST request to the /api/orders endpoint + $response = $this->postJson('/api/orders', $orderData); // Assert that the response has a status code of 201 Created // and contains the expected JSON structure @@ -65,7 +65,7 @@ public function testListAllOrdersEndpoint() ->toArray(); // Act - $response = $this->getJson('/api/order'); + $response = $this->getJson('/api/orders'); // Assert $response diff --git a/tests/Feature/SellerControllerTest.php b/tests/Feature/SellerControllerTest.php index c02cf55..7012a17 100644 --- a/tests/Feature/SellerControllerTest.php +++ b/tests/Feature/SellerControllerTest.php @@ -20,7 +20,7 @@ public function testIndexEndpointListsAllSellers() $seller3 = Seller::factory()->create(); // Send a GET request to the /api/sellers endpoint - $response = $this->getJson('/api/seller'); + $response = $this->getJson('/api/sellers'); // Assert that the response has a status code of 200 OK // and contains the expected JSON structure with the sellers' data @@ -55,7 +55,7 @@ public function testStoreEndpointCreatesSeller() 'email' => $this->faker->unique()->safeEmail, ]; - $response = $this->postJson('/api/seller', $sellerData); + $response = $this->postJson('/api/sellers', $sellerData); $response ->assertStatus(201) @@ -84,7 +84,7 @@ public function testStoreEndpointNotCreateIfSellerAlreadyExists() Seller::create($sellerData); // Attempt to create another seller with the same email - $response = $this->postJson('/api/seller', $sellerData); + $response = $this->postJson('/api/sellers', $sellerData); // Assert that the response status is 400 Bad Request // and contains the expected error message