PluginProbe
Hello Plus / 1.7.0
Hello Plus v1.7.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.6.2 1.7.0 1.7.1 1.7.2 1.7.3 All 30 releases
hello-plus / tests / bootstrap.php

bootstrap.php in Hello Plus 1.7.0, at tests/bootstrap.php

84 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 $composer_autoloader_file = __DIR__ . '/../vendor/autoload.php';
4
5 if ( ! file_exists( $composer_autoloader_file ) ) {
6 die( 'Installing composer are required for running the tests.' );
7 }
8
9 require $composer_autoloader_file;
10
11 $_tests_dir = getenv( 'WP_TESTS_DIR' );
12
13 define( 'ELEMENTOR_TESTS', true );
14 define( 'HELLO_PLUS_TESTS', true );
15
16 /**
17 * change PLUGIN_FILE env in phpunit.xml
18 */
19 define( 'PLUGIN_FILE', getenv( 'PLUGIN_FILE' ) );
20 define( 'PLUGIN_FOLDER', basename( dirname( __DIR__ ) ) );
21 define( 'PLUGIN_PATH', PLUGIN_FOLDER . '/' . PLUGIN_FILE );
22
23 $elementor_plugin_path = 'elementor/elementor.php';
24
25 $active_plugins = [ $elementor_plugin_path, PLUGIN_PATH ];
26
27 // Activates this plugin in WordPress so it can be tested.
28 $GLOBALS['wp_tests_options'] = [
29 'active_plugins' => $active_plugins,
30 'template' => 'twentytwentyone',
31 'stylesheet' => 'twentytwentyone',
32 ];
33
34 require_once $_tests_dir . '/includes/functions.php';
35
36 tests_add_filter( 'muplugins_loaded', function () {
37 // Manually load plugin
38 $elementor_plugin_path = getenv( 'WP_TESTS_ELEMENTOR_DIR' );
39
40 require $elementor_plugin_path;
41
42 require dirname( __DIR__ ) . '/' . PLUGIN_FILE;
43 } );
44
45 // Removes all sql tables on shutdown
46 // Do this action last
47 tests_add_filter( 'shutdown', 'drop_tables', 999999 );
48
49 require $_tests_dir . '/includes/bootstrap.php';
50
51 remove_action( 'admin_init', '_maybe_update_themes' );
52 remove_action( 'admin_init', '_maybe_update_core' );
53 remove_action( 'admin_init', '_maybe_update_plugins' );
54 /**
55 * WordPress added deprecation error messages to print_emoji_styles in 6.4, which causes our PHPUnit assertions
56 * to fail. This is something that might still change during the beta period, but for now we need to remove this action
57 * as to not block all our PRs, but still run tests on WP Nightly.
58 *
59 * @see https://core.trac.wordpress.org/changeset/56682/
60 */
61 remove_action( 'wp_print_styles', 'print_emoji_styles' );
62
63 // Set behavior like on WP Admin for things like WP_Query->is_admin (default post status will be based on `show_in_admin_all_list`).
64 if ( ! defined( 'WP_ADMIN' ) ) {
65 define( 'WP_ADMIN', true );
66 }
67
68 do_action( 'plugins_loaded' );
69
70 function initialize_elementor_plugin( $plugin_class ) {
71 if ( ! class_exists( $plugin_class ) ) {
72 return null;
73 }
74
75 return $plugin_class::instance();
76 }
77
78 $plugin_instance = initialize_elementor_plugin( 'Elementor\Plugin' );
79
80 $plugin_instance->initialize_container();
81
82 do_action( 'init' );
83 do_action( 'wp_loaded' );
84