public function test_display()
 {
     tests_add_filter('gtm/id', function () {
         return 'GTM-456';
     });
     simple_gtm();
     $this->expectOutputRegex('/id\\=GTM\\-456/');
 }
Example #2
0
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';
}
 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';
 }
Example #4
0
 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');
 }
/**
 * 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';
}
 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';
 }
 /**
  * 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';
 }
Example #8
0
 /**
  * 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();
 }
Example #9
0
 /**
  * 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();
     }
 }
Example #10
0
 /**
  * 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();
 }
Example #11
0
 /**
  * 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();
 }
Example #12
0
<?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';
Example #13
0
 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'));
         }
     }
 }
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';
Example #15
0
<?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';
Example #16
0
if (!getenv('WP_TESTS_DIR')) {
    exit('$_ENV["WP_TESTS_DIR"] is not set.' . PHP_EOL);
}
include __DIR__ . '/../../../vendor/autoload.php';
/**
 * The WordPress tests functions.
 *
 * Clearly, WP_TESTS_DIR should be the path to the WordPress PHPUnit tests checkout.
 *
 * We are loading this so that we can add our tests filter to load the plugin, using
 * tests_add_filter().
 *
 * @since 1.0.0
 */
require_once getenv('WP_TESTS_DIR') . '/includes/functions.php';
tests_add_filter('muplugins_loaded', function () {
    $plugin_file = dirname(dirname(dirname(__DIR__))) . '/plugin.php';
    include $plugin_file;
    do_action('activate_' . plugin_basename($plugin_file));
});
/**
 * Sets up the WordPress test environment.
 *
 * We've got our action set up, so we can load this now, and viola, the tests begin.
 * Again, WordPress' PHPUnit test suite needs to be installed under the given path.
 *
 * @since 1.0.0
 */
require getenv('WP_TESTS_DIR') . '/includes/bootstrap.php';
include __DIR__ . '/export-testcase.php';
include __DIR__ . '/testcases/import.php';
Example #17
0
<?php

$wp_tests_dir = getenv('WP_TESTS_DIR');
require_once $wp_tests_dir . '/includes/functions.php';
function _manually_load_environment()
{
    $plugins_to_active = array(basename(dirname(__DIR__)) . "/plugin.php");
    // allow explicitly setting the plugin slug
    if (getenv('WP_PLUGIN_SLUG')) {
        $plugins_to_active = array(getenv('WP_PLUGIN_SLUG') . "/plugin.php");
    }
    update_option('active_plugins', $plugins_to_active);
    $pmp_creds = array('pmp_api_url' => getenv('PMP_API_URL'), 'pmp_client_id' => getenv('PMP_CLIENT_ID'), 'pmp_client_secret' => getenv('PMP_CLIENT_SECRET'));
    update_option('pmp_settings', $pmp_creds);
    $GLOBALS['pmp_stash'] = array();
}
tests_add_filter('muplugins_loaded', '_manually_load_environment');
require $wp_tests_dir . '/includes/bootstrap.php';
Example #18
0
<?php

$_tests_dir = getenv('WP_TESTS_DIR');
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
require_once $_tests_dir . '/includes/functions.php';
/**
 * Load the REST API and our own plugin.
 */
function _manually_load_oembed_api_plugin()
{
    require dirname(__FILE__) . '/../wp-api-oembed.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_oembed_api_plugin');
require $_tests_dir . '/includes/bootstrap.php';
Example #19
0
    $GLOBALS['base'] = '/';
} else {
    echo "Running as single site... To run multisite, use -c tests/phpunit/multisite.xml" . PHP_EOL;
}
unset($multisite);
require_once dirname(__FILE__) . '/functions.php';
// Preset WordPress options defined in bootstrap file.
// Used to activate themes, plugins, as well as  other settings.
if (isset($GLOBALS['wp_tests_options'])) {
    function wp_tests_options($value)
    {
        $key = substr(current_filter(), strlen('pre_option_'));
        return $GLOBALS['wp_tests_options'][$key];
    }
    foreach (array_keys($GLOBALS['wp_tests_options']) as $key) {
        tests_add_filter('pre_option_' . $key, 'wp_tests_options');
    }
}
// Load WordPress
require_once ABSPATH . '/wp-settings.php';
// Delete any default posts & related data
_delete_all_posts();
add_filter('user_has_cap', "ut_user_has_cap", 9, 3);
function ut_user_has_cap($all_caps, $cap, $args)
{
    $all_caps["gform_full_access"] = true;
    return $all_caps;
}
if (!class_exists('RGForms')) {
    require GRAVITYFORMS_BASE_PATH . 'gravityforms.php';
}
Example #20
0
<?php

