Skip to content

Commit 8662de9

Browse files
committed
Decode wrapped PHPUnit bootstrap assertions
1 parent 86a8e29 commit 8662de9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

tests/phpunit-project-autoload.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,12 +540,17 @@ 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+
543548
let capturedCanonicalHarnessCode = ""
544549
await runPhpunitCommand({
545550
artifactRoot: mkdtempSync(join(tmpdir(), "wp-codebox-phpunit-artifacts-")),
546551
mounts: [],
547552
runPlaygroundCommand: async (_command, _server, input) => {
548-
capturedCanonicalHarnessCode = input.code
553+
capturedCanonicalHarnessCode = decodeSubmittedBootstrap(input.code)
549554
return { text: "ok", exitCode: 0 }
550555
},
551556
runtimeSpec: phpunitRuntimeSpec,
@@ -573,7 +578,7 @@ await runPhpunitCommand({
573578
artifactRoot: mkdtempSync(join(tmpdir(), "wp-codebox-phpunit-artifacts-")),
574579
mounts: [],
575580
runPlaygroundCommand: async (_command, _server, input) => {
576-
capturedExplicitCode = input.code
581+
capturedExplicitCode = decodeSubmittedBootstrap(input.code)
577582
return { text: "ok", exitCode: 0 }
578583
},
579584
runtimeSpec: phpunitRuntimeSpec,

0 commit comments

Comments
 (0)