Skip to content

Commit

Permalink
Add test for reset()
Browse files Browse the repository at this point in the history
  • Loading branch information
r-kujawa committed Apr 28, 2023
1 parent 96f6da0 commit 8856202
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/Unit/TestPaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.');
Expand All @@ -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 */
Expand All @@ -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 */
Expand All @@ -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()
{
Expand Down

0 comments on commit 8856202

Please sign in to comment.