Skip to content

[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
repo-assist/test-phpcbf-class-2026-03-25-f5637cf13607fd0c
Draft

[Repo Assist] test: add 21 unit tests for PHPCBF class (no package.json changes)#107
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/test-phpcbf-class-2026-03-25-f5637cf13607fd0c

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated draft PR from Repo Assist, an AI assistant.

Summary

Adds 21 unit tests for the PHPCBF class using a lightweight vscode stub — no VS Code Extension Host required. Exports the PHPCBF class from extension.js to make it testable.

Previously, only findFiles had unit tests. The PHPCBF class (loadSettings, getArgs, getStandard) was completely untested.

Note: A similar change was previously blocked (issue #99) because it also modified package.json. This PR intentionally excludes any package.json changes. Run the new tests with node --test test/phpcbf.test.js (the existing npm run test:unit script still runs the original tests as before).

Changes

extension.js

Adds a single line:

exports.PHPCBF = PHPCBF;

This allows test/phpcbf.test.js to import the class without requiring VS Code.

test/phpcbf.test.js (new)

21 tests covering:

Suite Count What's tested
PHPCBF.loadSettings 11 Default values, configured values, tilde (~) expansion in executablePath, onsave, debug, standard, documentFormattingProvider
PHPCBF.getArgs 6 -lq vs -l (debug mode), tmpFileName placement, --standard=(value) presence/absence, argument ordering
PHPCBF.getStandard 4 configSearch: false pass-through, null workspace folder, undefined fileName

The test file uses Module._load to intercept require("vscode") and return a minimal stub. This technique is self-contained and does not require any new dependencies.

How to run

# New PHPCBF class tests:
node --test test/phpcbf.test.js

# Existing findFiles tests (unchanged):
npm run test:unit

# Both together:
node --test test/unit.test.js test/phpcbf.test.js

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

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants