1+ <?php
2+ /**
3+ * PHPUnit bootstrap file.
4+ *
5+ * @package Simple_WP_Optimizer
6+ */
7+
8+ // Load the Composer autoloader.
9+ require_once dirname ( __DIR__ ) . '/vendor/autoload.php ' ;
10+
11+ // Load the PHPUnit Polyfills for cross-version compatibility.
12+ require_once dirname ( __DIR__ ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php ' ;
13+
14+ // Make sure the tests directory is in the include path.
15+ if ( ! defined ( 'WP_CONTENT_DIR ' ) ) {
16+ define ( 'WP_CONTENT_DIR ' , dirname ( __DIR__ ) . '/tests/wp-content ' );
17+ }
18+
19+ if ( ! defined ( 'WP_PLUGIN_DIR ' ) ) {
20+ define ( 'WP_PLUGIN_DIR ' , WP_CONTENT_DIR . '/plugins ' );
21+ }
22+
23+ // Define a test plugin directory name.
24+ if ( ! defined ( 'TEST_PLUGIN_DIR ' ) ) {
25+ define ( 'TEST_PLUGIN_DIR ' , dirname ( __DIR__ ) );
26+ }
27+
28+ // Manually load the plugin being tested.
29+ function _manually_load_plugin () {
30+ require dirname ( __DIR__ ) . '/simple-wp-optimizer.php ' ;
31+ }
32+
33+ // Start up the WP testing environment.
34+ // Ideally, this would be automatically handled by the integration test action.
35+ // If WP_TESTS_DIR is defined, we'll use it, otherwise we'll set up a basic mock.
36+ if ( defined ( 'WP_TESTS_DIR ' ) && file_exists ( WP_TESTS_DIR . '/includes/bootstrap.php ' ) ) {
37+ require WP_TESTS_DIR . '/includes/bootstrap.php ' ;
38+ tests_add_filter ( 'muplugins_loaded ' , '_manually_load_plugin ' );
39+ } else {
40+ // Simple mock class if WP test suite isn't available
41+ class WP_UnitTestCase extends \Yoast \PHPUnitPolyfills \TestCases \TestCase {
42+ // Include test helper methods here
43+ }
44+ }
0 commit comments