From 59a43d37d8323b73dec205afec3b4a40a908e667 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sat, 18 Jul 2026 20:58:38 -0400 Subject: [PATCH] Fix PHPUnit dependency mount lifecycle --- .../runtime-playground/src/phpunit-command-handlers.ts | 2 +- tests/phpunit-project-autoload.test.ts | 3 ++- .../playground-phpunit-readonly-cache.integration.test.ts | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/runtime-playground/src/phpunit-command-handlers.ts b/packages/runtime-playground/src/phpunit-command-handlers.ts index 40582270..f53aafcf 100644 --- a/packages/runtime-playground/src/phpunit-command-handlers.ts +++ b/packages/runtime-playground/src/phpunit-command-handlers.ts @@ -363,7 +363,7 @@ $changed_test_files_raw = ${JSON.stringify(JSON.stringify(options.changedTestFil $phpunit_args_raw = json_decode(${JSON.stringify(JSON.stringify(options.phpunitArgs))}, true); $bench_env = json_decode(${JSON.stringify(JSON.stringify(options.env))}, true); $wp_config_defines = json_decode(${JSON.stringify(JSON.stringify(options.wpConfigDefines))}, true); -$dep_mounts = ${JSON.stringify(options.dependencyMounts.join("\\n"))}; +$dep_mounts = ${JSON.stringify(options.dependencyMounts.join("\n"))}; $bootstrap_files = json_decode(${JSON.stringify(JSON.stringify(options.bootstrapFiles))}, true); $preload_files = json_decode(${JSON.stringify(JSON.stringify(options.preloadFiles ?? []))}, true); $bootstrap_mode = ${JSON.stringify(options.bootstrapMode || "managed")}; diff --git a/tests/phpunit-project-autoload.test.ts b/tests/phpunit-project-autoload.test.ts index ce9badc9..bebdce0d 100644 --- a/tests/phpunit-project-autoload.test.ts +++ b/tests/phpunit-project-autoload.test.ts @@ -401,7 +401,7 @@ const managedModeCode = phpunitRunCode({ phpunitArgs: [], env: {}, wpConfigDefines: {}, - dependencyMounts: [], + dependencyMounts: ["/wordpress/wp-content/plugins/demo-plugin", "/wordpress/wp-content/plugins/dependency"], bootstrapFiles: [], bootstrapMode: "managed", projectBootstrap: "", @@ -410,6 +410,7 @@ const managedModeCode = phpunitRunCode({ assert.ok(managedModeCode.includes("configured PHPUnit harness autoload file is not readable")) assert.ok(managedModeCode.includes("'cacheResult' => false")) +assert.ok(managedModeCode.includes('$dep_mounts = "/wordpress/wp-content/plugins/demo-plugin\\n/wordpress/wp-content/plugins/dependency";'), "dependency mounts must be newline-delimited for the generated PHP runner") const installStageIndex = managedModeCode.indexOf("pg_run_install_stage(array(") const dependencyLoadStageIndex = managedModeCode.indexOf("$loaded_dep_files = pg_run_load_deps_stage", installStageIndex) const activationStageIndex = managedModeCode.indexOf("pg_run_activation_stage", dependencyLoadStageIndex) diff --git a/tests/playground-phpunit-readonly-cache.integration.test.ts b/tests/playground-phpunit-readonly-cache.integration.test.ts index c95b9763..0cca1fc7 100644 --- a/tests/playground-phpunit-readonly-cache.integration.test.ts +++ b/tests/playground-phpunit-readonly-cache.integration.test.ts @@ -26,14 +26,16 @@ try { const recipe = buildWordPressPhpunitRecipe({ pluginSlug: "readonly-phpunit-fixture", extra_plugins: [{ + source: plugin, + slug: "readonly-phpunit-fixture", + activate: false, + }, { source: dependency, slug: "activation-dependency", - pluginFile: "activation-dependency/activation-dependency.php", activate: false, }], - dependencyMounts: ["/wordpress/wp-content/plugins/activation-dependency"], + dependencyMounts: ["/wordpress/wp-content/plugins/readonly-phpunit-fixture", "/wordpress/wp-content/plugins/activation-dependency"], mounts: [ - { source: plugin, target: "/wordpress/wp-content/plugins/readonly-phpunit-fixture", mode: "readonly" }, { source: join(harness, "vendor"), target: "/wp-codebox-vendor", mode: "readonly" }, ], })