Testing¶
The plugin uses PHPUnit 6.5 for unit tests.
Running tests¶
The test bootstrap is at tests/bootstrap.php. Test configuration is in _phpunit.xml.
Test coverage¶
Tests live in tests/ and mirror the inc/ structure:
| Test file | Covers |
|---|---|
API/APIConfigTest.php | KlaviyoAPIConfig |
API/KlaviyoAPIFacadeTest.php | KlaviyoAPIFacade |
API/Objects/Event/EventTest.php | Event object |
API/Objects/Event/Metric/MetricTest.php | Metric object |
API/Objects/Lists/Subscribe/*Test.php | List subscription request objects |
API/Objects/Profile/*Test.php | Profile request objects |
API/Responses/ResponseDataTest.php | API response parsing |
Writing new tests¶
- Place tests in
tests/mirroring the source path underinc/. - Extend
PHPUnit\Framework\TestCase. - Keep tests isolated — avoid WordPress/WooCommerce bootstrap where possible; mock external dependencies.
- Run the full suite before and after every change.