/**
 * Tests bootstrapper
 *
 * @author X-Team <x-team.com>
 * @author Jonathan Bardo <*****@*****.**>
 */
// Use in code to trigger custom actions
define('STREAM_TESTS', true);
define('WP_STREAM_DEV_DEBUG', true);
$_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', function () {
    // Manually load plugin
    require dirname(dirname(__FILE__)) . '/stream.php';
});
require getenv('WP_TESTS_DIR') . 'includes/bootstrap.php';
require dirname(__FILE__) . '/testcase.php';
Example #21
0
<?php

if (!defined('BP_TESTS_DIR')) {
    define('BP_TESTS_DIR', dirname(__FILE__) . '/../../buddypress/tests');
}
if (file_exists(BP_TESTS_DIR . '/bootstrap.php')) {
    $_tests_dir = getenv('WP_TESTS_DIR');
    if (!$_tests_dir) {
        $_tests_dir = '/tmp/wordpress-tests-lib';
    }
    require_once $_tests_dir . '/includes/functions.php';
    function _bootstrap_plugins()
    {
        require BP_TESTS_DIR . '/includes/loader.php';
        require dirname(__FILE__) . '/../bp-activity-subscription.php';
    }
    tests_add_filter('muplugins_loaded', '_bootstrap_plugins');
    require $_tests_dir . '/includes/bootstrap.php';
    require BP_TESTS_DIR . '/includes/testcase.php';
}
<?php

/**
 * PHPUnit bootstrap file
 *
 * @package post-link-shortcodes
 */
if (!($_tests_dir = getenv('WP_TESTS_DIR'))) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
require_once __DIR__ . '/trait-shortcode-assertions.php';
// Give access to tests_add_filter() function.
require_once $_tests_dir . '/includes/functions.php';
/**
 * Manually load the plugin being tested.
 */
tests_add_filter('muplugins_loaded', function () {
    require realpath(__DIR__ . '/../post-link-shortcodes.php');
});
/**
 * Register some custom post types for our tests
 */
tests_add_filter('init', function () {
    register_post_type('xyz', ['show_ui' => true]);
    register_post_type('secret', ['show_ui' => false]);
    $args = ['public' => true, 'show_ui' => true, 'has_archive' => true, 'supports' => ['title', 'editor', 'thumbnail']];
    register_post_type('cpt-with-dashes', $args);
    register_post_type('cpt_with_underscores', $args);
});
// Start up the WP testing environment.
require $_tests_dir . '/includes/bootstrap.php';
Example #23
0
{
    global $wp_filter, $merged_filters;
    $idx = _test_filter_build_unique_id($tag, $function_to_add, $priority);
    $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
    unset($merged_filters[$tag]);
    return true;
}
function _test_filter_build_unique_id($tag, $function, $priority)
{
    global $wp_filter;
    static $filter_id_count = 0;
    if (is_string($function)) {
        return $function;
    }
    if (is_object($function)) {
        $function = array($function, '');
    } else {
        $function = (array) $function;
    }
    if (is_object($function[0])) {
        return spl_object_hash($function[0]) . $function[1];
    } else {
        if (is_string($function[0])) {
            return $function[0] . $function[1];
        }
    }
}
// Allow tests to override wp_die
$GLOBALS['_wp_die_disabled'] = false;
tests_add_filter('wp_die_handler', '_wp_die_handler_filter');
require_once realpath(ABSPATH . 'wp-config.php');
Example #24
0
{
    if (defined('WP_TESTS_BUDDYPRESS') && 1 == WP_TESTS_BUDDYPRESS) {
        if (!defined('WP_TESTS_MULTISITE')) {
            echo "Testing with BuddyPress integration..." . PHP_EOL;
            echo "Running without BuddyPress multisite integration... To test BuddyPress multisite integration, use -c tests/phpunit/buddymulti.xml" . PHP_EOL;
        } else {
            echo "Testing with BuddyPress multisite integration..." . PHP_EOL;
        }
        if (!defined('BP_TESTS_DIR')) {
            define('BP_TESTS_DIR', dirname(__FILE__) . '/../../../buddypress/tests/phpunit');
        }
        if (!file_exists(BP_TESTS_DIR . '/bootstrap.php')) {
            die('The BuddyPress Test suite could not be found');
        }
        // Make sure BP is installed and loaded first
        require BP_TESTS_DIR . '/includes/loader.php';
    } else {
        echo "Running without BuddyPress integration... To test BuddyPress integration, use -c tests/phpunit/buddypress.xml" . PHP_EOL;
        echo "To test BuddyPress multisite integration, use -c tests/phpunit/buddymulti.xml" . PHP_EOL;
    }
    // load WP Idea Stream
    require dirname(__FILE__) . '/../../wp-idea-stream.php';
}
tests_add_filter('muplugins_loaded', '_bootstrap_wp_idea_stream');
require getenv('WP_DEVELOP_DIR') . '/tests/phpunit/includes/bootstrap.php';
if (defined('WP_TESTS_BUDDYPRESS') && 1 == WP_TESTS_BUDDYPRESS) {
    // Load the BP-specific testing tools
    require BP_TESTS_DIR . '/includes/testcase.php';
}
// include our testcase
require 'testcase.php';
Example #25
0
<?php

