mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge trunk (WIP)
This commit is contained in:
commit
e36d77fad2
25 changed files with 1052 additions and 195 deletions
|
@ -8,6 +8,7 @@ use Requests_Utility_CaseInsensitiveDictionary;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ApplicationContext;
|
||||
use Woocommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\CaptureStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PatchCollection;
|
||||
|
@ -288,7 +289,7 @@ class OrderEndpointTest extends TestCase
|
|||
$expectedOrder->shouldReceive('purchase_units')->once()->andReturn(['0'=>$purchaseUnit]);
|
||||
$purchaseUnit->shouldReceive('payments')->once()->andReturn($payment);
|
||||
$payment->shouldReceive('captures')->once()->andReturn(['0'=>$capture]);
|
||||
$capture->shouldReceive('status')->once()->andReturn('');
|
||||
$capture->shouldReceive('status')->once()->andReturn(new CaptureStatus(CaptureStatus::COMPLETED));
|
||||
|
||||
$result = $testee->capture($orderToCapture);
|
||||
$this->assertEquals($expectedOrder, $result);
|
||||
|
|
|
@ -8,10 +8,12 @@ use Psr\Log\NullLogger;
|
|||
use Requests_Utility_CaseInsensitiveDictionary;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Authorization;
|
||||
use Woocommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\ErrorResponseCollection;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Token;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\AuthorizationFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\CaptureFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\ErrorResponseCollectionFactory;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\TestCase;
|
||||
use Mockery;
|
||||
|
@ -21,7 +23,22 @@ use function Brain\Monkey\Functions\expect;
|
|||
|
||||
class PaymentsEndpointTest extends TestCase
|
||||
{
|
||||
public function testAuthorizationDefault()
|
||||
private $authorizationFactory;
|
||||
private $captureFactory;
|
||||
|
||||
private $logger;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->authorizationFactory = Mockery::mock(AuthorizationFactory::class);
|
||||
$this->captureFactory = Mockery::mock(CaptureFactory::class);
|
||||
|
||||
$this->logger = new NullLogger();
|
||||
}
|
||||
|
||||
public function testAuthorizationDefault()
|
||||
{
|
||||
expect('wp_json_encode')->andReturnUsing('json_encode');
|
||||
$host = 'https://example.com/';
|
||||
|
@ -35,15 +52,10 @@ class PaymentsEndpointTest extends TestCase
|
|||
->expects('bearer')->andReturn($token);
|
||||
|
||||
$authorization = Mockery::mock(Authorization::class);
|
||||
$authorizationFactory = Mockery::mock(AuthorizationFactory::class);
|
||||
$authorizationFactory
|
||||
$this->authorizationFactory
|
||||
->expects('from_paypal_response')
|
||||
->andReturn($authorization);
|
||||
|
||||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$rawResponse = [
|
||||
|
@ -54,8 +66,9 @@ class PaymentsEndpointTest extends TestCase
|
|||
$testee = new PaymentsEndpoint(
|
||||
$host,
|
||||
$bearer,
|
||||
$authorizationFactory,
|
||||
$logger
|
||||
$this->authorizationFactory,
|
||||
$this->captureFactory,
|
||||
$this->logger
|
||||
);
|
||||
|
||||
expect('wp_remote_get')->andReturnUsing(
|
||||
|
@ -92,12 +105,6 @@ class PaymentsEndpointTest extends TestCase
|
|||
$bearer = Mockery::mock(Bearer::class);
|
||||
$bearer->expects('bearer')->andReturn($token);
|
||||
|
||||
$authorizationFactory = Mockery::mock(AuthorizationFactory::class);
|
||||
|
||||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$rawResponse = [
|
||||
|
@ -108,8 +115,9 @@ class PaymentsEndpointTest extends TestCase
|
|||
$testee = new PaymentsEndpoint(
|
||||
$host,
|
||||
$bearer,
|
||||
$authorizationFactory,
|
||||
$logger
|
||||
$this->authorizationFactory,
|
||||
$this->captureFactory,
|
||||
$this->logger
|
||||
);
|
||||
|
||||
expect('wp_remote_get')->andReturn($rawResponse);
|
||||
|
@ -131,8 +139,6 @@ class PaymentsEndpointTest extends TestCase
|
|||
$bearer = Mockery::mock(Bearer::class);
|
||||
$bearer->expects('bearer')->andReturn($token);
|
||||
|
||||
$authorizationFactory = Mockery::mock(AuthorizationFactory::class);
|
||||
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$rawResponse = [
|
||||
|
@ -140,15 +146,12 @@ class PaymentsEndpointTest extends TestCase
|
|||
'headers' => $headers,
|
||||
];
|
||||
|
||||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
|
||||
$testee = new PaymentsEndpoint(
|
||||
$host,
|
||||
$bearer,
|
||||
$authorizationFactory,
|
||||
$logger
|
||||
$this->authorizationFactory,
|
||||
$this->captureFactory,
|
||||
$this->logger
|
||||
);
|
||||
|
||||
expect('wp_remote_get')->andReturn($rawResponse);
|
||||
|
@ -172,16 +175,10 @@ class PaymentsEndpointTest extends TestCase
|
|||
$bearer
|
||||
->expects('bearer')->andReturn($token);
|
||||
|
||||
$authorization = Mockery::mock(Authorization::class);
|
||||
$authorizationFactory = Mockery::mock(AuthorizationFactory::class);
|
||||
$authorizationFactory
|
||||
$capture = Mockery::mock(Capture::class);
|
||||
$this->captureFactory
|
||||
->expects('from_paypal_response')
|
||||
->andReturn($authorization);
|
||||
|
||||
|
||||
$logger = Mockery::mock(LoggerInterface::class);
|
||||
$logger->shouldNotReceive('log');
|
||||
$logger->shouldReceive('debug');
|
||||
->andReturn($capture);
|
||||
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
|
@ -193,8 +190,9 @@ class PaymentsEndpointTest extends TestCase
|
|||
$testee = new PaymentsEndpoint(
|
||||
$host,
|
||||
$bearer,
|
||||
$authorizationFactory,
|
||||
$logger
|
||||
$this->authorizationFactory,
|
||||
$this->captureFactory,
|
||||
$this->logger
|
||||
);
|
||||
|
||||
expect('wp_remote_get')->andReturnUsing(
|
||||
|
@ -219,7 +217,7 @@ class PaymentsEndpointTest extends TestCase
|
|||
expect('wp_remote_retrieve_response_code')->with($rawResponse)->andReturn(201);
|
||||
|
||||
$result = $testee->capture($authorizationId);
|
||||
$this->assertEquals($authorization, $result);
|
||||
$this->assertEquals($capture, $result);
|
||||
}
|
||||
|
||||
public function testCaptureIsWpError()
|
||||
|
@ -234,8 +232,6 @@ class PaymentsEndpointTest extends TestCase
|
|||
$bearer = Mockery::mock(Bearer::class);
|
||||
$bearer->expects('bearer')->andReturn($token);
|
||||
|
||||
$authorizationFactory = Mockery::mock(AuthorizationFactory::class);
|
||||
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$rawResponse = [
|
||||
|
@ -246,8 +242,9 @@ class PaymentsEndpointTest extends TestCase
|
|||
$testee = new PaymentsEndpoint(
|
||||
$host,
|
||||
$bearer,
|
||||
$authorizationFactory,
|
||||
new NullLogger()
|
||||
$this->authorizationFactory,
|
||||
$this->captureFactory,
|
||||
$this->logger
|
||||
);
|
||||
|
||||
expect('wp_remote_get')->andReturn($rawResponse);
|
||||
|
@ -269,8 +266,6 @@ class PaymentsEndpointTest extends TestCase
|
|||
$bearer = Mockery::mock(Bearer::class);
|
||||
$bearer->expects('bearer')->andReturn($token);
|
||||
|
||||
$authorizationFactory = Mockery::mock(AuthorizationFactory::class);
|
||||
|
||||
$headers = Mockery::mock(Requests_Utility_CaseInsensitiveDictionary::class);
|
||||
$headers->shouldReceive('getAll');
|
||||
$rawResponse = [
|
||||
|
@ -281,8 +276,9 @@ class PaymentsEndpointTest extends TestCase
|
|||
$testee = new PaymentsEndpoint(
|
||||
$host,
|
||||
$bearer,
|
||||
$authorizationFactory,
|
||||
new NullLogger()
|
||||
$this->authorizationFactory,
|
||||
$this->captureFactory,
|
||||
$this->logger
|
||||
);
|
||||
|
||||
expect('wp_remote_get')->andReturn($rawResponse);
|
||||
|
|
|
@ -8,6 +8,9 @@ use Psr\Container\ContainerInterface;
|
|||
use Psr\Log\LoggerInterface;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint;
|
||||
use Woocommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\CaptureStatus;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\State;
|
||||
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
||||
|
@ -25,8 +28,15 @@ use function Brain\Monkey\Functions\when;
|
|||
|
||||
class WcGatewayTest extends TestCase
|
||||
{
|
||||
private $environment;
|
||||
|
||||
public function testProcessPaymentSuccess() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->environment = Mockery::mock(Environment::class);
|
||||
}
|
||||
|
||||
public function testProcessPaymentSuccess() {
|
||||
expect('is_admin')->andReturn(false);
|
||||
|
||||
$orderId = 1;
|
||||
|
@ -83,6 +93,7 @@ class WcGatewayTest extends TestCase
|
|||
$transactionUrlProvider,
|
||||
$subscriptionHelper,
|
||||
PayPalGateway::ID,
|
||||
$this->environment,
|
||||
$paymentTokenRepository,
|
||||
$logger,
|
||||
$paymentsEndpoint,
|
||||
|
@ -141,6 +152,7 @@ class WcGatewayTest extends TestCase
|
|||
$transactionUrlProvider,
|
||||
$subscriptionHelper,
|
||||
PayPalGateway::ID,
|
||||
$this->environment,
|
||||
$paymentTokenRepository,
|
||||
$logger,
|
||||
$paymentsEndpoint,
|
||||
|
@ -216,10 +228,12 @@ class WcGatewayTest extends TestCase
|
|||
$transactionUrlProvider,
|
||||
$subscriptionHelper,
|
||||
PayPalGateway::ID,
|
||||
$this->environment,
|
||||
$paymentTokenRepository,
|
||||
$logger,
|
||||
$paymentsEndpoint,
|
||||
$orderEndpoint
|
||||
$orderEndpoint,
|
||||
PayPalGateway::ID
|
||||
);
|
||||
|
||||
expect('wc_get_order')
|
||||
|
@ -258,11 +272,18 @@ class WcGatewayTest extends TestCase
|
|||
->expects('save');
|
||||
$settingsRenderer = Mockery::mock(SettingsRenderer::class);
|
||||
$orderProcessor = Mockery::mock(OrderProcessor::class);
|
||||
$capture = Mockery::mock(Capture::class);
|
||||
$capture
|
||||
->shouldReceive('status')
|
||||
->andReturn(new CaptureStatus(CaptureStatus::COMPLETED));
|
||||
$authorizedPaymentsProcessor = Mockery::mock(AuthorizedPaymentsProcessor::class);
|
||||
$authorizedPaymentsProcessor
|
||||
->expects('process')
|
||||
->with($wcOrder)
|
||||
->andReturn(AuthorizedPaymentsProcessor::SUCCESSFUL);
|
||||
$authorizedPaymentsProcessor
|
||||
->expects('captures')
|
||||
->andReturn([$capture]);
|
||||
$authorizedOrderActionNotice = Mockery::mock(AuthorizeOrderActionNotice::class);
|
||||
$authorizedOrderActionNotice
|
||||
->expects('display_message')
|
||||
|
@ -296,6 +317,7 @@ class WcGatewayTest extends TestCase
|
|||
$transactionUrlProvider,
|
||||
$subscriptionHelper,
|
||||
PayPalGateway::ID,
|
||||
$this->environment,
|
||||
$paymentTokenRepository,
|
||||
$logger,
|
||||
$paymentsEndpoint,
|
||||
|
@ -360,6 +382,7 @@ class WcGatewayTest extends TestCase
|
|||
$transactionUrlProvider,
|
||||
$subscriptionHelper,
|
||||
PayPalGateway::ID,
|
||||
$this->environment,
|
||||
$paymentTokenRepository,
|
||||
$logger,
|
||||
$paymentsEndpoint,
|
||||
|
@ -386,6 +409,9 @@ class WcGatewayTest extends TestCase
|
|||
->expects('process')
|
||||
->with($wcOrder)
|
||||
->andReturn($lastStatus);
|
||||
$authorizedPaymentsProcessor
|
||||
->expects('captures')
|
||||
->andReturn([]);
|
||||
$authorizedOrderActionNotice = Mockery::mock(AuthorizeOrderActionNotice::class);
|
||||
$authorizedOrderActionNotice
|
||||
->expects('display_message')
|
||||
|
@ -418,6 +444,7 @@ class WcGatewayTest extends TestCase
|
|||
$transactionUrlProvider,
|
||||
$subscriptionHelper,
|
||||
PayPalGateway::ID,
|
||||
$this->environment,
|
||||
$paymentTokenRepository,
|
||||
$logger,
|
||||
$paymentsEndpoint,
|
||||
|
@ -467,6 +494,7 @@ class WcGatewayTest extends TestCase
|
|||
$transactionUrlProvider,
|
||||
$subscriptionHelper,
|
||||
PayPalGateway::ID,
|
||||
$this->environment,
|
||||
$paymentTokenRepository,
|
||||
$logger,
|
||||
$paymentsEndpoint,
|
||||
|
|
|
@ -10,6 +10,8 @@ use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
|||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PaymentsEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Authorization;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\AuthorizationStatus;
|
||||
use Woocommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\CaptureStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payments;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
|
@ -57,7 +59,7 @@ class AuthorizedPaymentsProcessorTest extends TestCase
|
|||
$this->paymentsEndpoint
|
||||
->expects('capture')
|
||||
->with($this->authorizationId)
|
||||
->andReturn($this->createAuthorization($this->authorizationId, AuthorizationStatus::CAPTURED));
|
||||
->andReturn($this->createCapture(CaptureStatus::COMPLETED));
|
||||
|
||||
$this->assertEquals(AuthorizedPaymentsProcessor::SUCCESSFUL, $this->testee->process($this->wcOrder));
|
||||
}
|
||||
|
@ -78,7 +80,7 @@ class AuthorizedPaymentsProcessorTest extends TestCase
|
|||
$this->paymentsEndpoint
|
||||
->expects('capture')
|
||||
->with($authorization->id())
|
||||
->andReturn($this->createAuthorization($authorization->id(), AuthorizationStatus::CAPTURED));
|
||||
->andReturn($this->createCapture(CaptureStatus::COMPLETED));
|
||||
}
|
||||
|
||||
$this->assertEquals(AuthorizedPaymentsProcessor::SUCCESSFUL, $this->testee->process($this->wcOrder));
|
||||
|
@ -143,6 +145,14 @@ class AuthorizedPaymentsProcessorTest extends TestCase
|
|||
return $authorization;
|
||||
}
|
||||
|
||||
private function createCapture(string $status): Capture {
|
||||
$capture = Mockery::mock(Capture::class);
|
||||
$capture
|
||||
->shouldReceive('status')
|
||||
->andReturn(new CaptureStatus($status));
|
||||
return $capture;
|
||||
}
|
||||
|
||||
private function createPaypalOrder(array $authorizations): Order {
|
||||
$payments = Mockery::mock(Payments::class);
|
||||
$payments
|
||||
|
|
|
@ -4,15 +4,20 @@ declare(strict_types=1);
|
|||
namespace WooCommerce\PayPalCommerce\WcGateway\Processor;
|
||||
|
||||
|
||||
use Dhii\Container\Dictionary;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Authorization;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\AuthorizationStatus;
|
||||
use Woocommerce\PayPalCommerce\ApiClient\Entity\Capture;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\CaptureStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Order;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\Payments;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Entity\PurchaseUnit;
|
||||
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
||||
use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure;
|
||||
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||||
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
||||
use WooCommerce\PayPalCommerce\TestCase;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
|
@ -22,35 +27,44 @@ use function Brain\Monkey\Functions\when;
|
|||
|
||||
class OrderProcessorTest extends TestCase
|
||||
{
|
||||
private $environment;
|
||||
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->environment = new Environment(new Dictionary([]));
|
||||
}
|
||||
|
||||
public function testAuthorize() {
|
||||
$transactionId = 'ABC123';
|
||||
|
||||
$capture = Mockery::mock(Capture::class);
|
||||
$capture->expects('id')
|
||||
$authorization = Mockery::mock(Authorization::class);
|
||||
$authorization->shouldReceive('id')
|
||||
->andReturn($transactionId);
|
||||
$authorization->shouldReceive('status')
|
||||
->andReturn(new AuthorizationStatus(AuthorizationStatus::CREATED));
|
||||
|
||||
$payments = Mockery::mock(Payments::class);
|
||||
$payments->expects('captures')
|
||||
->andReturn([$capture]);
|
||||
$payments->shouldReceive('authorizations')
|
||||
->andReturn([$authorization]);
|
||||
$payments->shouldReceive('captures')
|
||||
->andReturn([]);
|
||||
|
||||
$purchaseUnit = Mockery::mock(PurchaseUnit::class);
|
||||
$purchaseUnit->expects('payments')
|
||||
$purchaseUnit->shouldReceive('payments')
|
||||
->andReturn($payments);
|
||||
|
||||
$wcOrder = Mockery::mock(\WC_Order::class);
|
||||
$wcOrder->expects('update_meta_data')
|
||||
->with(PayPalGateway::ORDER_PAYMENT_MODE_META_KEY, 'live');
|
||||
$wcOrder->expects('set_transaction_id')
|
||||
->with($transactionId);
|
||||
|
||||
$orderStatus = Mockery::mock(OrderStatus::class);
|
||||
$orderStatus
|
||||
->expects('is')
|
||||
->shouldReceive('is')
|
||||
->with(OrderStatus::APPROVED)
|
||||
->andReturn(true);
|
||||
$orderStatus
|
||||
->expects('is')
|
||||
->shouldReceive('is')
|
||||
->with(OrderStatus::COMPLETED)
|
||||
->andReturn(true);
|
||||
|
||||
|
@ -67,7 +81,7 @@ class OrderProcessorTest extends TestCase
|
|||
$currentOrder
|
||||
->shouldReceive('status')
|
||||
->andReturn($orderStatus);
|
||||
$currentOrder->expects('purchase_units')
|
||||
$currentOrder->shouldReceive('purchase_units')
|
||||
->andReturn([$purchaseUnit]);
|
||||
|
||||
$sessionHandler = Mockery::mock(SessionHandler::class);
|
||||
|
@ -112,7 +126,7 @@ class OrderProcessorTest extends TestCase
|
|||
$authorizedPaymentProcessor,
|
||||
$settings,
|
||||
$logger,
|
||||
false
|
||||
$this->environment
|
||||
);
|
||||
|
||||
$cart = Mockery::mock(\WC_Cart::class);
|
||||
|
@ -156,23 +170,25 @@ class OrderProcessorTest extends TestCase
|
|||
$capture = Mockery::mock(Capture::class);
|
||||
$capture->expects('id')
|
||||
->andReturn($transactionId);
|
||||
$capture->expects('status')
|
||||
->andReturn(new CaptureStatus(CaptureStatus::COMPLETED));
|
||||
|
||||
$payments = Mockery::mock(Payments::class);
|
||||
$payments->expects('captures')
|
||||
$payments->shouldReceive('captures')
|
||||
->andReturn([$capture]);
|
||||
|
||||
$purchaseUnit = Mockery::mock(PurchaseUnit::class);
|
||||
$purchaseUnit->expects('payments')
|
||||
$purchaseUnit->shouldReceive('payments')
|
||||
->andReturn($payments);
|
||||
|
||||
$wcOrder = Mockery::mock(\WC_Order::class);
|
||||
$orderStatus = Mockery::mock(OrderStatus::class);
|
||||
$orderStatus
|
||||
->expects('is')
|
||||
->shouldReceive('is')
|
||||
->with(OrderStatus::APPROVED)
|
||||
->andReturn(true);
|
||||
$orderStatus
|
||||
->expects('is')
|
||||
->shouldReceive('is')
|
||||
->with(OrderStatus::COMPLETED)
|
||||
->andReturn(true);
|
||||
$orderId = 'abc';
|
||||
|
@ -188,7 +204,7 @@ class OrderProcessorTest extends TestCase
|
|||
->shouldReceive('status')
|
||||
->andReturn($orderStatus);
|
||||
$currentOrder
|
||||
->expects('purchase_units')
|
||||
->shouldReceive('purchase_units')
|
||||
->andReturn([$purchaseUnit]);
|
||||
$sessionHandler = Mockery::mock(SessionHandler::class);
|
||||
$sessionHandler
|
||||
|
@ -240,7 +256,7 @@ class OrderProcessorTest extends TestCase
|
|||
$authorizedPaymentProcessor,
|
||||
$settings,
|
||||
$logger,
|
||||
false
|
||||
$this->environment
|
||||
);
|
||||
|
||||
$cart = Mockery::mock(\WC_Cart::class);
|
||||
|
@ -264,9 +280,6 @@ class OrderProcessorTest extends TestCase
|
|||
PayPalGateway::INTENT_META_KEY,
|
||||
$orderIntent
|
||||
);
|
||||
$wcOrder
|
||||
->expects('update_status')
|
||||
->with('on-hold', 'Awaiting payment.');
|
||||
$wcOrder->expects('update_meta_data')
|
||||
->with(PayPalGateway::ORDER_PAYMENT_MODE_META_KEY, 'live');
|
||||
$wcOrder->expects('set_transaction_id')
|
||||
|
@ -340,7 +353,7 @@ class OrderProcessorTest extends TestCase
|
|||
$authorizedPaymentProcessor,
|
||||
$settings,
|
||||
$logger,
|
||||
false
|
||||
$this->environment
|
||||
);
|
||||
|
||||
$wcOrder
|
||||
|
@ -355,7 +368,7 @@ class OrderProcessorTest extends TestCase
|
|||
PayPalGateway::INTENT_META_KEY,
|
||||
$orderIntent
|
||||
);
|
||||
|
||||
|
||||
$this->assertFalse($testee->process($wcOrder));
|
||||
$this->assertNotEmpty($testee->last_error());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue