[Repo Assist] test: add 3 unit tests for findFiles name-priority, depth-priority, and empty-names#113
Draft
github-actions[bot] wants to merge 1 commit intomasterfrom
Conversation
…nd empty-names Documents the exact selection behaviour of findFiles when multiple config-file candidates are present, which is relied on by getStandard() to honour PHPCS config-file priority (.phpcs.xml beats phpcs.xml). New tests: - 'returns first matching name when multiple config files exist in same directory': verifies that .phpcs.xml is preferred over phpcs.xml when both are present, matching PHPCS priority rules. - 'prefers file in deeper directory over ancestor when names overlap': explicit counterpart to the existing depth test using the same name in root and sub-dir, making the deepest-first behaviour unambiguous. - 'returns null for empty names array': defensive edge case; ensures an empty candidates list never throws and always returns null. All 10 tests pass (node --test test/unit.test.js). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 29, 2026
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 three targeted unit tests to
test/unit.test.jsthat document and pin the exact selection behaviour offindFiles()when multiple config-file candidates compete. These cases are relied on bygetStandard()to apply the correct PHPCS config-file priority.New tests
returns first matching name when multiple config files exist in same directory.phpcs.xmlbeatsphpcs.xmlwhen both are present — matching PHPCS priority rules. Thenamesarray order is the tiebreaker.prefers file in deeper directory over ancestor when names overlapreturns file in the deepest matching directory when multiple existtest with an identical-name scenario.returns null for empty names arraynull.Why these tests matter
The existing test suite verified array-of-names handling only when a single file existed; there was no test confirming which candidate wins when multiple files are present. Without a pinning test, a refactor could accidentally reverse the priority order, silently breaking PHPCS config detection for any project that has both
.phpcs.xmlandphpcs.xml.Test Status
✅ All 10 unit tests pass (7 existing + 3 new):
✅ Syntax check:
node --check extension.js— no errors