From 63426a67f3f31a4d5e3b19a2d1873bd5c5bb6424 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Mon, 18 Aug 2025 17:13:37 +0200 Subject: [PATCH] Fix phpunit --- .../Button/Endpoint/ChangeCartEndpointTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/PHPUnit/Button/Endpoint/ChangeCartEndpointTest.php b/tests/PHPUnit/Button/Endpoint/ChangeCartEndpointTest.php index dbff4d5c3..09cf055fb 100644 --- a/tests/PHPUnit/Button/Endpoint/ChangeCartEndpointTest.php +++ b/tests/PHPUnit/Button/Endpoint/ChangeCartEndpointTest.php @@ -84,6 +84,18 @@ class ChangeCartEndpointTest extends TestCase ->with(ChangeCartEndpoint::nonce()) ->andReturn($data); + // Mock WC session for shipping data preservation + $session = Mockery::mock(\WC_Session::class); + $session->shouldReceive('get') + ->with('chosen_shipping_methods') + ->andReturn(null); + $session->shouldReceive('set') + ->with('chosen_shipping_methods', Mockery::any()); + + $wc = Mockery::mock(); + $wc->session = $session; + expect('WC')->andReturn($wc); + $pu = Mockery::mock(PurchaseUnit::class); $pu ->shouldReceive('to_array')