Skip to content

Commit 7cd5178

Browse files
committed
Decode wrapped PHPUnit bootstrap assertions
1 parent c41685e commit 7cd5178

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
@@ -407,12 +407,17 @@ echo json_encode(array($legacy_project_autoload_file, $harness_autoload_file));
407407
`)
408408
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")
409409

410+
function decodeSubmittedBootstrap(code: string): string {
411+
const encodedBootstrap = code.match(/base64_decode\("([A-Za-z0-9+/=]+)"\)/)?.[1]
412+
return encodedBootstrap ? Buffer.from(encodedBootstrap, "base64").toString("utf8") : code
413+
}
414+
410415
let capturedCanonicalHarnessCode = ""
411416
await runPhpunitCommand({
412417
artifactRoot: mkdtempSync(join(tmpdir(), "wp-codebox-phpunit-artifacts-")),
413418
mounts: [],
414419
runPlaygroundCommand: async (_command, _server, input) => {
415-
capturedCanonicalHarnessCode = input.code
420+
capturedCanonicalHarnessCode = decodeSubmittedBootstrap(input.code)
416421
return { text: "ok", exitCode: 0 }
417422
},
418423
runtimeSpec: phpunitRuntimeSpec,
@@ -439,7 +444,7 @@ await runPhpunitCommand({
439444
artifactRoot: mkdtempSync(join(tmpdir(), "wp-codebox-phpunit-artifacts-")),
440445
mounts: [],
441446
runPlaygroundCommand: async (_command, _server, input) => {
442-
capturedExplicitCode = input.code
447+
capturedExplicitCode = decodeSubmittedBootstrap(input.code)
443448
return { text: "ok", exitCode: 0 }
444449
},
445450
runtimeSpec: phpunitRuntimeSpec,

0 commit comments

Comments
 (0)