Runtime
"Unitest WP Copy" is not a full WordPress installation. It is a selected set of WordPress functions and classes (symbols) that can run without a database or full bootstrap.
Runtime lifecycle
Runtime state is shared for the life of the PHP process:
- Define test constants.
- Call
\Unitest_WP_Copy\WP_Runtime::boot()once per PHP process.- Load runtime changes for the current WordPress version.
- Load selected symbols and runtime adapters.
- Start in-memory option stores and mockable-function support.
- Define WordPress constants.
- Initialize WordPress-like globals.
- Load adapted initialization fragments.
- Register the REST OPTIONS hook.
- Configure required globals, hooks, registries, and adapters.
- Run the code under test.
- Assert the result.
- Restore shared state in
tearDown().
Optional mocks
WP_Mock is separate from this runtime. When a test needs its handlers, call \WP_Mock::bootstrap() as well.
See Options for option configuration, lookup, mocking, defaults, and state cleanup.
Runtime-adapted classes
Some WordPress classes are reduced to the parts useful in unit tests:
\Unitest_WP_Copy\wpdb__Runtimebuilds SQL but does not query a database.\Unitest_WP_Copy\WP_REST_Server__Runtimeregisters and dispatches routes in memory.
See Runtime-adapted classes for extension examples, and SYMBOLS-INFO.md for their public methods.