Fix phpunit

This commit is contained in:
Emili Castells Guasch 2023-09-18 10:41:51 +02:00
parent 14d102015d
commit c39b03bcc9
2 changed files with 21 additions and 0 deletions

View file

@ -78,6 +78,12 @@ class CreditCardGatewayTest extends TestCase
$wc_order = Mockery::mock(WC_Order::class);
when('wc_get_order')->justReturn($wc_order);
$woocommerce = Mockery::mock(\WooCommerce::class);
$session = Mockery::mock(\WC_Session::class);
when('WC')->justReturn($woocommerce);
$woocommerce->session = $session;
$session->shouldReceive('set')->andReturn([]);
$this->orderProcessor->shouldReceive('process')
->with($wc_order)
->andReturn(true);
@ -95,6 +101,12 @@ class CreditCardGatewayTest extends TestCase
$wc_order->shouldReceive('get_customer_id')->andReturn(1);
when('wc_get_order')->justReturn($wc_order);
$woocommerce = Mockery::mock(\WooCommerce::class);
$session = Mockery::mock(\WC_Session::class);
when('WC')->justReturn($woocommerce);
$woocommerce->session = $session;
$session->shouldReceive('set')->andReturn([]);
$savedCreditCard = 'abc123';
$_POST['saved_credit_card'] = $savedCreditCard;

View file

@ -147,9 +147,11 @@ class WcGatewayTest extends TestCase
when('WC')->justReturn($woocommerce);
$woocommerce->cart = $cart;
$cart->shouldReceive('empty_cart');
$session = Mockery::mock(\WC_Session::class);
$woocommerce->session = $session;
$session->shouldReceive('get');
$session->shouldReceive('set');
$result = $testee->process_payment($orderId);
@ -164,6 +166,12 @@ class WcGatewayTest extends TestCase
$testee = $this->createGateway();
$woocommerce = Mockery::mock(\WooCommerce::class);
$session = Mockery::mock(\WC_Session::class);
when('WC')->justReturn($woocommerce);
$woocommerce->session = $session;
$session->shouldReceive('set')->andReturn([]);
expect('wc_get_order')
->with($orderId)
->andReturn(false);
@ -227,6 +235,7 @@ class WcGatewayTest extends TestCase
$session = Mockery::mock(\WC_Session::class);
$woocommerce->session = $session;
$session->shouldReceive('get');
$session->shouldReceive('set');
$result = $testee->process_payment($orderId);