mrkoopie/wp_wrapper

Wraps WordPress functions into mockable objects. Used for WP_ajaxfilter.

v1.2.4 2016-04-08 07:45 UTC

This package is auto-updated.

Last update: 2024-04-14 01:05:28 UTC


README

Total Downloads Latest Stable Version Build status https://travis-ci.org/MrKoopie/WP_wrapper.svg?branch=master

By default WordPress has many non-mockable functions such as register_taxonomy(). By implementing this wrapper you can create tests that use mocks instead of a real WordPress installation.

How to install

  1. Go to the root directory of your theme/plugin.
  2. Run the following command:
composer require mrkoopie/wp_wrapper
  1. Include the composer autoloader in your script (for a theme the functions.php).
require_once('vendor/autoload.php');

How to use the wrapper

Simply include this in the top of your file:

use MrKoopie/WP_wrapper/WP_wrapper;

Now you can run any command (including any PHP command) via the wrapper:

echo WP_wrapper::print_r('Y',1);

Do I always have to use the use feature?

Simply use this code to make the class available without the namespace. Do note that this may cause conflicts when an other class exists with the name WP_wrapper.

require_once('vendor/autoload.php');

class WP_wrapper extends MrKoopie/WP_wrapper/WP_Wrapper {};