Registry / testing / 10up-wp-mock

10up-wp-mock

JSON →
library1.1.1phppackagist✓ verified 24d ago

A mocking library to take the pain out of unit testing for WordPress.

composer require 10up/wp_mock
INSTALL
IMPORT
SIG · 10UP-WP-MOCK
1
10up-wp-mock
testingphpv1.1.1
Install
4.2s avg
Import
Disk
0MB
Pass rate
6/ 6
Env Coverage6 / 6
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.1.1 · composer require
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
cli
php 8.18.36 runs
installs and imports cleanly · install 2.1s · import 0.000s · 0.43MB
0
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Bootstrap
use WP_Mock\Bootstrap;

Initialize WP_Mock and mock a WordPress function.

use WP_Mock\Bootstrap; Bootstrap::init(); WP_Mock::userFunction('get_option', ['return' => 'value']); echo get_option('test'); // Outputs: value
Debug
Known issues
gotchaRequires PHP 7.0+ and may not work with newer WordPress versions.
fix
Check compatibility with your WordPress version.
affects: >=1.0.0
Upgrade
Version history
1.1.1latest on Packagist
Audit
Dependencies

No dependency data recorded yet.

Agent activity
74 hits · last 30 days
node
64
OpenAI (training)
1
Resources
10up-wp-mock — pip install 10up-wp-mock · libregistry