@@ -43,8 +43,7 @@ public function setUp(): void {
4343 * @return array{output: string, code: int}
4444 */
4545 private function run_wp_cli ( $ command ) {
46- // Calculate WordPress root from plugin directory (wp-content/plugins/progress-planner).
47- $ wp_path = \dirname ( PROGRESS_PLANNER_DIR , 3 );
46+ $ wp_path = $ this ->get_wp_path ();
4847
4948 $ full_command = \sprintf ( 'cd %s && wp %s 2>&1 ' , \escapeshellarg ( $ wp_path ), $ command );
5049
@@ -56,6 +55,31 @@ private function run_wp_cli( $command ) {
5655 ];
5756 }
5857
58+ /**
59+ * Get the WordPress installation path.
60+ *
61+ * Handles both local environments (plugin in wp-content/plugins/) and CI
62+ * environments (plugin symlinked into WP installation).
63+ *
64+ * @return string Path to WordPress installation.
65+ */
66+ private function get_wp_path () {
67+ // First, try the standard plugin location (3 directories up from plugin root).
68+ $ standard_path = \dirname ( PROGRESS_PLANNER_DIR , 3 );
69+ if ( \file_exists ( $ standard_path . '/wp-config.php ' ) || \file_exists ( $ standard_path . '/wp-load.php ' ) ) {
70+ return $ standard_path ;
71+ }
72+
73+ // In CI, WordPress is installed to /tmp/wordpress and the plugin is symlinked there.
74+ $ ci_wp_path = '/tmp/wordpress ' ;
75+ if ( \file_exists ( $ ci_wp_path . '/wp-load.php ' ) ) {
76+ return $ ci_wp_path ;
77+ }
78+
79+ // Fallback to standard path.
80+ return $ standard_path ;
81+ }
82+
5983 /**
6084 * Clean up test task after tests.
6185 *
0 commit comments