From 31181670f5d2bb26b55d2c85800b9e64fc6b4b87 Mon Sep 17 00:00:00 2001 From: Elon Mallin Date: Tue, 5 Mar 2024 21:56:30 +0100 Subject: [PATCH] fix: space problem --- package.json | 2 +- src/PhpunitCommand/PhpunitArgBuilder.ts | 2 +- .../tests/Space Test/SimpleTest.php | 9 ++++++ src/test/suite/e2e.test.ts | 29 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/test/php-project/tests/Space Test/SimpleTest.php diff --git a/package.json b/package.json index 9a301cc..9569f50 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "phpunit", "displayName": "PHPUnit", "description": "Run PHPUnit tests from VSCode.", - "version": "4.12.0", + "version": "4.16.0", "publisher": "emallin", "icon": "images/phpunit.png", "engines": { diff --git a/src/PhpunitCommand/PhpunitArgBuilder.ts b/src/PhpunitCommand/PhpunitArgBuilder.ts index 19414f4..12c5e7b 100644 --- a/src/PhpunitCommand/PhpunitArgBuilder.ts +++ b/src/PhpunitCommand/PhpunitArgBuilder.ts @@ -85,7 +85,7 @@ export class PhpunitArgBuilder { ...(this.filter ? ["--filter", `'${this.filter}'`] : []), ...(this.groups.length > 0 ? ["--group", this.groups.join(",")] : []), ...this.args, - ...this.directoryOrFiles, + ...this.directoryOrFiles.map((directoryOrFile) => `'${directoryOrFile}'`), ].filter((part) => part); if (this.pathMappings) { diff --git a/src/test/php-project/tests/Space Test/SimpleTest.php b/src/test/php-project/tests/Space Test/SimpleTest.php new file mode 100644 index 0000000..047e9a0 --- /dev/null +++ b/src/test/php-project/tests/Space Test/SimpleTest.php @@ -0,0 +1,9 @@ +assertTrue(true); + } +} diff --git a/src/test/suite/e2e.test.ts b/src/test/suite/e2e.test.ts index ea23d31..b90b280 100644 --- a/src/test/suite/e2e.test.ts +++ b/src/test/suite/e2e.test.ts @@ -74,6 +74,35 @@ suite("php-project e2e", () => { assert.equal(task.exitCode, 0); }); + test("phpunit.Test Class space in path", async () => { + const uri = vscode.Uri.file( + path.resolve( + vscode.workspace.workspaceFolders![0].uri.fsPath, + "tests/Space Test/SimpleTest.php", + ), + ); + const document = await vscode.workspace.openTextDocument(uri); + await vscode.window.showTextDocument(document, { + selection: new vscode.Range(4, 0, 4, 0), + }); + + await vscode.workspace + .getConfiguration("phpunit") + .update("preferRunClassTestOverQuickPickWindow", true); + + const taskOutputPromise = getOnDidEndTaskProcessPromise( + myExtensionApi.testRedirectedOutputFile, + ); + const res = await vscode.commands.executeCommand("phpunit.Test"); + const task = await taskOutputPromise; + + assert.match( + task.output, + /PHPUnit .* by Sebastian Bergmann and contributors./, + ); + assert.equal(task.exitCode, 0); + }); + test("phpunit.Test Function", async () => { const uri = vscode.Uri.file( path.resolve(