Merge pull request #1953 from woocommerce/PCP-461-error-when-adding-changing-subscription-payment-method-to-pay-pal-dcc-while-no-vault-token-exists

WC Subscriptions change subscription payment
This commit is contained in:
Emili Castells 2024-01-12 12:05:04 +01:00 committed by GitHub
commit be3d58e3de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 380 additions and 149 deletions

View file

@ -68,24 +68,6 @@ class VaultedCreditCardHandlerTest extends TestCase
);
}
public function testHandlePaymentChangingPayment()
{
$_POST['woocommerce_change_payment'] = 1;
$wcOrder = Mockery::mock(\WC_Order::class);
$wcOrder->shouldReceive('get_id')->andReturn(1);
$wcOrder->shouldReceive('update_meta_data')
->with('payment_token_id', 'abc123')
->andReturn(1);
$wcOrder->shouldReceive('save')->andReturn(1);
$this->subscriptionHelper->shouldReceive('has_subscription')->andReturn(true);
$this->subscriptionHelper->shouldReceive('is_subscription_change_payment')->andReturn(true);
$customer = Mockery::mock(WC_Customer::class);
$result = $this->testee->handle_payment('abc123', $wcOrder, $customer);
$this->assertInstanceOf(\WC_Order::class, $result);
}
public function testHandlePayment()
{
$_POST['woocommerce_change_payment'] = null;

View file

@ -109,6 +109,8 @@ class CreditCardGatewayTest extends TestCase
$session->shouldReceive('set')->andReturn([]);
$session->shouldReceive('get')->andReturn('');
when('is_checkout')->justReturn(true);
$savedCreditCard = 'abc123';
$_POST['saved_credit_card'] = $savedCreditCard;