[Repo Assist] test: add 21 unit tests for PHPCBF class (no package.json changes)#107
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Draft
Conversation
…dard) Exports the PHPCBF class from extension.js so it can be imported in tests. Adds test/phpcbf.test.js with 21 tests covering: - PHPCBF.loadSettings (11 tests): default values, configured values, tilde expansion in executablePath, onsave, debug, standard, documentFormattingProvider settings - PHPCBF.getArgs (6 tests): -lq vs -l flag (debug mode), tmpFileName placement, --standard presence/absence, argument ordering - PHPCBF.getStandard (4 tests): configSearch=false pass-through, null workspace folder, undefined fileName Uses a lightweight vscode stub via Module._load intercept — no VS Code Extension Host required. Run with: node --test test/phpcbf.test.js Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
35 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated draft PR from Repo Assist, an AI assistant.
Summary
Adds 21 unit tests for the
PHPCBFclass using a lightweight vscode stub — no VS Code Extension Host required. Exports thePHPCBFclass fromextension.jsto make it testable.Previously, only
findFileshad unit tests. ThePHPCBFclass (loadSettings,getArgs,getStandard) was completely untested.Changes
extension.jsAdds a single line:
This allows
test/phpcbf.test.jsto import the class without requiring VS Code.test/phpcbf.test.js(new)21 tests covering:
PHPCBF.loadSettings~) expansion inexecutablePath,onsave,debug,standard,documentFormattingProviderPHPCBF.getArgs-lqvs-l(debug mode),tmpFileNameplacement,--standard=(value)presence/absence, argument orderingPHPCBF.getStandardconfigSearch: falsepass-through, null workspace folder, undefinedfileNameThe test file uses
Module._loadto interceptrequire("vscode")and return a minimal stub. This technique is self-contained and does not require any new dependencies.How to run
Test Status
✅ New tests:
node --test test/phpcbf.test.js— 21/21 pass✅ Existing tests:
npm run test:unit— 7/7 pass✅ Syntax check:
node --check extension.js— no syntax errors