Testing¶
Requirements¶
- PHP 7.4+
- A running MySQL/MariaDB instance (tests hit a real database — no mocks)
- WordPress test suite installed (handled by
wp-test-init)
Setup¶
# First-time setup — installs WordPress test suite
composer test:init
# Reset the test database
composer test:reset
Running tests¶
This runs vendor/bin/wp-test which invokes PHPUnit with the configuration in phpunit.xml.
Test structure¶
tests/
├── bootstrap.php
├── WCTest.php # Base test case with WooCommerce helpers
└── Subscribed/PaymentsHub/Core/
├── Gateways/
│ ├── FrisbiiGatewayTest.php
│ └── MobilePayGatewayTest.php
└── Services/
├── LocaleResolverTest.php
└── PaymentRetryDateServiceTest.php
Writing tests¶
- Extend
WCTestfor tests that need WooCommerce fixtures (orders, subscriptions, customers). - Gateway tests should use HTTP-level mocks (Guzzle mock handler) rather than mocking the gateway classes themselves.
- Place new tests under
tests/Subscribed/PaymentsHub/mirroring thesrc/namespace structure. - All tests must pass before submitting a PR.