Skip to content

Add test-data CLI commands from the pmpro-cli POC - #73

Open
flintfromthebasement wants to merge 1 commit into
strangerstudios:devfrom
flintfromthebasement:feature/cli-test-data-commands
Open

Add test-data CLI commands from the pmpro-cli POC#73
flintfromthebasement wants to merge 1 commit into
strangerstudios:devfrom
flintfromthebasement:feature/cli-test-data-commands

Conversation

@flintfromthebasement

Copy link
Copy Markdown

What this does

Ports the dev/test-data commands from the strangerstudios/pmpro-cli POC repo into Toolkit's CLI, where dev-only tooling belongs. The general-purpose commands from that POC are landing in core via strangerstudios/paid-memberships-pro#3740 and #3748; with this PR merged, the POC repo can be archived.

New subcommands, registered under the existing wp pmpro-toolkit namespace and gated behind the same Enable CLI Commands Toolkit setting:

  • wp pmpro-toolkit bulk-add-users — generate test users, optionally with memberships/subscriptions, random past start dates, and a Siege login file (--for-siege).
  • wp pmpro-toolkit bulk-checkout-users — generate users and simulate checkouts through Toolkit's toolkit/v1/test-checkout REST endpoint (requires the Performance Endpoints setting at Read and Write).
  • wp pmpro-toolkit expire-memberships — rewrite expiration/next-payment dates to test expiry flows; --with_as triggers the Action Scheduler emails.
  • wp pmpro-toolkit payment-reminders — adjust next_payment_date and clear reminder meta to test recurring payment reminders.
  • wp pmpro-toolkit cleanup-actions — delete PMPro scheduled actions by hook/group/status/args.

Changes from the POC versions

  • Namespace pmpro_cli\corePMPro_Toolkit, text domain → pmpro-toolkit, examples updated to the pmpro-toolkit command namespace.
  • Fixed bulk-checkout-users' default endpoint from the stale tk/v1/test-checkout to toolkit/v1/test-checkout (Toolkit's actual REST namespace).
  • Dropped the stray inline WP_CLI::add_command() in the bulk-checkout file; all five register centrally in pmpro-toolkit.php behind the existing WP_CLI gate.
  • One class per command under cli/commands/, loaded only when CLI commands are enabled.

How to test

  1. Toolkit settings: enable CLI commands (and set Performance Endpoints to Read and Write for the checkout test).
  2. wp pmpro-toolkit bulk-add-users --count=3 --with-membership
  3. wp pmpro-toolkit expire-memberships --user_ids=<ids> --days=-1
  4. wp pmpro-toolkit payment-reminders --user_ids=<ids> --days=3
  5. wp pmpro-toolkit cleanup-actions
  6. wp pmpro-toolkit bulk-checkout-users --count=2

All five verified on a local seeded site (test data cleaned up after).

🤖 Generated with Claude Code

Ports bulk-add-users, bulk-checkout-users, expire-memberships,
payment-reminders, and cleanup-actions into the Toolkit CLI, registered
as pmpro-toolkit subcommands behind the existing enable_cli_commands
setting. Fixes the stale tk/v1 endpoint default to toolkit/v1.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant