fix tests

This commit is contained in:
David Remer 2020-08-25 14:55:06 +03:00
parent 607a247133
commit 7d490c6b7c
2 changed files with 29 additions and 4 deletions

View file

@ -160,6 +160,10 @@ class AuthorizedPaymentsProcessorTest extends TestCase
->shouldReceive('is') ->shouldReceive('is')
->with(AuthorizationStatus::CREATED) ->with(AuthorizationStatus::CREATED)
->andReturn(false); ->andReturn(false);
$authorizationStatus
->shouldReceive('is')
->with(AuthorizationStatus::PENDING)
->andReturn(false);
$authorization = Mockery::mock(Authorization::class); $authorization = Mockery::mock(Authorization::class);
$authorization $authorization
->shouldReceive('id') ->shouldReceive('id')

View file

@ -14,6 +14,7 @@ use Inpsyde\PayPalCommerce\Button\Helper\ThreeDSecure;
use Inpsyde\PayPalCommerce\Session\SessionHandler; use Inpsyde\PayPalCommerce\Session\SessionHandler;
use Inpsyde\PayPalCommerce\TestCase; use Inpsyde\PayPalCommerce\TestCase;
use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway; use Inpsyde\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use Inpsyde\PayPalCommerce\WcGateway\Settings\Settings;
use Inpsyde\Woocommerce\Logging\WoocommerceLoggingModule; use Inpsyde\Woocommerce\Logging\WoocommerceLoggingModule;
use Mockery; use Mockery;
@ -66,6 +67,11 @@ class OrderProcessorTest extends TestCase
->with($wcOrder, $currentOrder) ->with($wcOrder, $currentOrder)
->andReturn($currentOrder); ->andReturn($currentOrder);
$threeDSecure = Mockery::mock(ThreeDSecure::class); $threeDSecure = Mockery::mock(ThreeDSecure::class);
$authorizedPaymentProcessor = Mockery::mock(AuthorizedPaymentsProcessor::class);
$settings = Mockery::mock(Settings::class);
$settings
->shouldReceive('has')
->andReturnFalse();
$testee = new OrderProcessor( $testee = new OrderProcessor(
$sessionHandler, $sessionHandler,
@ -73,7 +79,9 @@ class OrderProcessorTest extends TestCase
$orderEndpoint, $orderEndpoint,
$paymentsEndpoint, $paymentsEndpoint,
$orderFactory, $orderFactory,
$threeDSecure $threeDSecure,
$authorizedPaymentProcessor,
$settings
); );
$cart = Mockery::mock(\WC_Cart::class); $cart = Mockery::mock(\WC_Cart::class);
@ -152,6 +160,11 @@ class OrderProcessorTest extends TestCase
->with($wcOrder, $currentOrder) ->with($wcOrder, $currentOrder)
->andReturn($currentOrder); ->andReturn($currentOrder);
$threeDSecure = Mockery::mock(ThreeDSecure::class); $threeDSecure = Mockery::mock(ThreeDSecure::class);
$authorizedPaymentProcessor = Mockery::mock(AuthorizedPaymentsProcessor::class);
$settings = Mockery::mock(Settings::class);
$settings
->shouldReceive('has')
->andReturnFalse();
$testee = new OrderProcessor( $testee = new OrderProcessor(
$sessionHandler, $sessionHandler,
@ -159,7 +172,9 @@ class OrderProcessorTest extends TestCase
$orderEndpoint, $orderEndpoint,
$paymentsEndpoint, $paymentsEndpoint,
$orderFactory, $orderFactory,
$threeDSecure $threeDSecure,
$authorizedPaymentProcessor,
$settings
); );
$cart = Mockery::mock(\WC_Cart::class); $cart = Mockery::mock(\WC_Cart::class);
@ -208,6 +223,9 @@ class OrderProcessorTest extends TestCase
$currentOrder $currentOrder
->shouldReceive('status') ->shouldReceive('status')
->andReturn($orderStatus); ->andReturn($orderStatus);
$currentOrder
->shouldReceive('paymentSource')
->andReturnNull();
$sessionHandler = Mockery::mock(SessionHandler::class); $sessionHandler = Mockery::mock(SessionHandler::class);
$sessionHandler $sessionHandler
->expects('order') ->expects('order')
@ -217,7 +235,8 @@ class OrderProcessorTest extends TestCase
$paymentsEndpoint = Mockery::mock(PaymentsEndpoint::class); $paymentsEndpoint = Mockery::mock(PaymentsEndpoint::class);
$orderFactory = Mockery::mock(OrderFactory::class); $orderFactory = Mockery::mock(OrderFactory::class);
$threeDSecure = Mockery::mock(ThreeDSecure::class); $threeDSecure = Mockery::mock(ThreeDSecure::class);
$threeDSecure->expects('proceedWithOrder')->andReturn(ThreeDSecure::REJECT); $authorizedPaymentProcessor = Mockery::mock(AuthorizedPaymentsProcessor::class);
$settings = Mockery::mock(Settings::class);
$testee = new OrderProcessor( $testee = new OrderProcessor(
$sessionHandler, $sessionHandler,
@ -225,7 +244,9 @@ class OrderProcessorTest extends TestCase
$orderEndpoint, $orderEndpoint,
$paymentsEndpoint, $paymentsEndpoint,
$orderFactory, $orderFactory,
$threeDSecure $threeDSecure,
$authorizedPaymentProcessor,
$settings
); );
$cart = Mockery::mock(\WC_Cart::class); $cart = Mockery::mock(\WC_Cart::class);