Skip to content

[Repo Assist] test: add unit tests for PHPCBF class and findFiles edge casesΒ #99

@github-actions

Description

@github-actions

πŸ€– This PR was created by Repo Assist, an automated AI assistant.

Summary

Significantly improves the test suite by adding 24 new unit tests for the PHPCBF class (previously untested) and 6 edge-case tests for findFiles. Total test count grows from 7 β†’ 36.

Changes

extension.js

  • Exports PHPCBF class (exports.PHPCBF = PHPCBF) so unit tests can instantiate it directly without requiring a VS Code Extension Host.

test/phpcbf.test.js (new)

Tests PHPCBF by injecting a lightweight vscode mock via Module._resolveFilename β€” no extension host required. Covers:

Suite What's tested
loadSettings Default values, config overrides, onsave, standard, debug, tilde (~) expansion in executablePath, re-load on config change
getArgs -lq vs -l flag (debug mode), tmpFileName placement, --standard=(value) presence/absence, argument ordering
getStandard configSearch: false pass-through, null workspace folder, phpcs.xml discovery, .phpcs.xml priority over phpcs.xml, fallback to this.standard, null standard

test/unit.test.js

Six new edge-case tests for findFiles:

  • Empty names array β†’ null
  • Empty-string directory (resolves to parent) β†’ finds file / returns null
  • Name-array priority: first match wins; falls through to second name when first absent

package.json

Updated test:unit script to run both test files: node --test test/unit.test.js test/phpcbf.test.js

Test Status

βœ” PHPCBF.loadSettings (10 tests)
βœ” PHPCBF.getArgs (7 tests)
βœ” PHPCBF.getStandard (7 tests)
βœ” findFiles (12 tests, up from 7)

tests 36 | pass 36 | fail 0

All tests pass with npm run test:unit.

Generated by Repo Assist Β· β—·

To install this agentic workflow, run

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

Warning

πŸ›‘οΈ Protected Files

This was originally intended as a pull request, but the patch modifies protected files: package.json.

These files may affect project dependencies, CI/CD pipelines, or agent behaviour. Please review the changes carefully before creating the pull request.

Click here to create the pull request once you have reviewed the changes

To route changes like this to a review issue instead of blocking, configure protected-files: fallback-to-issue in your workflow configuration.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions