Skip to content

GH#1508: test: stabilize checkout regressions#1523

Merged
superdav42 merged 3 commits into
mainfrom
fix/issue-1508-checkout-regressions
Jun 22, 2026
Merged

GH#1508: test: stabilize checkout regressions#1523
superdav42 merged 3 commits into
mainfrom
fix/issue-1508-checkout-regressions

Conversation

@superdav42

@superdav42 superdav42 commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Suppresses the verify-email notice for paid checkout payments while preserving the pending-email notice for free flows.
  • Normalizes wu_multiple_memberships_enabled() to return a boolean.
  • Stabilizes checkout regression tests with unique addon/discount fixtures, request superglobal coverage, and a deterministic no-tax assertion.

Files

  • inc/checkout/class-checkout-pages.php
  • inc/functions/checkout.php
  • tests/WP_Ultimo/Checkout/Cart_Addon_Pricing_Test.php
  • tests/WP_Ultimo/Checkout/Cart_Test.php
  • tests/WP_Ultimo/Checkout/Signup_Fields/Base_Signup_Field_Test.php

Verification

  • vendor/bin/phpunit --filter 'test_addon_only_charges_for_addon_product|test_tax_breakthrough_empty_when_no_taxes|test_add_verify_email_notice_silent_when_paid|test_get_value_uses_request_when_from_request_is_set|test_multiple_memberships_enabled|test_multiple_memberships_enabled_returns_bool'
  • vendor/bin/phpunit --filter Cart_Addon_Pricing_Test
  • vendor/bin/phpcs inc/checkout/class-checkout-pages.php inc/functions/checkout.php tests/WP_Ultimo/Checkout/Cart_Addon_Pricing_Test.php
  • git diff --check

Resolves #1508


aidevops.sh v3.21.12 plugin for OpenCode v1.17.9 with gpt-5.5 spent 44m and 445,618 tokens on this with the user in an interactive session.

Summary by CodeRabbit

  • Bug Fixes
    • Email verification notices are now shown only when the transaction total is zero, reducing unnecessary interruptions during normal checkout.
    • Improved checkout settings handling by ensuring the multiple-memberships toggle is interpreted consistently as a boolean.
  • Tests
    • Updated checkout pricing and cart tests to use randomized fixtures for better isolation, added clearer error assertions, and added cleanup to prevent cross-test contamination.
    • Strengthened tax-related assertions to explicitly verify empty tax breakdowns when taxes are disabled.
  • Chores
    • Refined signup field test setup/cleanup to cover both request and post input sources.

@superdav42 superdav42 added status:in-review PR open, awaiting review/merge origin:interactive Created by interactive user session labels Jun 22, 2026
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7dd72c32-078d-42bb-9187-a0e90fb512db

📥 Commits

Reviewing files that changed from the base of the PR and between ccfaefe and 68f45a7.

📒 Files selected for processing (1)
  • tests/WP_Ultimo/Checkout/Cart_Addon_Pricing_Test.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/WP_Ultimo/Checkout/Cart_Addon_Pricing_Test.php

📝 Walkthrough

Walkthrough

Two production-side fixes address failing type checks and a misfiring email-verification notice. Three test files are updated to eliminate shared discount-code fixtures, randomize product/customer slugs, tighten tax-breakdown and array assertions, and populate both $_POST and $_REQUEST in a signup-field test.

Changes

Checkout test stabilization and production fixes

