From 1c50400989fd37aa2330fdb8bfc06c13c09225cb Mon Sep 17 00:00:00 2001 From: David Stone Date: Thu, 9 Jul 2026 04:31:28 -0600 Subject: [PATCH] wip: cover checkout pre-flight persistence --- tests/WP_Ultimo/Checkout/Checkout_Test.php | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/WP_Ultimo/Checkout/Checkout_Test.php b/tests/WP_Ultimo/Checkout/Checkout_Test.php index 79cc9d38..98db5486 100644 --- a/tests/WP_Ultimo/Checkout/Checkout_Test.php +++ b/tests/WP_Ultimo/Checkout/Checkout_Test.php @@ -603,6 +603,51 @@ public function test_persist_current_step_to_session_saves_account_fields(): voi ); } + /** + * Test pre-flight persistence stores filtered fields under pre_selected. + */ + public function test_persist_current_step_to_session_handles_pre_flight(): void { + + $checkout = Checkout::get_instance(); + $reflection = new \ReflectionClass($checkout); + + $this->ensure_session($checkout); + + $session_prop = $this->get_session_prop($reflection); + $session = $session_prop->getValue($checkout); + + $session->set('signup', []); + + $_POST['pre-flight'] = '1'; + $_POST['email_address'] = 'pre-flight@example.com'; + $_POST['checkout_action'] = 'wu_checkout'; + $_POST['_wpnonce'] = 'nonce'; + + $method = $reflection->getMethod('persist_current_step_to_session'); + + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } + + $saved = $method->invoke($checkout); + $signup = $session->get('signup'); + + $this->assertArrayNotHasKey('pre-flight', $saved); + $this->assertArrayNotHasKey('checkout_action', $saved); + $this->assertArrayNotHasKey('_wpnonce', $saved); + $this->assertSame('pre-flight@example.com', $saved['email_address']); + $this->assertSame('pre-flight@example.com', $signup['pre_selected']['email_address']); + + $session->set('signup', []); + + unset( + $_POST['pre-flight'], + $_POST['email_address'], + $_POST['checkout_action'], + $_POST['_wpnonce'] + ); + } + // ------------------------------------------------------------------------- // Step navigation — is_first_step // -------------------------------------------------------------------------