Skip to content

[Repo Assist] test: add unit tests for PHPCBF.findFiles config-search logic#57

Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/test-improvements-findfiles-2026-03-09-c6581aa20a7b2517
Draft

[Repo Assist] test: add unit tests for PHPCBF.findFiles config-search logic#57
github-actions[bot] wants to merge 1 commit intomasterfrom
repo-assist/test-improvements-findfiles-2026-03-09-c6581aa20a7b2517

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Mar 9, 2026

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

Summary

Replaces the placeholder "Something 1" test with six meaningful unit tests for PHPCBF.findFiles() — the core method behind the phpcbf.configSearch feature.

Also exports the PHPCBF class from extension.js so it can be imported in the test suite.

Tests Added (test/extension.test.js)

Test What it checks
finds config file in the same directory Basic discovery when config sits next to the PHP file
finds config file in a parent directory (walks up) The walk-up traversal that makes configSearch useful
returns null when no config file exists anywhere Graceful fallback when nothing is found
returns the first matching file when multiple names given Priority order of config file name candidates
prefers a closer (deeper) config file over a parent one Correct scoping in nested projects
does not search above the workspace root Prevents leaking into OS-level directories

Each test uses a fresh fs.mkdtempSync directory (created in setup, cleaned up in teardown) so tests are isolated and side-effect-free.

Why findFiles is the right target

  • It is pure filesystem logic — no VS Code UI or editor state needed, so tests run reliably in the extension host
  • It is non-trivial (path walking with multiple filename candidates, parent-stop boundary) and lacked any test coverage
  • Bugs here would silently break phpcbf.configSearch for all users

Test Status

These tests require the VS Code extension host (vscode/lib/testrunner) to run. The findFiles logic itself was manually verified with Node.js to confirm all six assertions hold before opening this PR. Infrastructure (no VS Code in CI) prevents automated test execution.

Generated by Repo Assist ·

To install this agentic workflow, run

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

Replace the placeholder 'Something 1' test with six meaningful unit
tests for the PHPCBF.findFiles() method, which is the core logic
behind the phpcbf.configSearch feature.

Tests cover:
- Config file found in the same directory
- Config file found by walking up to a parent directory
- Returns null when no config file exists
- Returns the first matching name when multiple candidates given
- Prefers a closer (deeper) config over a parent one
- Does not search above the workspace root

Also exports the PHPCBF class so it can be imported in tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Copy Markdown
Contributor Author

🤖 This is an automated note from Repo Assist.

This PR has been superseded by changes that landed on master via PR #66. Specifically:

As a result, merging this PR as-is would conflict with test/extension.test.js and introduce a stale export to extension.js.

I'd suggest closing this PR — the testing goal it set out to achieve is already covered on master. Thank you for the intent behind it!

Generated by Repo Assist ·

To install this agentic workflow, run

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

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