AbstractFunctionRestrictionsSniff: improve namespaced names tests #2663
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.
Description
This PR improves the namespaced names tests for the sniffs that extend the
AbstractFunctionRestrictionsSniffclass based on what was discussed during the review of #2581 and #2620. The sniffsWordPress.Security.EscapeOutputandWordPress.WP.AlternativeFunctionsare not included here as they are addressed separately in #2618 and #2617, respectively.WP/DiscouragedFunctions: rename test case file
Doing this to be able to move an intentional syntax error test to its own file.
WP/DiscouragedFunctions: move syntax error test to its own file
Tests: non-standard case function call tests for sniffs extending AbstractFunctionRestrictionsSniff
This commit ensures that the tests for all sniffs extending the
AbstractFunctionRestrictionsSniffclass contain a test with a non-standard case, an unqualified, and a fully qualified function call. In some cases, it was possible to update an existing test, and in other cases, it was necessary to add a new one.For small test files, new tests were inserted alongside related existing tests (rather than appended at the end) to keep similar test cases grouped. The improved test organization should outweigh the added review complexity due to the need to update line numbers in test expectations.
Two sniffs that extend AbstractFunctionRestrictionsSniff will be addressed separately:
WordPress.Security.EscapeOutputandWordPress.WP.AlternativeFunctions.Tests: add namespace\Sub\ tests for sniffs extending AbstractFunctionRestrictionsSniff
This commit adds
namespace\Sub\function_name()test cases to all test files for sniffs extendingAbstractFunctionRestrictionsSniff.Two sniffs that extend
AbstractFunctionRestrictionsSniffwill be addressed separately:WordPress.Security.EscapeOutputandWordPress.WP.AlternativeFunctions.Tests: vary function names in namespace tests for sniffs extending AbstractFunctionRestrictionsSniff
As suggested in 2581, for sniffs that check multiple functions, the namespace name tests now use different function names rather than repeatedly testing the same function.
Two sniffs that extend AbstractFunctionRestrictionsSniff will be addressed separately:
WordPress.Security.EscapeOutputandWordPress.WP.AlternativeFunctions.Suggested changelog entry
N/A