diff --git a/tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php b/tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php index 1cc802f9a..120e7e435 100644 --- a/tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php +++ b/tests/PHPUnit/WcGateway/Gateway/WcGatewayTest.php @@ -46,7 +46,10 @@ class WcGatewayTest extends TestCase ->with($orderId) ->andReturn($wcOrder); + global $woocommerce; + $woocommerce = Mockery::mock(\WooCommerce::class); $result = $testee->process_payment($orderId); + unset($woocommerce); $this->assertIsArray($result); $this->assertEquals('success', $result['result']); $this->assertEquals($result['redirect'], $wcOrder); @@ -72,7 +75,10 @@ class WcGatewayTest extends TestCase ->with($orderId) ->andReturn(false); + global $woocommerce; + $woocommerce = Mockery::mock(\WooCommerce::class); $this->assertNull($testee->process_payment($orderId)); + unset($woocommerce); } @@ -106,7 +112,10 @@ class WcGatewayTest extends TestCase expect('wc_add_notice') ->with($lastError); + global $woocommerce; + $woocommerce = Mockery::mock(\WooCommerce::class); $result = $testee->process_payment($orderId); + unset($woocommerce); $this->assertNull($result); } diff --git a/tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php b/tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php index 2699661a6..b66c4377c 100644 --- a/tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php +++ b/tests/PHPUnit/WcGateway/Processor/OrderProcessorTest.php @@ -13,6 +13,7 @@ use Inpsyde\PayPalCommerce\ApiClient\Repository\CartRepository; use Inpsyde\PayPalCommerce\Session\SessionHandler; use Inpsyde\PayPalCommerce\TestCase; use Inpsyde\PayPalCommerce\WcGateway\Gateway\WcGateway; +use Inpsyde\Woocommerce\Logging\WoocommerceLoggingModule; use Mockery; class OrderProcessorTest extends TestCase @@ -75,7 +76,8 @@ class OrderProcessorTest extends TestCase $cart = Mockery::mock(\WC_Cart::class); $cart ->expects('empty_cart'); - $woocommerce = (object) ['cart' => $cart]; + $woocommerce = Mockery::mock(\WooCommerce::class); + $woocommerce->cart = $cart; $wcOrder ->expects('update_meta_data') @@ -158,7 +160,8 @@ class OrderProcessorTest extends TestCase $cart = Mockery::mock(\WC_Cart::class); $cart ->expects('empty_cart'); - $woocommerce = (object) ['cart' => $cart]; + $woocommerce = Mockery::mock(\WooCommerce::class); + $woocommerce->cart = $cart; $wcOrder ->expects('update_meta_data') @@ -218,7 +221,8 @@ class OrderProcessorTest extends TestCase ); $cart = Mockery::mock(\WC_Cart::class); - $woocommerce = (object) ['cart' => $cart]; + $woocommerce = Mockery::mock(\WooCommerce::class); + $woocommerce->cart = $cart; $wcOrder ->expects('update_meta_data')