From 2b5463475c955359d12b0037ce4f6e206388008a Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 11 Jul 2024 15:25:26 +0100 Subject: [PATCH] Added test Signed-off-by: snipe --- .../Consumables/Api/ConsumableIndexTest.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/Feature/Consumables/Api/ConsumableIndexTest.php b/tests/Feature/Consumables/Api/ConsumableIndexTest.php index b16dfdfa5..f1d3ad7f0 100644 --- a/tests/Feature/Consumables/Api/ConsumableIndexTest.php +++ b/tests/Feature/Consumables/Api/ConsumableIndexTest.php @@ -54,4 +54,29 @@ class ConsumableIndexTest extends TestCase ->assertResponseDoesNotContainInRows($consumableA) ->assertResponseContainsInRows($consumableB); } + + public function testConsumableIndexReturnsExpectedSearchResults() + { + Consumable::factory()->count(10)->create(); + Consumable::factory()->count(1)->create(['name' => 'My Test Consumable']); + + $this->actingAsForApi(User::factory()->superuser()->create()) + ->getJson( + route('api.consumables.index', [ + 'search' => 'My Test Consumable', + 'sort' => 'name', + 'order' => 'asc', + 'offset' => '0', + 'limit' => '20', + ])) + ->assertOk() + ->assertJsonStructure([ + 'total', + 'rows', + ]) + ->assertJson([ + 'total' => 1, + ]); + + } }