Skip to content

Commit 72e2acd

Browse files
committed
Preserve strict PHPUnit config handling after rebase
1 parent 8662de9 commit 72e2acd

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,9 @@ function pg_run_project_bootstrap_stage(array $cfg): void {
837837
$from_config = $bootstrap !== '';
838838
}
839839
if ($bootstrap === '') {
840+
if (!$phpunit_xml_is_default && !is_readable($phpunit_xml)) {
841+
throw new RuntimeException('explicit PHPUnit config is not readable: ' . $phpunit_xml);
842+
}
840843
pg_log('NOTICE:project bootstrap not declared; continuing without one');
841844
pg_stage_ok('project_bootstrap');
842845
return;

tests/phpunit-project-autoload.test.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -540,17 +540,12 @@ echo json_encode(array($legacy_project_autoload_file, $harness_autoload_file));
540540
`)
541541
assert.deepEqual(JSON.parse(execFileSync("php", [canonicalHarnessProbe], { encoding: "utf8" })), ["", "/tmp/wp-codebox-inputs/0-wp-codebox-vendor-73845ca47d2f/autoload.php"], "a canonical staged harness path remains the harness in project mode")
542542

543-
function decodeSubmittedBootstrap(code: string): string {
544-
const encodedBootstrap = code.match(/base64_decode\("([A-Za-z0-9+/=]+)"\)/)?.[1]
545-
return encodedBootstrap ? Buffer.from(encodedBootstrap, "base64").toString("utf8") : code
546-
}
547-
548543
let capturedCanonicalHarnessCode = ""
549544
await runPhpunitCommand({
550545
artifactRoot: mkdtempSync(join(tmpdir(), "wp-codebox-phpunit-artifacts-")),
551546
mounts: [],
552547
runPlaygroundCommand: async (_command, _server, input) => {
553-
capturedCanonicalHarnessCode = decodeSubmittedBootstrap(input.code)
548+
capturedCanonicalHarnessCode = input.code
554549
return { text: "ok", exitCode: 0 }
555550
},
556551
runtimeSpec: phpunitRuntimeSpec,
@@ -571,14 +566,14 @@ const decodedCanonicalHarnessCode = decodedBootstrapWrapper(capturedCanonicalHar
571566
assert.ok(decodedCanonicalHarnessCode.includes('$autoload_file = "/tmp/wp-codebox-inputs/0-wp-codebox-vendor-73845ca47d2f/autoload.php";'))
572567
assert.ok(decodedCanonicalHarnessCode.includes('$autoload_file_role = "harness";'))
573568
assert.ok(decodedCanonicalHarnessCode.includes('putenv("TC_MYSQL_PORT=3306");'), "runtime service environment is passed to the PHP executed by wordpress.phpunit")
574-
assert.ok(decodedCanonicalHarnessCode.indexOf('putenv("TC_MYSQL_PORT=3306");') < decodedCanonicalHarnessCode.indexOf("require_once '/wordpress/wp-load.php';"), "runtime environment is available to project bootstrap code")
569+
assert.ok(!decodedCanonicalHarnessCode.includes("require_once '/wordpress/wp-load.php';"), "project bootstrap mode does not load the managed WordPress runtime first")
575570

576571
let capturedExplicitCode = ""
577572
await runPhpunitCommand({
578573
artifactRoot: mkdtempSync(join(tmpdir(), "wp-codebox-phpunit-artifacts-")),
579574
mounts: [],
580575
runPlaygroundCommand: async (_command, _server, input) => {
581-
capturedExplicitCode = decodeSubmittedBootstrap(input.code)
576+
capturedExplicitCode = input.code
582577
return { text: "ok", exitCode: 0 }
583578
},
584579
runtimeSpec: phpunitRuntimeSpec,

0 commit comments

Comments
 (0)