From 985714d50487c14e900eb2d290a628160588fc4b Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 18 Jul 2024 05:04:17 +0100 Subject: [PATCH] Test passing now - I hope Signed-off-by: snipe --- .../Feature/Checkouts/Ui/AccessoryCheckoutTest.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php b/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php index 9845baf36a..e0af379db0 100644 --- a/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php @@ -22,6 +22,7 @@ class AccessoryCheckoutTest extends TestCase { $accessory = Accessory::factory()->create(); $response = $this->actingAs(User::factory()->superuser()->create()) + ->from(route('accessories.checkout.show', $accessory)) ->post(route('accessories.checkout.store', $accessory), [ // missing assigned_to ]) @@ -32,17 +33,19 @@ class AccessoryCheckoutTest extends TestCase $this->followRedirects($response)->assertSee(trans('general.error')); } - public function testAccessoryMustBeAvailableWhenCheckingOut() + public function testAccessoryMustHaveAvailableItemsForCheckoutWhenCheckingOut() { + $accessory = Accessory::factory()->withoutItemsRemaining()->create(); $response = $this->actingAs(User::factory()->viewAccessories()->checkoutAccessories()->create()) - ->post(route('accessories.checkout.store', Accessory::factory()->withoutItemsRemaining()->create()), [ + ->from(route('accessories.checkout.show', $accessory)) + ->post(route('accessories.checkout.store', $accessory), [ 'assigned_to' => User::factory()->create()->id, ]) ->assertStatus(302) - ->assertSessionHas('error') - ->assertRedirect(route('accessories.index')); - + ->assertSessionHas('errors') + ->assertRedirect(route('accessories.checkout.store', $accessory)); + $response->assertInvalid(['checkout_qty']); $this->followRedirects($response)->assertSee(trans('general.error')); } @@ -71,7 +74,6 @@ class AccessoryCheckoutTest extends TestCase public function testAccessoryCanBeCheckedOutWithQuantity() { - //$this->withoutExceptionHandling(); $accessory = Accessory::factory()->create(['qty'=>5]); $user = User::factory()->create();