Skip to content

docs: document using Smooth Generator in PHPUnit tests - #218

Open
faisalahammad wants to merge 1 commit into
woocommerce:trunkfrom
faisalahammad:docs/151-phpunit-usage
Open

docs: document using Smooth Generator in PHPUnit tests#218
faisalahammad wants to merge 1 commit into
woocommerce:trunkfrom
faisalahammad:docs/151-phpunit-usage

Conversation

@faisalahammad

Copy link
Copy Markdown

All Submissions:

Changes proposed in this Pull Request:

Adds documentation on using Smooth Generator inside PHPUnit tests, addressing issue #151. The generators are already callable as static methods (Product::generate(), Product::batch(), Router::generate_batch()) and the plugin's own test suite uses them this way, but there was no guidance for extension developers who want the same in their own suites.

New file docs/using-in-phpunit.md covers: prerequisites (WP + WooCommerce bootstrapped, plugin loaded), a quick start, per-generator code examples (products, orders, customers, coupons, bookings, terms, router), return-value and assertion patterns, the smoothgenerator_*_generated action hooks, and gotchas (batch counts can be shorter than requested, Term's positional taxonomy argument, orders need products, bookings need WC Bookings, no image-disable flag, 100 batch cap, emails auto-disabled). The README links to it.

Closes #151.

How to test the changes in this Pull Request:

  1. Read docs/using-in-phpunit.md.
  2. Confirm every code snippet matches the generator signatures in includes/Generator/*.php and includes/Router.php.
  3. Optionally copy a snippet into a WP_UnitTestCase that boots WooCommerce and run it.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable? (Docs only; no code changed, so no new tests.)
  • Have you successfully run tests with your changes locally? (No functional change; composer phpcs passes for changed content.)

Changelog entry

Add documentation for using Smooth Generator inside PHPUnit tests.

FOR PR REVIEWER ONLY:

  • I have reviewed that everything is sanitized/escaped appropriately for any SQL or XSS injection possibilities. I made sure Linting is not ignored or disabled.

Add docs/using-in-phpunit.md with prerequisites, per-generator code
examples, return-value handling, and gotchas for calling generators
from a PHPUnit test suite. Link it from the README.

Closes woocommerce#151
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.

Consider Adding Documentation on Using Smooth Generator in PHPUnit

1 participant