Issue-46: Improve tests to match the error reported for the stub files with the expected error #62
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.
Summary
Fixes #46
This PR enhances the reliability and accuracy of failing test fixtures by ensuring that the errors reported by PHPCS in stub files match the expected errors defined in new "expectations" files. It introduces per-test error expectations, so stub files now fail only for the intended, documented reasons, not for unrelated issues.
Key Changes
Test Enhancements:
process_phpcs_outputensures that unexpected errors cause test failures, increasing test reliability.Expectations Directory:
tests/fixtures/fail/expectations/directory containing new PHP files that specify the expected code standard violations for each failing fixture.Composer Script:
phpcs:expectationsto easily run PHPCS checks specifically against the expectations directory and surface only relevant errors.Documentation Updates:
Motivation
Previously, stub files intended to fail could do so for reasons unrelated to the specific test, making it difficult to ensure that the right coding standard was being enforced. This update aligns test failures with explicit expectations, inspired by practices in Automattic/VIP-Coding-Standards, and directly addresses the concerns raised in #46.
Testing
composer phpcs:expectations) runs successfully and surfaces only expected errors.Additional Notes