Add PHPUnit test suite with Brain\Monkey (v0.1.6)
All checks were successful
Create Release Package / PHP Lint (push) Successful in 1m2s
Create Release Package / PHPUnit Tests (push) Successful in 46s
Create Release Package / Build Release (push) Successful in 50s

Add test infrastructure for isolated unit testing without WordPress/WooCommerce:
- 27 tests (54 assertions) covering TemplateOverride and WooCommerceExtension
- Brain\Monkey for WordPress function mocking, class stubs for TwigService and WC_Product
- PHPUnit test job added to Gitea CI pipeline between lint and build-release
- Test artifacts excluded from release packages

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 03:48:19 +01:00
parent 784b400c46
commit 4031a1c8aa
14 changed files with 2678 additions and 10 deletions

View File

@@ -28,8 +28,9 @@ The bridge hooks into WooCommerce's `woocommerce_before_template_part` and `wooc
- **99 Twig template overrides** covering all customer-facing WooCommerce pages
- **Rendering bridge** (`WooCommerceExtension` + `TemplateOverride`) that intercepts WooCommerce's PHP template pipeline
- **~50 Twig functions** and **7 Twig filters** exposing WooCommerce and WordPress APIs to templates
- **~50 Twig functions** and **8 Twig filters** exposing WooCommerce and WordPress APIs to templates
- Bootstrap 5 responsive markup with dark mode support
- **PHPUnit test suite** with Brain\Monkey for isolated unit testing (no WordPress/WooCommerce required)
- HPOS compatible (uses `WC_Order` methods only, no `$post` global)
- 8 reusable Twig components (card, pagination, price, rating, address-card, status-badge, quantity-input, form-field)
- Translation-ready
@@ -83,10 +84,15 @@ wc-bootstrap/
│ ├── notices/
│ ├── order/
│ └── single-product/
├── tests/
│ ├── bootstrap.php # PHPUnit bootstrap (autoloader + stubs)
│ ├── Stubs/ # WordPress/WooCommerce class stubs
│ └── Unit/ # Unit tests (TemplateOverride, WooCommerceExtension)
├── docker/
│ ├── Dockerfile # Multistage build (WC download, npm, composer, WP)
│ ├── entrypoint.sh # Auto-setup wrapper entrypoint
│ └── setup.sh # First-run WP install + plugin/theme activation
├── phpunit.xml.dist # PHPUnit 11 configuration
├── .env-dist # Environment variable template
├── compose.yaml # WordPress + MariaDB services
├── compose.override.yaml # Dev overrides (bind mounts, debug flags)
@@ -143,8 +149,8 @@ for po in languages/wc-bootstrap-*.po; do msgfmt -o "${po%.po}.mo" "$po"; done
Releases are automated via Gitea Actions. Push a tag matching `vX.X.X` to trigger a release build.
```bash
git tag -a v0.1.5 -m "Version 0.1.5 - Fix 10 known bugs"
git push origin v0.1.5
git tag -a v0.1.6 -m "Version 0.1.6 - Add PHPUnit test suite"
git push origin v0.1.6
```
## License