PHP Класс Codeception\Module\WPLoader

Loads a WordPress installation for testing purposes. The class is a Codeception adaptation of WordPress automated testing suite, see here, and takes care of configuring and installing a WordPress installation. To work properly the \WP_UnitTestCase should be used to run the tests in a PHPUnit-like behaviour.
Наследование: extends Codeception\Module
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$excludeActions
$includeInheritedActions
$onlyActions

Защищенные свойства (Protected)

Свойство Тип Описание
$config array All of the fields have a correspondant in the standard wp-tests-config.php file found in WordPress automated testing suite. isolatedInstall - bool, def. true, whether the WP installation should happen in an isolated process(core like) or not (previous wp-browser method). wpDebug - bool, def. true, the WP_DEBUG global value. multisite - bool, def. false, if set to true will create a multisite installation, the WP_TESTS_MULTISITE global value. dbCharset - string, def. utf8, the DB_CHARSET global value. dbCollate - string, def. , the DB_COLLATE global value. tablePrefix - string, def. wptests_, the WP_TESTS_TABLE_PREFIX value. domain - string, def. example.org, the root URL of the site, the WP_TESTS_DOMAIN global value. adminEmail - string, def. [email protected], the admin email, the WP_TEST_EMAIL global value. title - string, def. Test Blog, the blog title, the WP_TESTS_TITLE global value. phpBinary - string, def. php, the php bin command, the WP_PHP_BINARY global value. language - string, def. , the installation language, the WPLANG global value. configFile - string or array, def. , the path, or an array of paths, to custom config file(s) relative to the wpRootFolder folder, no leading slash needed; this is the place where custom wp_tests_options could be set. pluginsFolder - string, def. , the relative path to the plugins folder in respect to the WP root folder plugins - array, def. [], a list of plugins that should be loaded before any test case runs and after mu-plugins have been loaded; these should be defined in the folder/plugin-file.php format. activatePlugins - array, def. [], a list of plugins that should be activated calling the activate_{$plugin} before any test case runs and after mu-plugins have been loaded; these should be defined in the folder/plugin-file.php format. bootstrapActions - array, def. [], a list of actions that should be called after before any test case runs.
$pluginsFolder The absolute path to the plugins folder
$requiredFields array wpRootFolder - the absolute path to the root folder of the WordPress installation to use for testing, the ABSPATH global value. dbNAme - the name of the database to use for the tests, will be trashed during tests so take care, will be the DB_NAME global. dbHost - the host the database can be found at, will be the DB_HOST global. dbUser - the database privileged user, should GRANT ALL on the database, will be the DB_USER global. dbPassword - the password for the user, will be the DB_PASSWORD global.
$wpBootstrapFile string The path to the modified tests bootstrap file.
$wpRootFolder The absolute path to WP root folder (ABSPATH).

Открытые методы

Метод Описание
__construct ( Codeception\Lib\ModuleContainer $moduleContainer, $config, tad\WPBrowser\Adapters\WP $wp = null )
_initialize ( ) : void The function that will initialize the module.
_setActiveTheme ( ) Sets the active template and stylesheet according to the theme configuration parameter.
_switch_theme ( )
activatePlugins ( )
bootstrapActions ( ) Calls a list of user-defined actions needed in tests.
ensureDbModuleCompat ( )
loadPlugins ( ) Loads the plugins required by the test.

Защищенные методы

Метод Описание
defineGlobals ( ) : void Defines the globals needed by WordPress to run to user set values.
getPluginsFolder ( ) : string
getWpRootFolder ( ) : string
initialize ( )
loadConfigFile ( string $folder = null )
loadWordPress ( ) : void Loads WordPress calling the bootstrap file
requiresIsolatedInstallation ( ) : boolean | mixed
setActivePlugins ( )

Приватные методы

Метод Описание
ensureWPRoot ( string $wpRootFolder )

Описание методов

__construct() публичный Метод

public __construct ( Codeception\Lib\ModuleContainer $moduleContainer, $config, tad\WPBrowser\Adapters\WP $wp = null )
$moduleContainer Codeception\Lib\ModuleContainer
$wp tad\WPBrowser\Adapters\WP

_initialize() публичный Метод

The function will set up the WordPress testing configuration and will take care of installing and loading WordPress. The simple inclusion of the module in an test helper class will hence trigger WordPress loading, no explicit method calling on the user side is needed.
public _initialize ( ) : void
Результат void

