Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save montrealist/399428718b072c03d401d4c4d282f3dc to your computer and use it in GitHub Desktop.
Save montrealist/399428718b072c03d401d4c4d282f3dc to your computer and use it in GitHub Desktop.
How to get wp_mock set up inside Codeception

How to get Wp_Mock set up inside Codeception

How to get Wp_Mock (https://github.com/10up/wp_mock) set up inside Codeception (https://github.com/codeception/codeception):

Have a composer.json file inside the /tests/ directory (which is itself inside the plugin or theme directory);

Then follow the manual (https://github.com/10up/wp_mock#installation):

$ composer require --dev 10up/wp_mock:dev-master

Inside /tests/unit/_bootstrap.php include the Composer autoloader:

require_once __DIR__ . '/../vendor/autoload.php';

If it doesn't work you can add something to output a dummy test string inside /vendor/autoload.php:

print_r('test');

... and run your Codeception tests:

$ codecept run unit

The 'test' should show up somewhere in the output. If it doesn't then you're not including the file properly inside your _bootstrap.php; play with it unti you get the string showing up when the Codeception tests are run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment