Skip to content

Commit 0d4fd5f

Browse files
authored
Workflow
1 parent 894bb86 commit 0d4fd5f

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Added PHPUnit test framework with GitHub Actions workflow for automated testing
1414
- Configured cross-version PHP testing (7.4-8.2) with multisite support
1515
- Fixed database creation issues in testing workflow for CI environment
16+
- Enhanced plugin loading in test environment for improved reliability
1617

1718
## [1.5.4] - 2025-05-04
1819
### Changed

tests/bootstrap.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@
3535
* Manually load the plugin being tested.
3636
*/
3737
function _manually_load_plugin() {
38-
require dirname( __DIR__ ) . '/simple-wp-optimizer.php';
38+
// Explicitly include the main plugin file
39+
require_once dirname( __DIR__ ) . '/simple-wp-optimizer.php';
40+
41+
// Make sure the plugin gets initialized
42+
do_action('plugins_loaded');
43+
do_action('init');
3944
}
4045

4146
// Start up the WP testing environment.

tests/test-plugin.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ class Test_Simple_WP_Optimizer extends WP_UnitTestCase {
1313
* Test that the plugin can be loaded correctly.
1414
*/
1515
public function test_plugin_loaded() {
16-
// Simply check that the plugin file has been loaded
17-
$this->assertTrue( function_exists( 'simple_wp_optimizer_init' ) || class_exists( 'Simple_WP_Optimizer' ), 'Plugin functions not found, plugin may not be loaded correctly.' );
16+
// Load the plugin directly to ensure it's available for testing
17+
require_once dirname( __DIR__ ) . '/simple-wp-optimizer.php';
18+
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+
);
1826
}
1927
}

0 commit comments

Comments
 (0)