File tree Expand file tree Collapse file tree 3 files changed +23
-11
lines changed
Expand file tree Collapse file tree 3 files changed +23
-11
lines changed Original file line number Diff line number Diff line change 7575 uses : ramsey/composer-install@v2
7676 with :
7777 dependency-versions : highest
78- composer-options : " --prefer-dist --no-suggest --no- progress"
78+ composer-options : " --prefer-dist --no-progress"
7979
8080 - name : Prepare Database
8181 run : |
Original file line number Diff line number Diff line change 3535 * Manually load the plugin being tested.
3636 */
3737function _manually_load_plugin () {
38- // Explicitly include the main plugin file
38+ // Define global $wp_widget_factory to prevent null reference errors
39+ global $ wp_widget_factory ;
40+ $ wp_widget_factory = (object ) ['widgets ' => []];
41+
42+ // Add a mock register_widget function that works with our fake widget factory
43+ if (!function_exists ('register_widget ' )) {
44+ function register_widget ($ widget ) {
45+ global $ wp_widget_factory ;
46+ $ wp_widget_factory ->widgets [] = $ widget ;
47+ return true ;
48+ }
49+ }
50+
51+ // Now load the plugin
3952 require_once dirname ( __DIR__ ) . '/simple-wp-optimizer.php ' ;
4053
41- // Make sure the plugin gets initialized
54+ // Initialize the plugin without triggering widgets_init
55+ remove_all_actions ('widgets_init ' );
4256 do_action ('plugins_loaded ' );
4357 do_action ('init ' );
4458}
Original file line number Diff line number Diff line change 66 */
77
88/**
9- * Sample test case.
9+ * Simple test case for Simple WP Optimizer plugin .
1010 */
1111class Test_Simple_WP_Optimizer extends WP_UnitTestCase {
1212 /**
1313 * Test that the plugin can be loaded correctly.
14+ *
15+ * This test simply checks that the plugin loads in WordPress
16+ * without causing any errors.
1417 */
1518 public function test_plugin_loaded () {
1619 // Load the plugin directly to ensure it's available for testing
1720 require_once dirname ( __DIR__ ) . '/simple-wp-optimizer.php ' ;
1821
19- // Check for specific functions that we know exist in the plugin
20- $ this ->assertTrue (
21- function_exists ( 'es_optimizer_init_settings ' ) ||
22- function_exists ( 'disable_emojis ' ) ||
23- function_exists ( 'remove_jquery_migrate ' ),
24- 'Plugin core functions not found, plugin may not be loaded correctly. '
25- );
22+ // Check for at least one function to verify the plugin loaded
23+ $ this ->assertTrue (function_exists ('es_optimizer_init_settings ' ), 'Plugin was not loaded correctly ' );
2624 }
2725}
You can’t perform that action at this time.
0 commit comments