Skip to content

Commit 59a43d3

Browse files
committed
Fix PHPUnit dependency mount lifecycle
1 parent c751155 commit 59a43d3

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

packages/runtime-playground/src/phpunit-command-handlers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ $changed_test_files_raw = ${JSON.stringify(JSON.stringify(options.changedTestFil
363363
$phpunit_args_raw = json_decode(${JSON.stringify(JSON.stringify(options.phpunitArgs))}, true);
364364
$bench_env = json_decode(${JSON.stringify(JSON.stringify(options.env))}, true);
365365
$wp_config_defines = json_decode(${JSON.stringify(JSON.stringify(options.wpConfigDefines))}, true);
366-
$dep_mounts = ${JSON.stringify(options.dependencyMounts.join("\\n"))};
366+
$dep_mounts = ${JSON.stringify(options.dependencyMounts.join("\n"))};
367367
$bootstrap_files = json_decode(${JSON.stringify(JSON.stringify(options.bootstrapFiles))}, true);
368368
$preload_files = json_decode(${JSON.stringify(JSON.stringify(options.preloadFiles ?? []))}, true);
369369
$bootstrap_mode = ${JSON.stringify(options.bootstrapMode || "managed")};

tests/phpunit-project-autoload.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ const managedModeCode = phpunitRunCode({
401401
phpunitArgs: [],
402402
env: {},
403403
wpConfigDefines: {},
404-
dependencyMounts: [],
404+
dependencyMounts: ["/wordpress/wp-content/plugins/demo-plugin", "/wordpress/wp-content/plugins/dependency"],
405405
bootstrapFiles: [],
406406
bootstrapMode: "managed",
407407
projectBootstrap: "",
@@ -410,6 +410,7 @@ const managedModeCode = phpunitRunCode({
410410

411411
assert.ok(managedModeCode.includes("configured PHPUnit harness autoload file is not readable"))
412412
assert.ok(managedModeCode.includes("'cacheResult' => false"))
413+
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")
413414
const installStageIndex = managedModeCode.indexOf("pg_run_install_stage(array(")
414415
const dependencyLoadStageIndex = managedModeCode.indexOf("$loaded_dep_files = pg_run_load_deps_stage", installStageIndex)
415416
const activationStageIndex = managedModeCode.indexOf("pg_run_activation_stage", dependencyLoadStageIndex)

tests/playground-phpunit-readonly-cache.integration.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,16 @@ try {
2626
const recipe = buildWordPressPhpunitRecipe({
2727
pluginSlug: "readonly-phpunit-fixture",
2828
extra_plugins: [{
29+
source: plugin,
30+
slug: "readonly-phpunit-fixture",
31+
activate: false,
32+
}, {
2933
source: dependency,
3034
slug: "activation-dependency",
31-
pluginFile: "activation-dependency/activation-dependency.php",
3235
activate: false,
3336
}],
34-
dependencyMounts: ["/wordpress/wp-content/plugins/activation-dependency"],
37+
dependencyMounts: ["/wordpress/wp-content/plugins/readonly-phpunit-fixture", "/wordpress/wp-content/plugins/activation-dependency"],
3538
mounts: [
36-
{ source: plugin, target: "/wordpress/wp-content/plugins/readonly-phpunit-fixture", mode: "readonly" },
3739
{ source: join(harness, "vendor"), target: "/wp-codebox-vendor", mode: "readonly" },
3840
],
3941
})

0 commit comments

Comments
 (0)