From 3f8ac59f4cfd812149c68aa65866891ec8b37e40 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 13 Aug 2024 15:31:16 -0700 Subject: [PATCH] Reference the entry in the components_assets table --- .../Checkins/Ui/ComponentCheckinTest.php | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/Feature/Checkins/Ui/ComponentCheckinTest.php b/tests/Feature/Checkins/Ui/ComponentCheckinTest.php index 1213d65252..06754d33c0 100644 --- a/tests/Feature/Checkins/Ui/ComponentCheckinTest.php +++ b/tests/Feature/Checkins/Ui/ComponentCheckinTest.php @@ -4,27 +4,35 @@ namespace Tests\Feature\Checkins\Ui; use App\Models\Component; use App\Models\User; +use Illuminate\Support\Facades\DB; use Tests\TestCase; class ComponentCheckinTest extends TestCase { public function testCheckingInComponentRequiresCorrectPermission() { + $component = Component::factory()->checkedOutToAsset()->create(); + + $componentAsset = DB::table('components_assets')->where('component_id', $component->id)->first(); + $this->actingAs(User::factory()->create()) ->post(route('components.checkin.store', [ - 'componentID' => Component::factory()->checkedOutToAsset()->create()->id, + 'componentID' => $componentAsset->id, ])) ->assertForbidden(); } - public function testComponentCheckinPagePostIsRedirectedIfRedirectSelectionIsIndex() { $component = Component::factory()->checkedOutToAsset()->create(); + $componentAsset = DB::table('components_assets')->where('component_id', $component->id)->first(); + $this->actingAs(User::factory()->admin()->create()) ->from(route('components.index')) - ->post(route('components.checkin.store', $component), [ + ->post(route('components.checkin.store', [ + 'componentID' => $componentAsset->id, + ]), [ 'redirect_option' => 'index', 'checkin_qty' => 1, ]) @@ -36,9 +44,13 @@ class ComponentCheckinTest extends TestCase { $component = Component::factory()->checkedOutToAsset()->create(); + $componentAsset = DB::table('components_assets')->where('component_id', $component->id)->first(); + $this->actingAs(User::factory()->admin()->create()) ->from(route('components.index')) - ->post(route('components.checkin.store', $component), [ + ->post(route('components.checkin.store', [ + 'componentID' => $componentAsset->id, + ]), [ 'redirect_option' => 'item', 'checkin_qty' => 1, ]) @@ -46,6 +58,4 @@ class ComponentCheckinTest extends TestCase ->assertSessionHasNoErrors() ->assertRedirect(route('components.show', ['component' => $component->id])); } - - }