From 329bff858c93bf279e214dbb297819a6db73491e Mon Sep 17 00:00:00 2001 From: Robert Kujawa Date: Thu, 27 Jun 2024 06:23:37 -0600 Subject: [PATCH] Use TestCase::$checkoutConfig in tests --- tests/Unit/Database/PaymentModelTest.php | 4 ++-- tests/Unit/Database/WalletModelTest.php | 4 ++-- tests/Unit/TestBillableTrait.php | 2 +- tests/Unit/TestDisputeModel.php | 4 ++-- tests/Unit/TestPaymentInstrumentModel.php | 6 +++--- tests/Unit/TestPaymentModel.php | 8 ++++---- tests/Unit/TestPaymentRailModel.php | 6 +++--- tests/Unit/TestPaymentTypeModel.php | 4 ++-- tests/Unit/TestRefundModel.php | 4 ++-- tests/Unit/TestTransactionEventModel.php | 4 ++-- tests/Unit/TestWalletModel.php | 2 +- 11 files changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/Unit/Database/PaymentModelTest.php b/tests/Unit/Database/PaymentModelTest.php index dc6c04a..2c684a5 100644 --- a/tests/Unit/Database/PaymentModelTest.php +++ b/tests/Unit/Database/PaymentModelTest.php @@ -29,7 +29,7 @@ public function retrieve_payment_provider() $paymentWithProvider = Payment::factory()->create($usingServiceables); $this->assertInstanceOf(Provider::class, $paymentWithProvider->provider); - ServiceConfig::find('checkout')->set('models.' . Provider::class, TestProvider::class); + $this->checkoutConfig->set('models.' . Provider::class, TestProvider::class); $paymentWithOverriddenProvider = Payment::factory()->create($usingServiceables); $this->assertInstanceOf(TestProvider::class, $paymentWithOverriddenProvider->provider); } @@ -45,7 +45,7 @@ public function retrieve_payment_account() $paymentWithAccount = Payment::factory()->create($usingServiceables); $this->assertInstanceOf(Account::class, $paymentWithAccount->account); - ServiceConfig::find('checkout')->set('models.' . Account::class, TestAccount::class); + $this->checkoutConfig->set('models.' . Account::class, TestAccount::class); $paymentWithOverriddenAccount = Payment::factory()->create($usingServiceables); $this->assertInstanceOf(TestAccount::class, $paymentWithOverriddenAccount->account); } diff --git a/tests/Unit/Database/WalletModelTest.php b/tests/Unit/Database/WalletModelTest.php index bbe2167..0313f76 100644 --- a/tests/Unit/Database/WalletModelTest.php +++ b/tests/Unit/Database/WalletModelTest.php @@ -29,7 +29,7 @@ public function retrieve_wallet_provider() $walletWithProvider = Wallet::factory()->create($usingServiceables); $this->assertInstanceOf(Provider::class, $walletWithProvider->provider); - ServiceConfig::find('checkout')->set('models.' . Provider::class, TestProvider::class); + $this->checkoutConfig->set('models.' . Provider::class, TestProvider::class); $walletWithOverriddenProvider = Wallet::factory()->create($usingServiceables); $this->assertInstanceOF(TestProvider::class, $walletWithOverriddenProvider->provider); } @@ -45,7 +45,7 @@ public function retrieve_wallet_account() $walletWithAccount = Wallet::factory()->create($usingServiceables); $this->assertInstanceOf(Account::class, $walletWithAccount->account); - ServiceConfig::find('checkout')->set('models.' . Account::class, TestAccount::class); + $this->checkoutConfig->set('models.' . Account::class, TestAccount::class); $walletWithOverriddenAccount = Wallet::factory()->create($usingServiceables); $this->assertInstanceOF(TestAccount::class, $walletWithOverriddenAccount->account); } diff --git a/tests/Unit/TestBillableTrait.php b/tests/Unit/TestBillableTrait.php index a7488b2..54087e8 100644 --- a/tests/Unit/TestBillableTrait.php +++ b/tests/Unit/TestBillableTrait.php @@ -25,7 +25,7 @@ public function retrieve_billable_wallets() $this->assertCount(2, $billableWith2Wallets->wallets); $this->assertContainsOnlyInstancesOf(Wallet::class, $billableWith2Wallets->wallets); - ServiceConfig::find('checkout')->set('models.'.Wallet::class, TestWallet::class); + $this->checkoutConfig->set('models.'.Wallet::class, TestWallet::class); $billableWith3OverriddenWallets = User::factory()->has(Wallet::factory()->count(3)->sequence(fn () => [ 'provider_id' => $this->createProvider($this->checkoutConfig)->getId(), 'account_id' => $this->createAccount($this->checkoutConfig)->getId(), diff --git a/tests/Unit/TestDisputeModel.php b/tests/Unit/TestDisputeModel.php index 6989d16..db2247c 100644 --- a/tests/Unit/TestDisputeModel.php +++ b/tests/Unit/TestDisputeModel.php @@ -25,7 +25,7 @@ public function retrieve_dispute_payment() $disputeWithPayment = Dispute::factory()->for(Payment::factory()->create($usingServiceables))->create(); $this->assertInstanceOf(Payment::class, $disputeWithPayment->payment); - ServiceConfig::find('checkout')->set('models.' . Payment::class, TestPayment::class); + $this->checkoutConfig->set('models.' . Payment::class, TestPayment::class); $disputeWithOverriddenPayment = Dispute::factory()->for(Payment::factory()->create($usingServiceables))->create(); $this->assertInstanceOf(TestPayment::class, $disputeWithOverriddenPayment->payment); } @@ -45,7 +45,7 @@ public function retrieve_dispute_transaction_events() $this->assertCount(2, $disputeWith2TransactionEvents->transactionEvents); $this->assertContainsOnlyInstancesOf(TransactionEvent::class, $disputeWith2TransactionEvents->transactionEvents); - ServiceConfig::find('checkout')->set('models.' . TransactionEvent::class, TestTransactionEvent::class); + $this->checkoutConfig->set('models.' . TransactionEvent::class, TestTransactionEvent::class); $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); diff --git a/tests/Unit/TestPaymentInstrumentModel.php b/tests/Unit/TestPaymentInstrumentModel.php index d2264b1..dace523 100644 --- a/tests/Unit/TestPaymentInstrumentModel.php +++ b/tests/Unit/TestPaymentInstrumentModel.php @@ -27,7 +27,7 @@ public function retrieve_payment_instrument_wallet() $paymentInstrumentWithWallet = PaymentInstrument::factory()->for($wallet)->create(); $this->assertInstanceOf(Wallet::class, $paymentInstrumentWithWallet->wallet); - ServiceConfig::find('checkout')->set('models.' . Wallet::class, TestWallet::class); + $this->checkoutConfig->set('models.' . Wallet::class, TestWallet::class); $paymentInstrumentWithOverriddenWallet = PaymentInstrument::factory()->for($wallet)->create(); $this->assertInstanceOf(TestWallet::class, $paymentInstrumentWithOverriddenWallet->wallet); } @@ -43,7 +43,7 @@ public function retrieve_payment_instrument_type() $paymentInstrumentWithType = PaymentInstrument::factory()->for($wallet)->create(); $this->assertInstanceOf(PaymentType::class, $paymentInstrumentWithType->type); - ServiceConfig::find('checkout')->set('models.' . PaymentType::class, TestPaymentType::class); + $this->checkoutConfig->set('models.' . PaymentType::class, TestPaymentType::class); $paymentInstrumentWithOverriddenType = PaymentInstrument::factory()->for($wallet)->create(); $this->assertInstanceOf(TestPaymentType::class, $paymentInstrumentWithOverriddenType->type); } @@ -63,7 +63,7 @@ public function retrieve_payment_instrument_payments() $this->assertCount(2, $paymentInstrumentWith2Payments->payments); $this->assertContainsOnlyInstancesOf(Payment::class, $paymentInstrumentWith2Payments->payments); - ServiceConfig::find('checkout')->set('models.' . Payment::class, TestPayment::class); + $this->checkoutConfig->set('models.' . Payment::class, TestPayment::class); $paymentInstrumentWith3OverriddenPayments = PaymentInstrument::factory()->for($wallet)->hasPayments(3)->create(); $this->assertCount(3, $paymentInstrumentWith3OverriddenPayments->payments); $this->assertContainsOnlyInstancesOf(TestPayment::class, $paymentInstrumentWith3OverriddenPayments->payments); diff --git a/tests/Unit/TestPaymentModel.php b/tests/Unit/TestPaymentModel.php index 5fc08b7..c5a863f 100644 --- a/tests/Unit/TestPaymentModel.php +++ b/tests/Unit/TestPaymentModel.php @@ -31,7 +31,7 @@ public function retrieve_payment_rail() $paymentWithRail = Payment::factory()->create($usingServiceables); $this->assertInstanceOf(PaymentRail::class, $paymentWithRail->rail); - ServiceConfig::find('checkout')->set('models.' . PaymentRail::class, TestPaymentRail::class); + $this->checkoutConfig->set('models.' . PaymentRail::class, TestPaymentRail::class); $paymentWithOverriddenRail = Payment::factory()->create($usingServiceables); $this->assertInstanceOf(TestPaymentRail::class, $paymentWithOverriddenRail->rail); } @@ -50,7 +50,7 @@ public function retrieve_payment_instrument() $paymentWithInstrument = Payment::factory()->for(PaymentInstrument::factory()->for(Wallet::factory()->create($usingServiceables))->create(), 'instrument')->create($usingServiceables); $this->assertInstanceOf(PaymentInstrument::class, $paymentWithInstrument->instrument); - ServiceConfig::find('checkout')->set('models.' . PaymentInstrument::class, TestPaymentInstrument::class); + $this->checkoutConfig->set('models.' . PaymentInstrument::class, TestPaymentInstrument::class); $paymentWithOverriddenInstrument = Payment::factory()->for(PaymentInstrument::factory()->for(Wallet::factory()->create($usingServiceables))->create(), 'instrument')->create($usingServiceables); $this->assertInstanceOf(TestPaymentInstrument::class, $paymentWithOverriddenInstrument->instrument); } @@ -70,7 +70,7 @@ public function retrieve_payment_events() $this->assertCount(2, $paymentWith2Events->events); $this->assertContainsOnlyInstancesOf(TransactionEvent::class, $paymentWith2Events->events); - ServiceConfig::find('checkout')->set('models.' . TransactionEvent::class, TestTransactionEvent::class); + $this->checkoutConfig->set('models.' . TransactionEvent::class, TestTransactionEvent::class); $paymentWith3OverriddenEvents = Payment::factory()->hasEvents(3, ['status_code' => CheckoutStatus::AUTHORIZED])->create($usingServiceables); $this->assertCount(3, $paymentWith3OverriddenEvents->events); $this->assertContainsOnlyInstancesOf(TestTransactionEvent::class, $paymentWith3OverriddenEvents->events); @@ -91,7 +91,7 @@ public function retrieve_payment_transaction_events() $this->assertCount(2, $paymentWith2TransactionEvents->transactionEvents); $this->assertContainsOnlyInstancesOf(TransactionEvent::class, $paymentWith2TransactionEvents->transactionEvents); - ServiceConfig::find('checkout')->set('models.' . TransactionEvent::class, TestTransactionEvent::class); + $this->checkoutConfig->set('models.' . TransactionEvent::class, TestTransactionEvent::class); $paymentWith3OverriddenTransactionEvents = Payment::factory()->hasTransactionEvents(3)->create($usingServiceables); $this->assertCount(3, $paymentWith3OverriddenTransactionEvents->transactionEvents); $this->assertContainsOnlyInstancesOf(TestTransactionEvent::class, $paymentWith3OverriddenTransactionEvents->transactionEvents); diff --git a/tests/Unit/TestPaymentRailModel.php b/tests/Unit/TestPaymentRailModel.php index 989748f..d9b2332 100644 --- a/tests/Unit/TestPaymentRailModel.php +++ b/tests/Unit/TestPaymentRailModel.php @@ -47,7 +47,7 @@ public function retrieve_payment_rail_parent_type() $paymentRail = PaymentRail::factory()->create(); $this->assertInstanceOf(PaymentType::class, $paymentRail->parentType); - ServiceConfig::find('checkout')->set('models.' . PaymentType::class, TestPaymentType::class); + $this->checkoutConfig->set('models.' . PaymentType::class, TestPaymentType::class); $paymentRailWithOverriddenParentType = PaymentRail::factory()->create(); $this->assertInstanceOf(TestPaymentType::class, $paymentRailWithOverriddenParentType->parentType); } @@ -58,7 +58,7 @@ public function retrieve_payment_rail_type() $paymentRail = PaymentRail::factory()->create(); $this->assertInstanceOf(PaymentType::class, $paymentRail->type); - ServiceConfig::find('checkout')->set('models.' . PaymentType::class, TestPaymentType::class); + $this->checkoutConfig->set('models.' . PaymentType::class, TestPaymentType::class); $paymentRailWithOverriddenType = PaymentRail::factory()->create(); $this->assertInstanceOf(TestPaymentType::class, $paymentRailWithOverriddenType->type); } @@ -78,7 +78,7 @@ public function retrieve_payment_rail_payments() $this->assertCount(2, $paymentRailWith2Payments->payments); $this->assertContainsOnlyInstancesOf(Payment::class, $paymentRailWith2Payments->payments); - ServiceConfig::find('checkout')->set('models.' . Payment::class, TestPayment::class); + $this->checkoutConfig->set('models.' . Payment::class, TestPayment::class); $paymentRailWith3OverriddenPayments = PaymentRail::factory()->hasPayments(3, $usingServiceables)->create(); $this->assertCount(3, $paymentRailWith3OverriddenPayments->payments); $this->assertContainsOnlyInstancesOf(TestPayment::class, $paymentRailWith3OverriddenPayments->payments); diff --git a/tests/Unit/TestPaymentTypeModel.php b/tests/Unit/TestPaymentTypeModel.php index 6d370c9..a575221 100644 --- a/tests/Unit/TestPaymentTypeModel.php +++ b/tests/Unit/TestPaymentTypeModel.php @@ -25,7 +25,7 @@ public function retrieve_payment_type_rails() $this->assertCount(2, $paymentTypeWith2Rails->rails); $this->assertContainsOnlyInstancesOf(PaymentRail::class, $paymentTypeWith2Rails->rails); - ServiceConfig::find('checkout')->set('models.' . PaymentRail::class, TestPaymentRail::class); + $this->checkoutConfig->set('models.' . PaymentRail::class, TestPaymentRail::class); $paymentTypeWith3OverriddenRails = PaymentType::factory()->hasRails(3)->create(); $this->assertCount(3, $paymentTypeWith3OverriddenRails->rails); $this->assertContainsOnlyInstancesOf(TestPaymentRail::class, $paymentTypeWith3OverriddenRails->rails); @@ -46,7 +46,7 @@ public function retrieve_payment_type_instruments() $this->assertCount(2, $paymentTypeWith2Instruments->instruments); $this->assertContainsOnlyInstancesOf(PaymentInstrument::class, $paymentTypeWith2Instruments->instruments); - ServiceConfig::find('checkout')->set('models.' . PaymentInstrument::class, TestPaymentInstrument::class); + $this->checkoutConfig->set('models.' . PaymentInstrument::class, TestPaymentInstrument::class); $paymentTypeWith3OverriddenInstruments = PaymentType::factory()->has(PaymentInstrument::factory()->count(3)->for($wallet), 'instruments')->create(); $this->assertCount(3, $paymentTypeWith3OverriddenInstruments->instruments); $this->assertContainsOnlyInstancesOf(TestPaymentInstrument::class, $paymentTypeWith3OverriddenInstruments->instruments); diff --git a/tests/Unit/TestRefundModel.php b/tests/Unit/TestRefundModel.php index 8388e7e..12ad7b5 100644 --- a/tests/Unit/TestRefundModel.php +++ b/tests/Unit/TestRefundModel.php @@ -25,7 +25,7 @@ public function retrieve_refund_payment() $refundWithPayment = Refund::factory()->for(Payment::factory()->create($usingServiceables))->create(); $this->assertInstanceOf(Payment::class, $refundWithPayment->payment); - ServiceConfig::find('checkout')->set('models.' . Payment::class, TestPayment::class); + $this->checkoutConfig->set('models.' . Payment::class, TestPayment::class); $refundWithOverriddenPayment = Refund::factory()->for(Payment::factory()->create($usingServiceables))->create(); $this->assertInstanceOf(TestPayment::class, $refundWithOverriddenPayment->payment); } @@ -45,7 +45,7 @@ public function retrieve_refund_transaction_events() $this->assertCount(2, $refundWith2TransactionEvents->transactionEvents); $this->assertContainsOnlyInstancesOf(TransactionEvent::class, $refundWith2TransactionEvents->transactionEvents); - ServiceConfig::find('checkout')->set('models.' . TransactionEvent::class, TestTransactionEvent::class); + $this->checkoutConfig->set('models.' . TransactionEvent::class, TestTransactionEvent::class); $refundWith3OverriddenTransactionEvents = Refund::factory()->for($paymentForRefundWith3TransactionEvents = Payment::factory()->create($usingServiceables))->hasTransactionEvents(3, ['payment_id' => $paymentForRefundWith3TransactionEvents->id])->create(); $this->assertCount(3, $refundWith3OverriddenTransactionEvents->transactionEvents); $this->assertContainsOnlyInstancesOf(TestTransactionEvent::class, $refundWith3OverriddenTransactionEvents->transactionEvents); diff --git a/tests/Unit/TestTransactionEventModel.php b/tests/Unit/TestTransactionEventModel.php index 26b4f18..66662b2 100644 --- a/tests/Unit/TestTransactionEventModel.php +++ b/tests/Unit/TestTransactionEventModel.php @@ -27,7 +27,7 @@ public function retrieve_transaction_event_payment() $transactionEventWithPayment = TransactionEvent::factory()->for(Payment::factory()->create($usingServiceables))->create(['status_code' => CheckoutStatus::AUTHORIZED]); $this->assertInstanceOf(Payment::class, $transactionEventWithPayment->payment); - ServiceConfig::find('checkout')->set('models.' . Payment::class, TestPayment::class); + $this->checkoutConfig->set('models.' . Payment::class, TestPayment::class); $transactionEventWithOverriddenPayment = TransactionEvent::factory()->for(Payment::factory()->create($usingServiceables))->create(['status_code' => CheckoutStatus::AUTHORIZED]); $this->assertInstanceOf(TestPayment::class, $transactionEventWithOverriddenPayment->payment); } @@ -46,7 +46,7 @@ public function retrieve_transaction_event_transactionable() $transactionEventWithTransactionable = TransactionEvent::factory()->for($paymentForTransactionEventWithTransactionable = Payment::factory()->create($usingServiceables))->for(Refund::factory()->for($paymentForTransactionEventWithTransactionable)->create(), 'transactionable')->create(['status_code' => CheckoutStatus::AUTHORIZED]); $this->assertInstanceOf(Refund::class, $transactionEventWithTransactionable->transactionable); - ServiceConfig::find('checkout')->set('models.' . Dispute::class, TestDispute::class); + $this->checkoutConfig->set('models.' . Dispute::class, TestDispute::class); $transactionEventWithOverriddenTransactionable = TransactionEvent::factory()->for($paymentForTransactionEventWithOverriddenTransactionable = Payment::factory()->create($usingServiceables))->create(['status_code' => CheckoutStatus::AUTHORIZED]); $transactionEventWithOverriddenTransactionable->transactionable()->associate(transform(Dispute::factory()->for($paymentForTransactionEventWithOverriddenTransactionable)->create(), fn ($dispute) => TestDispute::find($dispute->id))); $this->assertInstanceOf(TestDispute::class, $transactionEventWithOverriddenTransactionable->transactionable); diff --git a/tests/Unit/TestWalletModel.php b/tests/Unit/TestWalletModel.php index 1aa3e75..81d302f 100644 --- a/tests/Unit/TestWalletModel.php +++ b/tests/Unit/TestWalletModel.php @@ -47,7 +47,7 @@ public function retrieve_wallet_payment_instruments() $this->assertCount(2, $walletWith2PaymentInstruments->paymentInstruments); $this->assertContainsOnlyInstancesOf(PaymentInstrument::class, $walletWith2PaymentInstruments->paymentInstruments); - ServiceConfig::find('checkout')->set('models.' . PaymentInstrument::class, TestPaymentInstrument::class); + $this->checkoutConfig->set('models.' . PaymentInstrument::class, TestPaymentInstrument::class); $walletWith3OverriddenPaymentInstruments = Wallet::factory()->hasPaymentInstruments(3)->create($usingServiceables); $this->assertCount(3, $walletWith3OverriddenPaymentInstruments->paymentInstruments); $this->assertContainsOnlyInstancesOf(TestPaymentInstrument::class, $walletWith3OverriddenPaymentInstruments->paymentInstruments);