Skip to content

Commit

Permalink
refactor: endpoint resources in plural
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorTurraF committed Feb 3, 2024
1 parent 3a549d1 commit 2c80fbd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]);
6 changes: 3 additions & 3 deletions tests/Feature/OrderControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -65,7 +65,7 @@ public function testListAllOrdersEndpoint()
->toArray();

// Act
$response = $this->getJson('/api/order');
$response = $this->getJson('/api/orders');

// Assert
$response
Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/SellerControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2c80fbd

Please sign in to comment.