Properties

$client

$client : \Goutte\Client

Type

\Goutte\Client

$cache_dir

$cache_dir : string

Type

string

$wp_original_options

$wp_original_options : array

Type

array

$wp_options

$wp_options : array

Type

array

$is_admin

$is_admin : 

Should we test in admin environment?

$plugin

$plugin : 

Methods

setUp()

setUp() 

Prepare the WP environment

This will prepare the environment for the current session as well as any following requests made to the current test installation using a client such as a crawler or a browser

setUpForCurrentRequest()

setUpForCurrentRequest() 

Prepares the WP environment, but for current request only

This means we don't need to prepare config and htaccess stuff

tearDown()

tearDown() 

get_plugin_under_test()

get_plugin_under_test() 

get_extra_plugins()

get_extra_plugins() : array

Get a list of extra plugins that should be loaded and activated for testing

This can include fxitures if needed.

Returns

array

get_all_plugins()

get_all_plugins() : array

Get a list of all plugins, including the plugin under test and extra ones

Returns

array

prepare_plugin_directories()

prepare_plugin_directories() 

Prepare plugin directories

This should create symlinks to the plugins' folders from wp-content/plugins directory so that they can be activated and used later on

load_plugins_for_current_process()

load_plugins_for_current_process() 

Load all required plugins for current process

This should be called by extending testcases explicitly. This only loads actual plugins, not fixtures.

pre_option_active_plugins()

pre_option_active_plugins() : array

Filter `pre_option_active_plugins` hook.

Returns

array

prepare_wp_config()

prepare_wp_config() 

prepare_htaccess_file()

prepare_htaccess_file() 

prepare_cache_directory()

prepare_cache_directory(string  $cache_dir = null) 

Prepare a blank cache folder for every test

Parameters

string $cache_dir

prepare_asset_directories()

prepare_asset_directories() 

Prepare js and css directories if not existed

set_wp_default_options()

set_wp_default_options() 

Set WP options that are used for all tests

We backup the orignal WP options so we can reset the options in db after every test

set_wp_options()

set_wp_options(array  $options) 

Set WP options that are used for a specific test

Parameters

array $options

an associative array of key => value

set_plugin_default_options()

set_plugin_default_options() 

Set default options that are used for all tests

set_options()

set_options(string  $option_key, array  $options) 

Set options used with a specific testcase

Parameters

string $option_key
array $options

a subset of options to be set

activate_plugins()

activate_plugins(array  $plugins) 

Activate specific plugins

This only affect actual requests made to the test site

Parameters

array $plugins

deactivate_plugins()

deactivate_plugins(array  $plugins = array()) 

Deactivate plugins

This only affect actual requests made to the test site

Parameters

array $plugins

optional, default is to deactivate all plugins

update_option()

update_option(string  $key, mixed  $value) 

Parameters

string $key
mixed $value

delete_option()

delete_option(string  $key) 

Parameters

string $key

reset_users()

reset_users() 

Reset users to installed state

This should not reset the initial 'admin' user

reset_posts()

reset_posts() 

reset_terms()

reset_terms() 

reset_posts_terms()

reset_posts_terms() 

reset_comments()

reset_comments() 

get_client()

get_client(boolean  $use_existing = true, boolean  $use_cache = false) : \Goutte\Client

Parameters

boolean $use_existing

whether to create a new client or use existing if any, default to true

boolean $use_cache

whether to use http cache

Returns

\Goutte\Client

get_client_clone()

get_client_clone() : \Goutte\Client

Returns

\Goutte\Client

get_crawler_from_url()

get_crawler_from_url(string  $url, array  $headers = array()) : \Symfony\Component\DomCrawler\Crawler

Get a Crawler instance from a URL.

Parameters

string $url
array $headers

Returns

\Symfony\Component\DomCrawler\Crawler

get_crawler_from_post()

get_crawler_from_post(\WP_Post  $post) : \Symfony\Component\DomCrawler\Crawler

Parameters

\WP_Post $post

Returns

\Symfony\Component\DomCrawler\Crawler

get_uri_from_client()

get_uri_from_client(\Goutte\Client  $client) : string

Get the requested uri from a Client object.

Parameters

\Goutte\Client $client

Returns

string

prepare_default_values()

prepare_default_values() 

Prepare default values including options and active plugins

load_fixtures()

load_fixtures(  $file_name = null) 

This should be used explicitly by extending testcases

Parameters

$file_name

bootstrap_plugin()

bootstrap_plugin() 

get_wp_version()

get_wp_version(  $version = '') : mixed

Get current WP version

If a WP version is provided as the first parameter, check if the current WP version is greater than or equal to that provided version

Parameters

$version

Returns

mixed

uniqid()

uniqid() : string

Returns

string

create_post()

create_post(  $post_type = 'post') 

Parameters

$post_type

create_posts()

create_posts(  $post_type = 'post',   $count = 5,   $post_date_gmt = null) 

Parameters

$post_type
$count
$post_date_gmt

create_terms()

create_terms(  $taxonomy = 'category',   $count = 5) 

Parameters

$taxonomy
$count