From 8edcc1d72e1c7e5ffcc3ed53fa47faf046860212 Mon Sep 17 00:00:00 2001 From: Robert Kujawa Date: Sun, 9 Jun 2024 14:43:48 -0600 Subject: [PATCH] Reformat DisputeModelTest --- tests/Unit/Config/DisputeModelTest.php | 13 +++++++++++ tests/Unit/Database/DisputeModelTest.php | 13 +++++++++++ ...puteModelTest.php => TestDisputeModel.php} | 23 ++++++++++++++----- 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 tests/Unit/Config/DisputeModelTest.php create mode 100644 tests/Unit/Database/DisputeModelTest.php rename tests/Unit/{DisputeModelTest.php => TestDisputeModel.php} (52%) diff --git a/tests/Unit/Config/DisputeModelTest.php b/tests/Unit/Config/DisputeModelTest.php new file mode 100644 index 0000000..4ff732b --- /dev/null +++ b/tests/Unit/Config/DisputeModelTest.php @@ -0,0 +1,13 @@ +create(); + $usingServiceables = [ + 'provider_id' => $this->createProvider($this->checkoutService)->getId(), + 'account_id' => $this->createAccount($this->checkoutService)->getID(), + ]; + + $disputeWithPayment = Dispute::factory()->for(Payment::factory()->create($usingServiceables))->create(); $this->assertInstanceOf(Payment::class, $disputeWithPayment->payment); ServiceConfig::set('checkout', 'models.' . Payment::class, TestPayment::class); - $disputeWithOverriddenPayment = Dispute::factory()->create(); + $disputeWithOverriddenPayment = Dispute::factory()->for(Payment::factory()->create($usingServiceables))->create(); $this->assertInstanceOf(TestPayment::class, $disputeWithOverriddenPayment->payment); } #[Test] public function retrieve_dispute_transaction_events() { - $dispute = Dispute::factory()->create(); + $usingServiceables = [ + 'provider_id' => $this->createProvider($this->checkoutService)->getId(), + 'account_id' => $this->createAccount($this->checkoutService)->getID(), + ]; + + $dispute = Dispute::factory()->for(Payment::factory()->create($usingServiceables))->create(); $this->assertEmpty($dispute->transactionEvents); - $disputeWith2TransactionEvents = Dispute::factory()->hasTransactionEvents(2)->create(); + $disputeWith2TransactionEvents = Dispute::factory()->for($paymentForDisputeWith2TransactionEvents = Payment::factory()->create($usingServiceables))->hasTransactionEvents(2, ['payment_id' => $paymentForDisputeWith2TransactionEvents->id])->create(); $this->assertCount(2, $disputeWith2TransactionEvents->transactionEvents); $this->assertContainsOnlyInstancesOf(TransactionEvent::class, $disputeWith2TransactionEvents->transactionEvents); ServiceConfig::set('checkout', 'models.' . TransactionEvent::class, TestTransactionEvent::class); - $disputeWith3OverriddenTransactionEvents = Dispute::factory()->hasTransactionEvents(3)->create(); + $disputeWith3OverriddenTransactionEvents = Dispute::factory()->for($paymentForDisputeWith3TransactionEvents = Payment::factory()->create($usingServiceables))->hasTransactionEvents(3, ['payment_id' => $paymentForDisputeWith3TransactionEvents->id])->create(); $this->assertCount(3, $disputeWith3OverriddenTransactionEvents->transactionEvents); $this->assertContainsOnlyInstancesOf(TestTransactionEvent::class, $disputeWith3OverriddenTransactionEvents->transactionEvents); }