本文整理汇总了PHP中tests_add_filter函数的典型用法代码示例。如果您正苦于以下问题:PHP tests_add_filter函数的具体用法?PHP tests_add_filter怎么用?PHP tests_add_filter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tests_add_filter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_display
public function test_display()
{
tests_add_filter('gtm/id', function () {
return 'GTM-456';
});
simple_gtm();
$this->expectOutputRegex('/id\\=GTM\\-456/');
}
示例2: _load_wordpress_tests
function _load_wordpress_tests($tests_directory)
{
$GLOBALS['wp_tests_options'] = array('active_plugins' => array('wprestcop/wprestcop.php'), 'timezone_string' => 'America/Los_Angeles');
require_once $tests_directory . '/includes/functions.php';
tests_add_filter('muplugins_loaded', function () {
require dirname(dirname(__DIR__)) . '/wprestcop.php';
});
require $tests_directory . '/includes/bootstrap.php';
}
示例3: __construct
public function __construct()
{
ini_set('display_errors', 'on');
error_reporting(E_ALL);
$this->wp_tests_dir = '/tmp/wordpress-tests-lib';
$this->includes();
require_once $this->wp_tests_dir . '/includes/functions.php';
tests_add_filter('muplugins_loaded', array($this, 'load'));
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
}
示例4: __construct
public function __construct()
{
ini_set('display_errors', 'on');
error_reporting(E_ALL);
$this->wp_tests_dir = '/tmp/wordpress-tests-lib';
require_once $this->wp_tests_dir . '/includes/functions.php';
tests_add_filter('muplugins_loaded', array($this, 'load_wc_pos'));
tests_add_filter('setup_theme', array($this, 'install_wc_pos'));
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
activate_plugin(WP_CONTENT_DIR . '/plugins/woocommerce/woocommerce.php');
}
示例5: _bp_follow_bootstrap
/**
* Load BuddyPress and BP Follow.
*/
function _bp_follow_bootstrap()
{
// Load up BP's specialized unit test loader
require BP_TESTS_DIR . '/includes/loader.php';
// make BP pass the bp_is_network_activated() check
// this is needed when the BP directory is symlinked
if (is_multisite()) {
tests_add_filter('bp_is_network_activated', '__return_true');
}
_bp_follow_install();
// Now load BP Follow
require dirname(__FILE__) . '/../../../loader.php';
}
示例6: __construct
public function __construct($testDir, $wpTestDir)
{
$this->testsDir = $testDir;
$this->pluginDir = \dirname($this->testsDir);
$this->wpTestsDir = $wpTestDir;
// Give access to tests_add_filter() function.
require_once $this->wpTestsDir . '/includes/functions.php';
// Load WooCommerce
\tests_add_filter('muplugins_loaded', array($this, 'loadWooCommerce'));
// Load the plugin
\tests_add_filter('muplugins_loaded', array($this, 'loadPlugin'));
// Start up the WP testing environment.
include_once $this->wpTestsDir . '/includes/bootstrap.php';
}
示例7: setup
/**
* Setup tests.
*/
private function setup()
{
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['SERVER_NAME'] = 'localhost';
$_tests_dir = getenv('WP_TESTS_DIR');
if (!$_tests_dir) {
$_tests_dir = '/tmp/wordpress-tests-lib';
}
require_once $_tests_dir . '/includes/functions.php';
tests_add_filter('muplugins_loaded', array($this, 'load_plugins'));
tests_add_filter('setup_theme', array($this, 'install_plugins'));
require $_tests_dir . '/includes/bootstrap.php';
require dirname(__FILE__) . '/../lib/edr-crt-test.php';
}
示例8: __construct
/**
* Setup the unit testing environment
*
* @since 1.3.2
*/
public function __construct()
{
ini_set('display_errors', 'on');
error_reporting(E_ALL);
$this->tests_dir = dirname(__FILE__);
$this->plugin_dir = dirname($this->tests_dir);
$this->wp_tests_dir = getenv('WP_TESTS_DIR') ? getenv('WP_TESTS_DIR') : '/tmp/wordpress-tests-lib';
// load test function so tests_add_filter() is available
require_once $this->wp_tests_dir . '/includes/functions.php';
// load CF_API
tests_add_filter('muplugins_loaded', array($this, 'load_cf_api'));
// load the WP testing environment
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
// load CF_API testing framework
$this->includes();
}
示例9: __construct
/**
* Setup the unit testing environment
*/
private function __construct()
{
ini_set('display_errors', 'on');
error_reporting(E_ALL);
$this->tests_dir = dirname(__FILE__);
$this->plugin_dir = dirname($this->tests_dir);
$this->wp_tests_dir = getenv('WP_TESTS_DIR') ? getenv('WP_TESTS_DIR') : $this->plugin_dir . '/tmp/wordpress-tests-lib';
// load test function so tests_add_filter() is available
require_once $this->wp_tests_dir . '/includes/functions.php';
// load plugin
tests_add_filter('muplugins_loaded', array($this, 'load_plugin'));
// load the WP testing environment
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
// make sure query vars are prepared
global $wp;
if (!is_array($wp->query_vars)) {
$wp->query_vars = array();
}
}
示例10: __construct
/**
* Setup the unit testing environment.
*
* @since 2.2
*/
public function __construct()
{
ini_set('display_errors', 'on');
error_reporting(E_ALL);
// Ensure server variable is set for WP email functions.
if (!isset($_SERVER['SERVER_NAME'])) {
$_SERVER['SERVER_NAME'] = 'localhost';
}
$this->tests_dir = dirname(__FILE__);
$this->plugin_dir = dirname($this->tests_dir);
$this->wp_tests_dir = getenv('WP_TESTS_DIR') ? getenv('WP_TESTS_DIR') : '/tmp/wordpress-tests-lib';
// load test function so tests_add_filter() is available
require_once $this->wp_tests_dir . '/includes/functions.php';
// load WC
tests_add_filter('muplugins_loaded', array($this, 'load_wc'));
// install WC
tests_add_filter('setup_theme', array($this, 'install_wc'));
// load the WP testing environment
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
// load WC testing framework
$this->includes();
}
示例11: __construct
/**
* Setup the unit testing environment
*
* @since 1.9
*/
public function __construct()
{
ini_set('display_errors', 'on');
error_reporting(E_ALL);
$this->tests_dir = dirname(__FILE__);
$this->plugin_dir = dirname($this->tests_dir);
$this->wp_tests_dir = getenv('WP_TESTS_DIR') ? getenv('WP_TESTS_DIR') : $this->plugin_dir . '/tmp/wordpress-tests-lib';
// load test function so tests_add_filter() is available
require_once $this->wp_tests_dir . '/includes/functions.php';
// load GV
tests_add_filter('muplugins_loaded', array($this, 'load'));
tests_add_filter('gravityview_log_error', array($this, 'test_print_log'), 10, 3);
// Log debug if passed to `phpunit` like: `phpunit --debug --verbose`
if (in_array('--debug', (array) $_SERVER['argv'], true) && in_array('--verbose', (array) $_SERVER['argv'], true)) {
tests_add_filter('gravityview_log_debug', array($this, 'test_print_log'), 10, 3);
}
// load the WP testing environment
require_once $this->wp_tests_dir . '/includes/bootstrap.php';
require_once $this->tests_dir . '/GV_UnitTestCase.php';
require_once $this->tests_dir . '/factory.php';
// set up GravityView
$this->install();
}
示例12: getenv
<?php
$wp_tests_dir = getenv('WP_TESTS_DIR');
require_once $wp_tests_dir . '/includes/functions.php';
$basename = basename(dirname(__DIR__));
$GLOBALS['wp_tests_options'] = array('stylesheet' => $basename, 'template' => $basename);
tests_add_filter('set_current_user', function ($arg) {
$user = wp_get_current_user();
$user->set_role('administrator');
return $arg;
}, 1, 10);
tests_add_filter('filesystem_method', function ($arg) {
return 'direct';
}, 1, 10);
require dirname(__FILE__) . '/mock/mock-options-framework.php';
require dirname(__FILE__) . '/mock/mock-admin-functions.php';
require $wp_tests_dir . '/includes/bootstrap.php';
示例13: setup_filters
public function setup_filters()
{
// Allow tests to override wp_die
tests_add_filter('wp_die_handler', '_wp_die_handler_filter');
// Preset WordPress options defined in bootstrap file.
// Used to activate themes, plugins, as well as other settings.
if (isset($GLOBALS['wp_tests_options'])) {
foreach (array_keys($GLOBALS['wp_tests_options']) as $key) {
tests_add_filter('pre_option_' . $key, array($this, 'wp_tests_options'));
}
}
}
示例14: die
if (!($wp_test_dir = getenv('WP_TESTS_DIR'))) {
$wp_test_dir = '/tmp/wordpress-tests-lib';
if (!file_exists($wp_test_dir . '/includes')) {
die("Fatal Error: Could not find the WordPress tests directory.\n");
}
}
/**
* Loads WP utility functions like `tests_add_filter` and `_delete_all_posts`.
*/
require_once $wp_test_dir . '/includes/functions.php';
/**
* Preset wp_options before loading the WordPress stack.
*
* Used to activate themes, plugins, as well as other settings in `wp_options`.
*
* @see wp_tests_options
*/
$GLOBALS['wp_tests_options'] = array('active_plugins' => array('hello.php'));
/**
* Run custom functionality after mu-plugins are loaded.
*/
function _tests_load_badgeos()
{
define('CMB_DIRECTORY_PATH', trailingslashit(dirname(dirname(dirname(dirname(__FILE__))))));
require CMB_DIRECTORY_PATH . 'init.php';
}
tests_add_filter('muplugins_loaded', '_tests_load_badgeos');
/**
* Bootstraps the WordPress stack.
*/
require $wp_test_dir . '/includes/bootstrap.php';
示例15: getenv
<?php
require_once getenv('WP_TESTS_DIR') . '/includes/functions.php';
tests_add_filter('muplugins_loaded', create_function('', "require dirname( __FILE__ ) . '/../frontend-uploader.php';"));
require getenv('WP_TESTS_DIR') . '/includes/bootstrap.php';