_setActiveTheme() публичный Метод

Sets the active template and stylesheet according to the theme configuration parameter.
public _setActiveTheme ( )

_switch_theme() публичный Метод

public _switch_theme ( )

activatePlugins() публичный Метод

public activatePlugins ( )

bootstrapActions() публичный Метод

Calls a list of user-defined actions needed in tests.
public bootstrapActions ( )

defineGlobals() защищенный Метод

The method replaces the "wp-tests-config.php" file the original testing workflow included to allow run-time customization of the globals in a Codeception friendly way.
protected defineGlobals ( ) : void
Результат void

ensureDbModuleCompat() публичный Метод

getPluginsFolder() защищенный Метод

protected getPluginsFolder ( ) : string
Результат string

getWpRootFolder() защищенный Метод

protected getWpRootFolder ( ) : string
Результат string

initialize() защищенный Метод

protected initialize ( )

loadConfigFile() защищенный Метод

protected loadConfigFile ( string $folder = null )
$folder string = null The absolute path to the WordPress root installation folder.

loadPlugins() публичный Метод

Loads the plugins required by the test.
public loadPlugins ( )

loadWordPress() защищенный Метод

This method does little but wrapping preparing the global space for the original automated testing bootstrap file and taking charge of replacing the original "wp-tests-config.php" file in setting up the globals.
protected loadWordPress ( ) : void
Результат void

requiresIsolatedInstallation() защищенный Метод

protected requiresIsolatedInstallation ( ) : boolean | mixed
Результат boolean | mixed

setActivePlugins() защищенный Метод

protected setActivePlugins ( )

Описание свойств

$config защищенное свойство

All of the fields have a correspondant in the standard wp-tests-config.php file found in WordPress automated testing suite. isolatedInstall - bool, def. true, whether the WP installation should happen in an isolated process(core like) or not (previous wp-browser method). wpDebug - bool, def. true, the WP_DEBUG global value. multisite - bool, def. false, if set to true will create a multisite installation, the WP_TESTS_MULTISITE global value. dbCharset - string, def. utf8, the DB_CHARSET global value. dbCollate - string, def. , the DB_COLLATE global value. tablePrefix - string, def. wptests_, the WP_TESTS_TABLE_PREFIX value. domain - string, def. example.org, the root URL of the site, the WP_TESTS_DOMAIN global value. adminEmail - string, def. [email protected], the admin email, the WP_TEST_EMAIL global value. title - string, def. Test Blog, the blog title, the WP_TESTS_TITLE global value. phpBinary - string, def. php, the php bin command, the WP_PHP_BINARY global value. language - string, def. , the installation language, the WPLANG global value. configFile - string or array, def. , the path, or an array of paths, to custom config file(s) relative to the wpRootFolder folder, no leading slash needed; this is the place where custom wp_tests_options could be set. pluginsFolder - string, def. , the relative path to the plugins folder in respect to the WP root folder plugins - array, def. [], a list of plugins that should be loaded before any test case runs and after mu-plugins have been loaded; these should be defined in the folder/plugin-file.php format. activatePlugins - array, def. [], a list of plugins that should be activated calling the activate_{$plugin} before any test case runs and after mu-plugins have been loaded; these should be defined in the folder/plugin-file.php format. bootstrapActions - array, def. [], a list of actions that should be called after before any test case runs.
protected array $config
Результат array

$excludeActions публичное статическое свойство

public static $excludeActions

$includeInheritedActions публичное статическое свойство

public static $includeInheritedActions

$onlyActions публичное статическое свойство

public static $onlyActions

$pluginsFolder защищенное свойство

The absolute path to the plugins folder
protected $pluginsFolder

$requiredFields защищенное свойство

wpRootFolder - the absolute path to the root folder of the WordPress installation to use for testing, the ABSPATH global value. dbNAme - the name of the database to use for the tests, will be trashed during tests so take care, will be the DB_NAME global. dbHost - the host the database can be found at, will be the DB_HOST global. dbUser - the database privileged user, should GRANT ALL on the database, will be the DB_USER global. dbPassword - the password for the user, will be the DB_PASSWORD global.
protected array $requiredFields
Результат array

$wpBootstrapFile защищенное свойство

The path to the modified tests bootstrap file.
protected string $wpBootstrapFile
Результат string

$wpRootFolder защищенное свойство

The absolute path to WP root folder (ABSPATH).
protected $wpRootFolder