A free open source IT asset/license management system
Remove legacy checks from test
Marcus Moore48ba7eed3e17
diff --git a/tests/Feature/CheckoutAcceptances/Ui/AccessoryAcceptanceTest.php b/tests/Feature/CheckoutAcceptances/Ui/AccessoryAcceptanceTest.phpindex c94af12664..cacfd55515 100644--- a/tests/Feature/CheckoutAcceptances/Ui/AccessoryAcceptanceTest.php+++ b/tests/Feature/CheckoutAcceptances/Ui/AccessoryAcceptanceTest.php@@ -103,51 +103,21 @@ class AccessoryAcceptanceTest extends TestCase*/public function test_all_accessory_checkouts_are_removed_when_user_declines_acceptance(){- // $this->markTestIncomplete();-$user = User::factory()->create();$this->actingAs(User::factory()->checkoutAccessories()->create());// create accessory that requires acceptance- $accessoryA = Accessory::factory()->requiringAcceptance()->create(['qty' => 4]);- $accessoryB = Accessory::factory()->requiringAcceptance()->create(['qty' => 4]);-- // check out the accessory to a user with qty of 2 using the legacy behavior: `checkout_acceptances.qty` is null- $this->post(route('accessories.checkout.store', $accessoryA), [- 'assigned_user' => $user->id,- 'checkout_qty' => 2,- ]);-- $this->assertEquals(2, AccessoryCheckout::where([- 'accessory_id' => $accessoryA->id,- 'assigned_to' => $user->id,- 'assigned_type' => User::class,- ])->count());-- $legacyCheckoutAcceptance = CheckoutAcceptance::query()- ->where([- 'assigned_to_id' => $user->id,- 'qty' => 2,- ])- ->whereNull(['accepted_at', 'declined_at'])- ->whereHasMorph(- 'checkoutable',- [Accessory::class],- )- ->sole();-- $legacyCheckoutAcceptance->qty = null;- $legacyCheckoutAcceptance->save();+ $accessory = Accessory::factory()->requiringAcceptance()->create(['qty' => 5]);// check out the accessory to a user with qty of 2 using the new behavior: `checkout_acceptances.qty` is 2- $this->post(route('accessories.checkout.store', $accessoryB), [+ $this->post(route('accessories.checkout.store', $accessory), ['assigned_user' => $user->id,- 'checkout_qty' => 2,+ 'checkout_qty' => 3,]);- $this->assertEquals(2, AccessoryCheckout::where([- 'accessory_id' => $accessoryB->id,+ $this->assertEquals(3, AccessoryCheckout::where([+ 'accessory_id' => $accessory->id,'assigned_to' => $user->id,'assigned_type' => User::class,])->count());@@ -157,30 +127,26 @@ class AccessoryAcceptanceTest extends TestCase$checkoutAcceptance = CheckoutAcceptance::query()->where(['assigned_to_id' => $user->id,- 'qty' => 2,+ 'qty' => 3,])- ->whereNull(['accepted_at', 'declined_at'])+ ->whereNull('accepted_at')+ ->whereNull('declined_at')->whereHasMorph('checkoutable',[Accessory::class],)->sole();- // decline the "legacy" checkout- $this->actingAs($user);-- $this->post(route('account.store-acceptance', $legacyCheckoutAcceptance), [- 'asset_acceptance' => 'declined',- ]);-// decline the checkout- $this->post(route('account.store-acceptance', $checkoutAcceptance), [- 'asset_acceptance' => 'declined',- ]);+ $this->actingAs($user)+ ->post(route('account.store-acceptance', $checkoutAcceptance), [+ 'asset_acceptance' => 'declined',+ ]);// four rows from `accessories_checkout` should be removed- $this->assertEquals($originalAccessoryCheckoutCount - 4, AccessoryCheckout::count());+ $this->assertEquals($originalAccessoryCheckoutCount - 3, AccessoryCheckout::count());+ // @todo:// ensure existing checkouts for the user are not affected.// in other words, make sure the removal of rows from `accessories_checkout` is not too eager, especially around legacy behavior.// ie...if a user accepted previous accessories then those should not be touched.