From 3a4db97e2132013f481a5aedb9d7140379b693f1 Mon Sep 17 00:00:00 2001 From: Robert Kujawa Date: Fri, 28 Apr 2023 08:32:19 -0600 Subject: [PATCH] Add test for `reset()` --- tests/Unit/TestPaymentGateway.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/Unit/TestPaymentGateway.php b/tests/Unit/TestPaymentGateway.php index 18852e3..cc20f1a 100644 --- a/tests/Unit/TestPaymentGateway.php +++ b/tests/Unit/TestPaymentGateway.php @@ -8,7 +8,9 @@ use Payavel\Checkout\Models\PaymentTransaction; use Payavel\Checkout\Models\Wallet; use Payavel\Checkout\PaymentResponse; +use Payavel\Checkout\Tests\AlternativePaymentResponse; use Payavel\Checkout\Tests\GatewayTestCase; +use Payavel\Checkout\Tests\TestPaymentResponse; use Payavel\Checkout\Tests\User; class TestPaymentGateway extends GatewayTestCase @@ -24,7 +26,7 @@ public function set_provider_and_merchant_fluently() /** @test */ public function setting_invalid_driver_throws_exception() { - config(['payment.defaults.driver' => 'fake']); + config(['payment.defaults.driver' => 'invalid']); $this->expectException(Exception::class); $this->expectExceptionMessage('Invalid checkout driver provided.'); @@ -38,7 +40,7 @@ public function setting_invalid_provider_throws_exception() $this->expectException(Exception::class); $this->expectExceptionMessage('Invalid checkout provider.'); - Payment::setProvider('fake'); + Payment::setProvider('invalid'); } /** @test */ @@ -47,7 +49,7 @@ public function setting_invalid_merchant_throws_exception() $this->expectException(Exception::class); $this->expectExceptionMessage('Invalid checkout merchant.'); - Payment::setMerchant('faker'); + Payment::setMerchant('invalid'); } /** @test */ @@ -60,6 +62,18 @@ public function setting_incompatible_merchant_provider_throws_exception() Payment::authorize([]); } + /** @test */ + public function resetting_payment_service_to_default_configuration() + { + Payment::provider('alternative')->merchant('alternate'); + + $this->assertEquals(AlternativePaymentResponse::class, get_class(Payment::authorize([]))); + + Payment::reset(); + + $this->assertEquals(TestPaymentResponse::class, get_class(Payment::authorize([]))); + } + /** @test */ public function payment_service_throws_exception_when_test_mode_gateway_does_not_exist() {