// Activates this plugin in WordPress so it can be tested.
$GLOBALS['wp_tests_options'] = array('active_plugins' => array('posts-to-posts/posts-to-posts.php', 'rtbiz/index.php'));
$_tests_dir = getenv('WP_TESTS_DIR');
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib/';
}
require_once $_tests_dir . 'includes/functions.php';
function _manually_load_plugin()
{
    define('WP_ADMIN', true);
    $_SERVER['REMOTE_ADDR'] = 'localhost';
    $_SERVER['PHP_SELF'] = 'http://localhost/wp-admin/';
    define('AUTH_KEY', '1234567890');
    define('SECURE_AUTH_KEY', '1234567890');
    require_once dirname(__FILE__) . '/../../posts-to-posts/posts-to-posts.php';
    require_once dirname(__FILE__) . '/../rtbiz.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
function _manually_init()
{
    // This is for p2p tables
    wp_set_current_user(1);
    do_action('admin_notices');
}
tests_add_filter('plugins_loaded', '_manually_init', 15);
require $_tests_dir . '/includes/bootstrap.php';
require_once 'rt-wp-test-case.php';
Example #26
0
<?php

require_once getenv('WP_DEVELOP_DIR') . '/tests/phpunit/includes/functions.php';
function _bootstrap_buddydrive()
{
    if (!defined('BP_TESTS_DIR')) {
        define('BP_TESTS_DIR', dirname(__FILE__) . '/../../../buddypress/tests/phpunit');
    }
    if (!file_exists(BP_TESTS_DIR . '/bootstrap.php')) {
        die('The BuddyPress Test suite could not be found');
    }
    // Make sure BP is installed and loaded first
    require BP_TESTS_DIR . '/includes/loader.php';
    // load WP Idea Stream
    require dirname(__FILE__) . '/../../buddydrive.php';
}
tests_add_filter('muplugins_loaded', '_bootstrap_buddydrive');
require getenv('WP_DEVELOP_DIR') . '/tests/phpunit/includes/bootstrap.php';
require BP_TESTS_DIR . '/includes/testcase.php';
// include our testcase
require 'testcase.php';
<?php

$_tests_dir = getenv('WP_TESTS_DIR');
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
/**
 * change PLUGIN_FILE env in phpunit.xml
 */
define('PLUGIN_FILE', getenv('PLUGIN_FILE'));
define('PLUGIN_FOLDER', basename(dirname(__DIR__)));
define('PLUGIN_PATH', PLUGIN_FOLDER . '/' . PLUGIN_FILE);
// Activates this plugin in WordPress so it can be tested.
$GLOBALS['wp_tests_options'] = array('active_plugins' => array(PLUGIN_PATH));
require_once $_tests_dir . '/includes/functions.php';
tests_add_filter('muplugins_loaded', function () {
    // Manually load plugin
    require dirname(__DIR__) . '/' . PLUGIN_FILE;
});
// Removes all sql tables on shutdown
// Do this action last
tests_add_filter('shutdown', 'drop_tables', 999999);
require $_tests_dir . '/includes/bootstrap.php';
Example #28
0
    add_filter('ep_config_mapping', 'ep_test_shard_number');
    $tries = 5;
    $sleep = 3;
    do {
        $response = wp_remote_get(EP_HOST);
        if (200 == wp_remote_retrieve_response_code($response)) {
            // Looks good!
            break;
        } else {
            printf("\nInvalid response from ES, sleeping %d seconds and trying again...\n", intval($sleep));
            sleep($sleep);
        }
    } while (--$tries);
    if (200 != wp_remote_retrieve_response_code($response)) {
        exit('Could not connect to ElasticPress server.');
    }
    require_once dirname(__FILE__) . '/includes/functions.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
function _setup_theme()
{
    define('WP_UNINSTALL_PLUGIN', true);
    update_option('woocommerce_status_options', array('uninstall_data' => 1));
    include dirname(__FILE__) . '/../vendor/woocommerce/uninstall.php';
    WC_Install::install();
    $GLOBALS['wp_roles']->reinit();
    echo "Installing WooCommerce..." . PHP_EOL;
}
tests_add_filter('setup_theme', '_setup_theme');
require $_tests_dir . '/includes/bootstrap.php';
require_once dirname(__FILE__) . '/includes/class-ep-test-base.php';
Example #29
0
$_tests_dir = getenv('WP_TESTS_DIR');
if (!$_tests_dir) {
    $_tests_dir = '/tmp/wordpress-tests-lib';
}
require_once $_tests_dir . '/includes/functions.php';
if (getenv('WP_CORE_DIR')) {
    $_core_dir = getenv('WP_CORE_DIR');
} else {
    if (getenv('WP_DEVELOP_DIR')) {
        $_core_dir = getenv('WP_DEVELOP_DIR') . '/src/';
    } else {
        $_core_dir = '/tmp/wordpress';
    }
}
if (getenv('WP_REDIS_USE_CACHE_GROUPS')) {
    define('WP_REDIS_USE_CACHE_GROUPS', true);
}
// Easiest way to get this to where WordPress will load it
copy(dirname(dirname(dirname(__FILE__))) . '/object-cache.php', $_core_dir . '/wp-content/object-cache.php');
function _manually_load_plugin()
{
    require dirname(dirname(dirname(__FILE__))) . '/wp-redis.php';
}
tests_add_filter('muplugins_loaded', '_manually_load_plugin');
require $_tests_dir . '/includes/bootstrap.php';
error_log(PHP_EOL);
$phpredis_state = class_exists('Redis') ? 'enabled' : 'disabled';
error_log('PhpRedis: ' . $phpredis_state . PHP_EOL);
$cache_groups_state = defined('WP_REDIS_USE_CACHE_GROUPS') && WP_REDIS_USE_CACHE_GROUPS ? 'enabled' : 'disabled';
error_log('Cache groups: ' . $cache_groups_state . PHP_EOL);
error_log(PHP_EOL);
Example #30
0
 /**
  * Loads WordPress calling the bootstrap file
  *
  * 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.
  *
  * @return void
  */
 protected function loadWordPress()
 {
     $this->defineGlobals();
     if ($this->config['multisite']) {
         $this->debug('Running as multisite');
     } else {
         $this->debug('Running as single site');
     }
     require_once dirname(dirname(__DIR__)) . '/includes/functions.php';
     $this->setActivePlugins();
     $this->_setActiveTheme();
     if (!$this->requiresIsolatedInstallation()) {
         tests_add_filter('muplugins_loaded', [$this, 'loadPlugins']);
         tests_add_filter('wp_install', [$this, 'activatePlugins'], 100);
         tests_add_filter('wp_install', [$this, 'bootstrapActions'], 101);
         tests_add_filter('plugins_loaded', [$this, '_switch_theme']);
     }
     require_once $this->wpBootstrapFile;
     if ($this->requiresIsolatedInstallation()) {
         $this->bootstrapActions();
         $this->_switch_theme();
     }
 }