how to set context in WordPress for unit testing
If you have phpUnit configured for testing a WP plugin, you can use a test case like this: In your plugin-directory/tests/Some_Test_Case.php: class Plugin_Test extends WP_UnitTestCase { /** * @dataProvider post_IDs_and_expected_results */ public function test_something( $post_id, $expected_result ) { global $post; $post = get_post( $post_id ); $plugin_content = call_plugin_function(); // Your function name here $this->assertEquals( $expected_result, … Read more