Testing
Stack
Running Tests
composer test # alias for test:unit
composer test:unit # run the full unit suite
vendor/bin/phpunit --filter ConfigTest # run a single test class
vendor/bin/phpunit --filter loads_and_caches # run a single test by name
vendor/bin/phpunit --list-tests # list all discovered testsDirectory Structure
tests/
├── bootstrap.php # autoloader + THEMENAME/ABSPATH constants
└── Unit/
├── TestCase.php # base class (extends YoastTestCase)
├── Blocks/ # BlockClassManager
├── Bootstrap/ # Config, FileConfigLoader, Loader
├── Configuration/ # Sidebars, Menus, CustomPostTypes, Actions
├── ContextManagers/ # Menu, Site, ThemeMods, AcfOptions, WooCommerce
└── ServiceProviders/ # TimberServiceProviderWriting a New Test
1. Create the test class
2. Extend the base TestCase
3. Mock WordPress functions with BrainMonkey
4. Reset singletons when needed
Testing Context Managers
Tips and Gotchas
BrainMonkey apply_filters signature
apply_filters signaturePre-loaded functions cannot be mocked
wp_parse_args is pre-stubbed
wp_parse_args is pre-stubbedLast updated