Layer / File(s) Summary
Production: payment-gate email notice and bool cast
inc/checkout/class-checkout-pages.php, inc/functions/checkout.php
add_verify_email_notice() now returns early when the payment total is greater than 0.0, suppressing the verification notice for paid checkouts. wu_multiple_memberships_enabled() wraps its return value in an explicit (bool) cast.
Cart addon pricing: randomized fixtures and per-test discount code
tests/WP_Ultimo/Checkout/Cart_Addon_Pricing_Test.php
Removes the shared Discount_Code class property and its set_up_before_class creation; introduces a create_available_customer($suffix) helper that retries customer creation with randomized credentials; reworks set_up_before_class() to generate a random suffix for all fixture slugs and use the helper; adds assertNotWPError checks throughout fixture creation; moves discount-code creation, application, and assertion into test_addon_applies_existing_discount_code() with per-run random code values and post-assertion meta cleanup; randomizes addon and plan slugs in two other tests with assertNotWPError guards; updates tear_down_after_class() to conditionally delete each fixture.
Cart tax assertion and signup-field request superglobal fix
tests/WP_Ultimo/Checkout/Cart_Test.php, tests/WP_Ultimo/Checkout/Signup_Fields/Base_Signup_Field_Test.php
test_tax_breakthrough_empty_when_no_taxes replaces a loop-based zero-total check with assertSame([], ...). test_get_value_uses_request_when_from_request_is_set now sets and unsets my_request_field in both $_POST and $_REQUEST instead of only $_POST.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Ultimate-Multisite/ultimate-multisite#354: Introduced the addon-pricing cart behavior and the original shared discount-code fixture setup that this PR's Cart_Addon_Pricing_Test.php changes directly refactor.

Suggested labels

testing

🐇 A notice won't shout when payment's been paid,
The bool returns true (no longer mislaid),
Discount codes live where the test needs them most,
No shared fixture ghost — just the test as its host.
Each slug has a suffix, each run stands alone,
The suite is now stable, all regressions are gone! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the specific issue being addressed (GH#1508) and accurately reflects the main objective of stabilizing checkout test regressions.
Linked Issues check ✅ Passed The PR successfully addresses all six identified failures from issue #1508: discount code persistence via per-test fixture creation, tax-breakthrough assertions, verify-email notice suppression for paid checkouts, request superglobal coverage, and boolean return type normalization.
Out of Scope Changes check ✅ Passed All changes are directly aligned with resolving the specific failures documented in issue #1508; no unrelated modifications are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1508-checkout-regressions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/WP_Ultimo/Checkout/Cart_Addon_Pricing_Test.php`:
- Around line 288-290: The delete_meta() calls on self::$membership for
Membership::META_DISCOUNT_CODE and Membership::META_VERIFIED_PAYMENT_DISCOUNT
are removing the metadata, but these changes are not being persisted. Since the
test persisted the discount earlier via self::$membership->save(), the cleanup
must also be saved to ensure deterministic state and prevent cross-test
contamination. Add a call to self::$membership->save() after the delete_meta()
operations to persist the cleanup to storage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 820e62a1-cf4d-4f59-91e5-29dcde2868db

📥 Commits

Reviewing files that changed from the base of the PR and between 762003d and ccfaefe.

📒 Files selected for processing (5)
  • inc/checkout/class-checkout-pages.php
  • inc/functions/checkout.php
  • tests/WP_Ultimo/Checkout/Cart_Addon_Pricing_Test.php
  • tests/WP_Ultimo/Checkout/Cart_Test.php
  • tests/WP_Ultimo/Checkout/Signup_Fields/Base_Signup_Field_Test.php

Comment thread tests/WP_Ultimo/Checkout/Cart_Addon_Pricing_Test.php
@superdav42

Copy link
Copy Markdown
Collaborator Author

CLAIM_RELEASED reason=worker_complete runner=superdav42 ts=2026-06-22T19:47:29Z aidevops_version=3.21.12 opencode_version=1.17.9

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@github-actions

Copy link
Copy Markdown

🔨 Build Complete - Ready for Testing!

📦 Download Build Artifact (Recommended)

Download the zip build, upload to WordPress and test:

🌐 Test in WordPress Playground (Very Experimental)

Click the link below to instantly test this PR in your browser - no installation needed!
Playground support for multisite is very limitied, hopefully it will get better in the future.

🚀 Launch in Playground

Login credentials: admin / password

@superdav42 superdav42 merged commit 0c88178 into main Jun 22, 2026
8 of 11 checks passed
@superdav42 superdav42 deleted the fix/issue-1508-checkout-regressions branch June 22, 2026 23:28
@superdav42 superdav42 added the review-feedback-scanned Merged PR already scanned for quality feedback label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

origin:interactive Created by interactive user session review-feedback-scanned Merged PR already scanned for quality feedback status:in-review PR open, awaiting review/merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: stabilize checkout, cart, and checkout helper regressions

1 participant