From e01762b1fbf550ac0b2924db20e7b5acb8af8361 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 12 Sep 2019 16:15:49 +0200 Subject: [PATCH 1/3] Tests: allow for recording code coverage + add `@covers` tags ... to all unit test files, as well as enable strict coverage recording. Includes: * PHPUnit config: add code coverage configuration. By default, when there is a code coverage configuration and Xdebug is enabled, code coverage will be generated. Note: generating code coverage is slow. * Git ignore the `build` directory as created by PHPUnit to store the log files (as set up in the config file). * Composer: add coverage script and adjust the test script. * When running the "normal" `run-tests`, no code coverage will be created. * To run the tests with code coverage, the new `coverage` script has been added. When running PHPUnit locally, I'd recommend copying the `phpunit.xml.dist` file to `phpunit.xml` and replacing the `clover` logging with the following to allow for locally using the HTML report: ```xml ``` NOte: this commit does not set up code coverage checking for PRs via an external service like Coveralls or CodeCov, though I imagine we could set this up in the future as the WP organisation already has a CodeCov account (we'd need to check if we can or need permission). --- .gitignore | 3 ++- .../ArrayDeclarationSpacingUnitTest.php | 2 ++ .../Tests/Arrays/ArrayIndentationUnitTest.php | 2 ++ .../ArrayKeySpacingRestrictionsUnitTest.php | 2 ++ .../Arrays/CommaAfterArrayItemUnitTest.php | 2 ++ .../MultipleStatementAlignmentUnitTest.php | 2 ++ .../AssignmentInTernaryConditionUnitTest.php | 2 ++ .../EscapedNotTranslatedUnitTest.php | 2 ++ .../Tests/DB/DirectDatabaseQueryUnitTest.php | 2 ++ .../DB/PreparedSQLPlaceholdersUnitTest.php | 2 ++ WordPress/Tests/DB/PreparedSQLUnitTest.php | 2 ++ .../Tests/DB/RestrictedClassesUnitTest.php | 2 ++ .../Tests/DB/RestrictedFunctionsUnitTest.php | 2 ++ WordPress/Tests/DB/SlowDBQueryUnitTest.php | 2 ++ .../DateTime/CurrentTimeTimestampUnitTest.php | 2 ++ .../DateTime/RestrictedFunctionsUnitTest.php | 2 ++ WordPress/Tests/Files/FileNameUnitTest.php | 2 ++ .../PrefixAllGlobalsUnitTest.php | 2 ++ .../ValidFunctionNameUnitTest.php | 2 ++ .../ValidHookNameUnitTest.php | 2 ++ .../ValidPostTypeSlugUnitTest.php | 2 ++ .../ValidVariableNameUnitTest.php | 2 ++ .../PHP/DevelopmentFunctionsUnitTest.php | 2 ++ .../PHP/DiscouragedPHPFunctionsUnitTest.php | 2 ++ WordPress/Tests/PHP/DontExtractUnitTest.php | 2 ++ WordPress/Tests/PHP/IniSetUnitTest.php | 2 ++ .../Tests/PHP/NoSilencedErrorsUnitTest.php | 2 ++ .../Tests/PHP/POSIXFunctionsUnitTest.php | 2 ++ .../Tests/PHP/PregQuoteDelimiterUnitTest.php | 2 ++ .../PHP/RestrictedPHPFunctionsUnitTest.php | 2 ++ WordPress/Tests/PHP/StrictInArrayUnitTest.php | 2 ++ WordPress/Tests/PHP/TypeCastsUnitTest.php | 2 ++ .../Tests/PHP/YodaConditionsUnitTest.php | 2 ++ .../Tests/Security/EscapeOutputUnitTest.php | 2 ++ .../Security/NonceVerificationUnitTest.php | 2 ++ .../Tests/Security/PluginMenuSlugUnitTest.php | 2 ++ .../Tests/Security/SafeRedirectUnitTest.php | 2 ++ .../ValidatedSanitizedInputUnitTest.php | 2 ++ .../Utils/I18nTextDomainFixerUnitTest.php | 2 ++ .../Tests/WP/AlternativeFunctionsUnitTest.php | 2 ++ WordPress/Tests/WP/CapabilitiesUnitTest.php | 2 ++ WordPress/Tests/WP/CapitalPDangitUnitTest.php | 2 ++ WordPress/Tests/WP/ClassNameCaseUnitTest.php | 2 ++ WordPress/Tests/WP/CronIntervalUnitTest.php | 2 ++ .../Tests/WP/DeprecatedClassesUnitTest.php | 2 ++ .../Tests/WP/DeprecatedFunctionsUnitTest.php | 2 ++ .../WP/DeprecatedParameterValuesUnitTest.php | 2 ++ .../Tests/WP/DeprecatedParametersUnitTest.php | 2 ++ .../Tests/WP/DiscouragedConstantsUnitTest.php | 2 ++ .../Tests/WP/DiscouragedFunctionsUnitTest.php | 2 ++ .../WP/EnqueuedResourceParametersUnitTest.php | 2 ++ .../Tests/WP/EnqueuedResourcesUnitTest.php | 2 ++ .../WP/GlobalVariablesOverrideUnitTest.php | 2 ++ WordPress/Tests/WP/I18nUnitTest.php | 2 ++ WordPress/Tests/WP/PostsPerPageUnitTest.php | 2 ++ .../CastStructureSpacingUnitTest.php | 2 ++ .../ControlStructureSpacingUnitTest.php | 2 ++ .../ObjectOperatorSpacingUnitTest.php | 2 ++ .../WhiteSpace/OperatorSpacingUnitTest.php | 2 ++ composer.json | 6 +++++- phpunit.xml.dist | 21 ++++++++++++++++++- 61 files changed, 143 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index bfec4c3c30..9e9c75d11d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -vendor +vendor/ composer.lock +build/ phpunit.xml phpcs.xml .phpcs.xml diff --git a/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php b/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php index 482c22490c..ea45ae434e 100644 --- a/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php +++ b/WordPress/Tests/Arrays/ArrayDeclarationSpacingUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.11.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\Arrays\ArrayDeclarationSpacingSniff */ final class ArrayDeclarationSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php b/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php index 3291de971a..950c4b2506 100644 --- a/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php +++ b/WordPress/Tests/Arrays/ArrayIndentationUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.12.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\Arrays\ArrayIndentationSniff */ final class ArrayIndentationUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Arrays/ArrayKeySpacingRestrictionsUnitTest.php b/WordPress/Tests/Arrays/ArrayKeySpacingRestrictionsUnitTest.php index 8414f8ac31..2f871ad3db 100644 --- a/WordPress/Tests/Arrays/ArrayKeySpacingRestrictionsUnitTest.php +++ b/WordPress/Tests/Arrays/ArrayKeySpacingRestrictionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\Arrays\ArrayKeySpacingRestrictionsSniff */ final class ArrayKeySpacingRestrictionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php b/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php index 19741593b9..dd80994f62 100644 --- a/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php +++ b/WordPress/Tests/Arrays/CommaAfterArrayItemUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.12.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\Arrays\CommaAfterArrayItemSniff */ final class CommaAfterArrayItemUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php b/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php index 84aeb96181..075df264a2 100644 --- a/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php +++ b/WordPress/Tests/Arrays/MultipleStatementAlignmentUnitTest.php @@ -21,6 +21,8 @@ * @package WPCS\WordPressCodingStandards * * @since 0.14.0 + * + * @covers \WordPressCS\WordPress\Sniffs\Arrays\MultipleStatementAlignmentSniff */ final class MultipleStatementAlignmentUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/CodeAnalysis/AssignmentInTernaryConditionUnitTest.php b/WordPress/Tests/CodeAnalysis/AssignmentInTernaryConditionUnitTest.php index 2c6d4eb998..dbba1575e4 100644 --- a/WordPress/Tests/CodeAnalysis/AssignmentInTernaryConditionUnitTest.php +++ b/WordPress/Tests/CodeAnalysis/AssignmentInTernaryConditionUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 0.14.0 + * + * @covers \WordPressCS\WordPress\Sniffs\CodeAnalysis\AssignmentInTernaryConditionSniff */ final class AssignmentInTernaryConditionUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/CodeAnalysis/EscapedNotTranslatedUnitTest.php b/WordPress/Tests/CodeAnalysis/EscapedNotTranslatedUnitTest.php index 6caee59867..245ae7f17e 100644 --- a/WordPress/Tests/CodeAnalysis/EscapedNotTranslatedUnitTest.php +++ b/WordPress/Tests/CodeAnalysis/EscapedNotTranslatedUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 2.2.0 + * + * @covers \WordPressCS\WordPress\Sniffs\CodeAnalysis\EscapedNotTranslatedSniff */ final class EscapedNotTranslatedUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php b/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php index 4d425b392b..aa76e463ac 100644 --- a/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php +++ b/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php @@ -19,6 +19,8 @@ * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `DB` category. + * + * @covers \WordPressCS\WordPress\Sniffs\DB\DirectDatabaseQuerySniff */ final class DirectDatabaseQueryUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.php b/WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.php index 61decb7521..7c133a554a 100644 --- a/WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.php +++ b/WordPress/Tests/DB/PreparedSQLPlaceholdersUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 0.14.0 + * + * @covers \WordPressCS\WordPress\Sniffs\DB\PreparedSQLPlaceholdersSniff */ final class PreparedSQLPlaceholdersUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DB/PreparedSQLUnitTest.php b/WordPress/Tests/DB/PreparedSQLUnitTest.php index 5ff2c8f616..aa15964c48 100644 --- a/WordPress/Tests/DB/PreparedSQLUnitTest.php +++ b/WordPress/Tests/DB/PreparedSQLUnitTest.php @@ -19,6 +19,8 @@ * @since 0.8.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `WP` category to the `DB` category. + * + * @covers \WordPressCS\WordPress\Sniffs\DB\PreparedSQLSniff */ final class PreparedSQLUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DB/RestrictedClassesUnitTest.php b/WordPress/Tests/DB/RestrictedClassesUnitTest.php index 05a522e9de..f9365a9441 100644 --- a/WordPress/Tests/DB/RestrictedClassesUnitTest.php +++ b/WordPress/Tests/DB/RestrictedClassesUnitTest.php @@ -20,6 +20,8 @@ * @since 0.10.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 3.0.0 Renamed the fixtures to create compatibility with PHPCS 4.x/PHPUnit >=8. + * + * @covers \WordPressCS\WordPress\Sniffs\DB\RestrictedClassesSniff */ final class RestrictedClassesUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DB/RestrictedFunctionsUnitTest.php b/WordPress/Tests/DB/RestrictedFunctionsUnitTest.php index e37298a136..521c39df4f 100644 --- a/WordPress/Tests/DB/RestrictedFunctionsUnitTest.php +++ b/WordPress/Tests/DB/RestrictedFunctionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.10.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\DB\RestrictedFunctionsSniff */ final class RestrictedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DB/SlowDBQueryUnitTest.php b/WordPress/Tests/DB/SlowDBQueryUnitTest.php index 62753ee481..82b1c9aaae 100644 --- a/WordPress/Tests/DB/SlowDBQueryUnitTest.php +++ b/WordPress/Tests/DB/SlowDBQueryUnitTest.php @@ -19,6 +19,8 @@ * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `DB` category. + * + * @covers \WordPressCS\WordPress\Sniffs\DB\SlowDBQuerySniff */ final class SlowDBQueryUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.php b/WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.php index e1eae57eb0..44984710c5 100644 --- a/WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.php +++ b/WordPress/Tests/DateTime/CurrentTimeTimestampUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 2.2.0 + * + * @covers \WordPressCS\WordPress\Sniffs\DateTime\CurrentTimeTimestampSniff */ final class CurrentTimeTimestampUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.php b/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.php index 53fdbbd2ca..97a90bed48 100644 --- a/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.php +++ b/WordPress/Tests/DateTime/RestrictedFunctionsUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 2.2.0 + * + * @covers \WordPressCS\WordPress\Sniffs\DateTime\RestrictedFunctionsSniff */ final class RestrictedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Files/FileNameUnitTest.php b/WordPress/Tests/Files/FileNameUnitTest.php index 29deb6403e..e29d57099a 100644 --- a/WordPress/Tests/Files/FileNameUnitTest.php +++ b/WordPress/Tests/Files/FileNameUnitTest.php @@ -19,6 +19,8 @@ * @since 2013-06-11 * @since 0.11.0 Actually added tests ;-) * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\Files\FileNameSniff */ final class FileNameUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php index 3cd0128329..cef6b3c362 100644 --- a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php +++ b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.12.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\PrefixAllGlobalsSniff */ final class PrefixAllGlobalsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php index 49a787b68d..f9632c6166 100644 --- a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -18,6 +18,8 @@ * * @since 2013-06-11 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\ValidFunctionNameSniff */ final class ValidFunctionNameUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php index ddaabad882..65e724c0d4 100644 --- a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.10.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\ValidHookNameSniff */ final class ValidHookNameUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/ValidPostTypeSlugUnitTest.php b/WordPress/Tests/NamingConventions/ValidPostTypeSlugUnitTest.php index a20c4f2e24..9e9298a56e 100644 --- a/WordPress/Tests/NamingConventions/ValidPostTypeSlugUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidPostTypeSlugUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 2.2.0 + * + * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\ValidPostTypeSlugSniff */ final class ValidPostTypeSlugUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php index c5b4ec547a..9b56994feb 100644 --- a/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.9.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\ValidVariableNameSniff */ final class ValidVariableNameUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/DevelopmentFunctionsUnitTest.php b/WordPress/Tests/PHP/DevelopmentFunctionsUnitTest.php index 67da444d39..efc4b9c919 100644 --- a/WordPress/Tests/PHP/DevelopmentFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/DevelopmentFunctionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.11.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\DevelopmentFunctionsSniff */ final class DevelopmentFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/DiscouragedPHPFunctionsUnitTest.php b/WordPress/Tests/PHP/DiscouragedPHPFunctionsUnitTest.php index bd8c5aad27..019996f116 100644 --- a/WordPress/Tests/PHP/DiscouragedPHPFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/DiscouragedPHPFunctionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.11.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\DiscouragedPHPFunctionsSniff */ final class DiscouragedPHPFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/DontExtractUnitTest.php b/WordPress/Tests/PHP/DontExtractUnitTest.php index c86ab344d8..45d63f6de0 100644 --- a/WordPress/Tests/PHP/DontExtractUnitTest.php +++ b/WordPress/Tests/PHP/DontExtractUnitTest.php @@ -19,6 +19,8 @@ * @since 0.10.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `Functions` category to the `PHP` category. + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\DontExtractSniff */ final class DontExtractUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/IniSetUnitTest.php b/WordPress/Tests/PHP/IniSetUnitTest.php index abca628317..573c24c430 100644 --- a/WordPress/Tests/PHP/IniSetUnitTest.php +++ b/WordPress/Tests/PHP/IniSetUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 2.1.0 + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\IniSetSniff */ final class IniSetUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/NoSilencedErrorsUnitTest.php b/WordPress/Tests/PHP/NoSilencedErrorsUnitTest.php index 0867ed8419..b4ee45892a 100644 --- a/WordPress/Tests/PHP/NoSilencedErrorsUnitTest.php +++ b/WordPress/Tests/PHP/NoSilencedErrorsUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 1.1.0 + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\NoSilencedErrorsSniff */ final class NoSilencedErrorsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/POSIXFunctionsUnitTest.php b/WordPress/Tests/PHP/POSIXFunctionsUnitTest.php index bfadfe6b35..c24ceda461 100644 --- a/WordPress/Tests/PHP/POSIXFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/POSIXFunctionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.10.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\POSIXFunctionsSniff */ final class POSIXFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/PregQuoteDelimiterUnitTest.php b/WordPress/Tests/PHP/PregQuoteDelimiterUnitTest.php index fe84b6f445..dcb0948838 100644 --- a/WordPress/Tests/PHP/PregQuoteDelimiterUnitTest.php +++ b/WordPress/Tests/PHP/PregQuoteDelimiterUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 1.0.0 + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\PregQuoteDelimiterSniff */ final class PregQuoteDelimiterUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php index 8ed0c52e94..ea4aa098ce 100644 --- a/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php +++ b/WordPress/Tests/PHP/RestrictedPHPFunctionsUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 0.14.0 + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\RestrictedPHPFunctionsSniff */ final class RestrictedPHPFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/StrictInArrayUnitTest.php b/WordPress/Tests/PHP/StrictInArrayUnitTest.php index c8174a3595..6f5225a65a 100644 --- a/WordPress/Tests/PHP/StrictInArrayUnitTest.php +++ b/WordPress/Tests/PHP/StrictInArrayUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.9.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\StrictInArraySniff */ final class StrictInArrayUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/TypeCastsUnitTest.php b/WordPress/Tests/PHP/TypeCastsUnitTest.php index db837c8b97..de2dd0d5ad 100644 --- a/WordPress/Tests/PHP/TypeCastsUnitTest.php +++ b/WordPress/Tests/PHP/TypeCastsUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 1.2.0 + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\TypeCastsSniff */ final class TypeCastsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/YodaConditionsUnitTest.php b/WordPress/Tests/PHP/YodaConditionsUnitTest.php index cd87e263a9..eac33f7a8a 100644 --- a/WordPress/Tests/PHP/YodaConditionsUnitTest.php +++ b/WordPress/Tests/PHP/YodaConditionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\PHP\YodaConditionsSniff */ final class YodaConditionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Security/EscapeOutputUnitTest.php b/WordPress/Tests/Security/EscapeOutputUnitTest.php index 6054315a7c..3e460950aa 100644 --- a/WordPress/Tests/Security/EscapeOutputUnitTest.php +++ b/WordPress/Tests/Security/EscapeOutputUnitTest.php @@ -19,6 +19,8 @@ * @since 2013-06-11 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `XSS` category to the `Security` category. + * + * @covers \WordPressCS\WordPress\Sniffs\Security\EscapeOutputSniff */ final class EscapeOutputUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Security/NonceVerificationUnitTest.php b/WordPress/Tests/Security/NonceVerificationUnitTest.php index 4f164d0d33..2fb94c8da5 100644 --- a/WordPress/Tests/Security/NonceVerificationUnitTest.php +++ b/WordPress/Tests/Security/NonceVerificationUnitTest.php @@ -19,6 +19,8 @@ * @since 0.5.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `CSRF` category to the `Security` category. + * + * @covers \WordPressCS\WordPress\Sniffs\Security\NonceVerificationSniff */ final class NonceVerificationUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Security/PluginMenuSlugUnitTest.php b/WordPress/Tests/Security/PluginMenuSlugUnitTest.php index 8555d23212..b77830614e 100644 --- a/WordPress/Tests/Security/PluginMenuSlugUnitTest.php +++ b/WordPress/Tests/Security/PluginMenuSlugUnitTest.php @@ -19,6 +19,8 @@ * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `Security` category. + * + * @covers \WordPressCS\WordPress\Sniffs\Security\PluginMenuSlugSniff */ final class PluginMenuSlugUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Security/SafeRedirectUnitTest.php b/WordPress/Tests/Security/SafeRedirectUnitTest.php index b42d75b9fa..0cf00822e3 100644 --- a/WordPress/Tests/Security/SafeRedirectUnitTest.php +++ b/WordPress/Tests/Security/SafeRedirectUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 1.0.0 + * + * @covers \WordPressCS\WordPress\Sniffs\Security\SafeRedirectSniff */ final class SafeRedirectUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php b/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php index 1337bbe669..290c0903cd 100644 --- a/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php +++ b/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php @@ -19,6 +19,8 @@ * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `Security` category. + * + * @covers \WordPressCS\WordPress\Sniffs\Security\ValidatedSanitizedInputSniff */ final class ValidatedSanitizedInputUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php b/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php index e89b04bf50..dd0c6dc488 100644 --- a/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php +++ b/WordPress/Tests/Utils/I18nTextDomainFixerUnitTest.php @@ -18,6 +18,8 @@ * @package WPCS\WordPressCodingStandards * * @since 1.2.0 + * + * @covers \WordPressCS\WordPress\Sniffs\Utils\I18nTextDomainFixerSniff */ final class I18nTextDomainFixerUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php index 497b4682ad..dd847fd008 100644 --- a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php +++ b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.11.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\AlternativeFunctionsSniff */ final class AlternativeFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/CapabilitiesUnitTest.php b/WordPress/Tests/WP/CapabilitiesUnitTest.php index 38ae5f4f0d..ca26338aa4 100644 --- a/WordPress/Tests/WP/CapabilitiesUnitTest.php +++ b/WordPress/Tests/WP/CapabilitiesUnitTest.php @@ -17,6 +17,8 @@ * * @package WPCS\WordPressCodingStandards * @since 3.0.0 + * + * @covers \WordPressCS\WordPress\Sniffs\WP\CapabilitiesSniff */ final class CapabilitiesUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/CapitalPDangitUnitTest.php b/WordPress/Tests/WP/CapitalPDangitUnitTest.php index c222ac3725..2c61e7e715 100644 --- a/WordPress/Tests/WP/CapitalPDangitUnitTest.php +++ b/WordPress/Tests/WP/CapitalPDangitUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.12.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\CapitalPDangitSniff */ final class CapitalPDangitUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/ClassNameCaseUnitTest.php b/WordPress/Tests/WP/ClassNameCaseUnitTest.php index c91b007160..c7a7108a81 100644 --- a/WordPress/Tests/WP/ClassNameCaseUnitTest.php +++ b/WordPress/Tests/WP/ClassNameCaseUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 3.0.0 + * + * @covers \WordPressCS\WordPress\Sniffs\WP\ClassNameCaseSniff */ final class ClassNameCaseUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/CronIntervalUnitTest.php b/WordPress/Tests/WP/CronIntervalUnitTest.php index a77d930230..06a9cbf389 100644 --- a/WordPress/Tests/WP/CronIntervalUnitTest.php +++ b/WordPress/Tests/WP/CronIntervalUnitTest.php @@ -19,6 +19,8 @@ * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `WP` category. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\CronIntervalSniff */ final class CronIntervalUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/DeprecatedClassesUnitTest.php b/WordPress/Tests/WP/DeprecatedClassesUnitTest.php index 73a34b6388..c6da2e5634 100644 --- a/WordPress/Tests/WP/DeprecatedClassesUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedClassesUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.12.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\DeprecatedClassesSniff */ final class DeprecatedClassesUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php index d7c44ab65e..700fb821fe 100644 --- a/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedFunctionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.11.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\DeprecatedFunctionsSniff */ final class DeprecatedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/DeprecatedParameterValuesUnitTest.php b/WordPress/Tests/WP/DeprecatedParameterValuesUnitTest.php index 50d104ec7f..8866c29979 100644 --- a/WordPress/Tests/WP/DeprecatedParameterValuesUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedParameterValuesUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 1.0.0 + * + * @covers \WordPressCS\WordPress\Sniffs\WP\DeprecatedParameterValuesSniff */ final class DeprecatedParameterValuesUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/DeprecatedParametersUnitTest.php b/WordPress/Tests/WP/DeprecatedParametersUnitTest.php index 78aa55d753..4372783b03 100644 --- a/WordPress/Tests/WP/DeprecatedParametersUnitTest.php +++ b/WordPress/Tests/WP/DeprecatedParametersUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.12.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\DeprecatedParametersSniff */ final class DeprecatedParametersUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/DiscouragedConstantsUnitTest.php b/WordPress/Tests/WP/DiscouragedConstantsUnitTest.php index cadcffd534..605c5cf49a 100644 --- a/WordPress/Tests/WP/DiscouragedConstantsUnitTest.php +++ b/WordPress/Tests/WP/DiscouragedConstantsUnitTest.php @@ -16,6 +16,8 @@ * * @package WPCS\WordPressCodingStandards * @since 0.14.0 + * + * @covers \WordPressCS\WordPress\Sniffs\WP\DiscouragedConstantsSniff */ final class DiscouragedConstantsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php b/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php index 814a9b9cae..fbb88b14e1 100644 --- a/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php +++ b/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.11.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\DiscouragedFunctionsSniff */ final class DiscouragedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php index 17ad318abd..59d91d0c44 100644 --- a/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php +++ b/WordPress/Tests/WP/EnqueuedResourceParametersUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 1.0.0 + * + * @covers \WordPressCS\WordPress\Sniffs\WP\EnqueuedResourceParametersSniff */ final class EnqueuedResourceParametersUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php b/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php index 83b735b9ce..0eae7f1bc8 100644 --- a/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php +++ b/WordPress/Tests/WP/EnqueuedResourcesUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\EnqueuedResourcesSniff */ final class EnqueuedResourcesUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php b/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php index de2194ccdc..e867623e08 100644 --- a/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php +++ b/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php @@ -20,6 +20,8 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `Variables` category to the `WP` * category and renamed from `GlobalVariables` to `GlobalVariablesOverride`. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\GlobalVariablesOverrideSniff */ final class GlobalVariablesOverrideUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/I18nUnitTest.php b/WordPress/Tests/WP/I18nUnitTest.php index ee45944f60..be011054f9 100644 --- a/WordPress/Tests/WP/I18nUnitTest.php +++ b/WordPress/Tests/WP/I18nUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.10.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\I18nSniff */ final class I18nUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/PostsPerPageUnitTest.php b/WordPress/Tests/WP/PostsPerPageUnitTest.php index 7a302347fa..ef848320d2 100644 --- a/WordPress/Tests/WP/PostsPerPageUnitTest.php +++ b/WordPress/Tests/WP/PostsPerPageUnitTest.php @@ -21,6 +21,8 @@ * @since 1.0.0 This sniff has been split into two, with the check for high pagination * limit being part of the WP category, and the check for pagination * disabling being part of the VIP category. + * + * @covers \WordPressCS\WordPress\Sniffs\WP\PostsPerPageSniff */ final class PostsPerPageUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php b/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php index f46131110a..90ca0000dd 100644 --- a/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php +++ b/WordPress/Tests/WhiteSpace/CastStructureSpacingUnitTest.php @@ -18,6 +18,8 @@ * * @since 0.3.0 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WhiteSpace\CastStructureSpacingSniff */ final class CastStructureSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php index e7e8494a45..1cd2bde66c 100644 --- a/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php +++ b/WordPress/Tests/WhiteSpace/ControlStructureSpacingUnitTest.php @@ -18,6 +18,8 @@ * * @since 2013-06-11 * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WhiteSpace\ControlStructureSpacingSniff */ final class ControlStructureSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php b/WordPress/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php index 52a3776022..cd6d22955f 100644 --- a/WordPress/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php +++ b/WordPress/Tests/WhiteSpace/ObjectOperatorSpacingUnitTest.php @@ -17,6 +17,8 @@ * @package WPCS\WordPressCodingStandards * * @since 3.0.0 + * + * @covers \WordPressCS\WordPress\Sniffs\WhiteSpace\ObjectOperatorSpacingSniff */ final class ObjectOperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php b/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php index 09aa9efec3..aa60ee4cd6 100644 --- a/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php +++ b/WordPress/Tests/WhiteSpace/OperatorSpacingUnitTest.php @@ -20,6 +20,8 @@ * @since 0.12.0 Now only tests the WPCS specific addition of T_BOOLEAN_NOT. * The rest of the sniff is unit tested upstream. * @since 0.13.0 Class name changed: this class is now namespaced. + * + * @covers \WordPressCS\WordPress\Sniffs\WhiteSpace\OperatorSpacingSniff */ final class OperatorSpacingUnitTest extends AbstractSniffUnitTest { diff --git a/composer.json b/composer.json index cf1c2ccb23..db34b5ff6c 100644 --- a/composer.json +++ b/composer.json @@ -48,6 +48,9 @@ "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf" ], "run-tests": [ + "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/squizlabs/php_codesniffer/tests/AllTests.php --no-coverage" + ], + "coverage": [ "@php ./vendor/phpunit/phpunit/phpunit --filter WordPress ./vendor/squizlabs/php_codesniffer/tests/AllTests.php" ], "check-complete": [ @@ -67,7 +70,8 @@ "lint": "Lint PHP files against parse errors.", "check-cs": "Run the PHPCS script against the entire codebase.", "fix-cs": "Run the PHPCBF script to fix all the autofixable violations on the codebase.", - "run-tests": "Run all the unit tests for the WordPress Coding Standards sniffs.", + "run-tests": "Run all the unit tests for the WordPress Coding Standards sniffs without code coverage.", + "coverage": "Run all the unit tests for the WordPress Coding Standards sniffs with code coverage.", "check-complete": "Check if all the sniffs have tests.", "check-complete-strict": "Check if all the sniffs have unit tests and XML documentation.", "check-all": "Run all checks (lint, phpcs, feature completeness) and tests." diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4bd81b342a..34c93a6263 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,7 +5,8 @@ backupGlobals="true" bootstrap="./Tests/bootstrap.php" beStrictAboutTestsThatDoNotTestAnything="false" - colors="true"> + colors="true" + forceCoversAnnotation="true"> @@ -13,4 +14,22 @@ + + + ./WordPress/Sniff.php + ./WordPress/PHPCSHelper.php + ./WordPress/AbstractArrayAssignmentRestrictionsSniff.php + ./WordPress/AbstractClassRestrictionsSniff.php + ./WordPress/AbstractFunctionParameterSniff.php + ./WordPress/AbstractFunctionRestrictionsSniff.php + ./WordPress/Sniffs/ + ./WordPress/Helpers/ + + + + + + + + From 391caeab14bacc0ce1ae55f2b27f4600c4ee2580 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 8 Apr 2023 16:29:28 +0200 Subject: [PATCH 2/3] Tests: add `@covers` tags for Helpers As the `Helpers` in WPCS do not have dedicated tests, but are tested via the sniffs using them, I'm adding `@covers` tags for these to select sniffs. At a later point in time, we can revisit whether or not to add dedicated tests for the Helpers. --- WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php | 1 + WordPress/Tests/DB/PreparedSQLUnitTest.php | 1 + WordPress/Tests/DB/RestrictedClassesUnitTest.php | 1 + WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php | 1 + WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php | 1 + WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php | 1 + WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php | 1 + WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php | 1 + WordPress/Tests/WP/AlternativeFunctionsUnitTest.php | 1 + WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php | 1 + 10 files changed, 10 insertions(+) diff --git a/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php b/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php index aa76e463ac..349e20991c 100644 --- a/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php +++ b/WordPress/Tests/DB/DirectDatabaseQueryUnitTest.php @@ -20,6 +20,7 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `DB` category. * + * @covers \WordPressCS\WordPress\Helpers\RulesetPropertyHelper * @covers \WordPressCS\WordPress\Sniffs\DB\DirectDatabaseQuerySniff */ final class DirectDatabaseQueryUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DB/PreparedSQLUnitTest.php b/WordPress/Tests/DB/PreparedSQLUnitTest.php index aa15964c48..d707ac3960 100644 --- a/WordPress/Tests/DB/PreparedSQLUnitTest.php +++ b/WordPress/Tests/DB/PreparedSQLUnitTest.php @@ -20,6 +20,7 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `WP` category to the `DB` category. * + * @covers \WordPressCS\WordPress\Helpers\WPDBTrait * @covers \WordPressCS\WordPress\Sniffs\DB\PreparedSQLSniff */ final class PreparedSQLUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/DB/RestrictedClassesUnitTest.php b/WordPress/Tests/DB/RestrictedClassesUnitTest.php index f9365a9441..1623e68682 100644 --- a/WordPress/Tests/DB/RestrictedClassesUnitTest.php +++ b/WordPress/Tests/DB/RestrictedClassesUnitTest.php @@ -21,6 +21,7 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * @since 3.0.0 Renamed the fixtures to create compatibility with PHPCS 4.x/PHPUnit >=8. * + * @covers \WordPressCS\WordPress\Helpers\RulesetPropertyHelper * @covers \WordPressCS\WordPress\Sniffs\DB\RestrictedClassesSniff */ final class RestrictedClassesUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php index cef6b3c362..03408c53e1 100644 --- a/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php +++ b/WordPress/Tests/NamingConventions/PrefixAllGlobalsUnitTest.php @@ -19,6 +19,7 @@ * @since 0.12.0 * @since 0.13.0 Class name changed: this class is now namespaced. * + * @covers \WordPressCS\WordPress\Helpers\IsUnitTestTrait * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\PrefixAllGlobalsSniff */ final class PrefixAllGlobalsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php index f9632c6166..9213827917 100644 --- a/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidFunctionNameUnitTest.php @@ -19,6 +19,7 @@ * @since 2013-06-11 * @since 0.13.0 Class name changed: this class is now namespaced. * + * @covers \WordPressCS\WordPress\Helpers\DeprecationHelper * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\ValidFunctionNameSniff */ final class ValidFunctionNameUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php index 65e724c0d4..ff0b7e5093 100644 --- a/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidHookNameUnitTest.php @@ -19,6 +19,7 @@ * @since 0.10.0 * @since 0.13.0 Class name changed: this class is now namespaced. * + * @covers \WordPressCS\WordPress\Helpers\WPHookHelper * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\ValidHookNameSniff */ final class ValidHookNameUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php b/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php index 9b56994feb..e69b1dd8f5 100644 --- a/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php +++ b/WordPress/Tests/NamingConventions/ValidVariableNameUnitTest.php @@ -19,6 +19,7 @@ * @since 0.9.0 * @since 0.13.0 Class name changed: this class is now namespaced. * + * @covers \WordPressCS\WordPress\Helpers\SnakeCaseHelper * @covers \WordPressCS\WordPress\Sniffs\NamingConventions\ValidVariableNameSniff */ final class ValidVariableNameUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php b/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php index 290c0903cd..ab4574aff0 100644 --- a/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php +++ b/WordPress/Tests/Security/ValidatedSanitizedInputUnitTest.php @@ -20,6 +20,7 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `Security` category. * + * @covers \WordPressCS\WordPress\Helpers\VariableHelper * @covers \WordPressCS\WordPress\Sniffs\Security\ValidatedSanitizedInputSniff */ final class ValidatedSanitizedInputUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php index dd847fd008..ffe0e4acc1 100644 --- a/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php +++ b/WordPress/Tests/WP/AlternativeFunctionsUnitTest.php @@ -19,6 +19,7 @@ * @since 0.11.0 * @since 0.13.0 Class name changed: this class is now namespaced. * + * @covers \WordPressCS\WordPress\Helpers\MinimumWPVersionTrait * @covers \WordPressCS\WordPress\Sniffs\WP\AlternativeFunctionsSniff */ final class AlternativeFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php b/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php index e867623e08..23fa6d1f9f 100644 --- a/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php +++ b/WordPress/Tests/WP/GlobalVariablesOverrideUnitTest.php @@ -21,6 +21,7 @@ * @since 1.0.0 This sniff has been moved from the `Variables` category to the `WP` * category and renamed from `GlobalVariables` to `GlobalVariablesOverride`. * + * @covers \WordPressCS\WordPress\Helpers\WPGlobalVariablesHelper * @covers \WordPressCS\WordPress\Sniffs\WP\GlobalVariablesOverrideSniff */ final class GlobalVariablesOverrideUnitTest extends AbstractSniffUnitTest { From 617224515785d89a6ce227e67ef3505c164119ef Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 8 Apr 2023 16:36:14 +0200 Subject: [PATCH 3/3] Tests: add `@covers` tags for abstract base sniff classes As the abstract sniff base classes in WPCS do not have dedicated tests, but are tested via the sniffs using them, I'm adding `@covers` tags for these to select sniffs. As the majority of these will at some point in the future be replaced by (fully tested) abstracts from PHPCSUtils, I'm not concerned with adding dedicated tests for these, so this will do until they are deprecated/removed. --- WordPress/Tests/DB/RestrictedClassesUnitTest.php | 1 + WordPress/Tests/DB/SlowDBQueryUnitTest.php | 1 + WordPress/Tests/PHP/StrictInArrayUnitTest.php | 1 + WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php | 1 + WordPress/Tests/WP/PostsPerPageUnitTest.php | 1 + 5 files changed, 5 insertions(+) diff --git a/WordPress/Tests/DB/RestrictedClassesUnitTest.php b/WordPress/Tests/DB/RestrictedClassesUnitTest.php index 1623e68682..1ee99d0840 100644 --- a/WordPress/Tests/DB/RestrictedClassesUnitTest.php +++ b/WordPress/Tests/DB/RestrictedClassesUnitTest.php @@ -21,6 +21,7 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * @since 3.0.0 Renamed the fixtures to create compatibility with PHPCS 4.x/PHPUnit >=8. * + * @covers \WordPressCS\WordPress\AbstractClassRestrictionsSniff * @covers \WordPressCS\WordPress\Helpers\RulesetPropertyHelper * @covers \WordPressCS\WordPress\Sniffs\DB\RestrictedClassesSniff */ diff --git a/WordPress/Tests/DB/SlowDBQueryUnitTest.php b/WordPress/Tests/DB/SlowDBQueryUnitTest.php index 82b1c9aaae..94aa230564 100644 --- a/WordPress/Tests/DB/SlowDBQueryUnitTest.php +++ b/WordPress/Tests/DB/SlowDBQueryUnitTest.php @@ -20,6 +20,7 @@ * @since 0.13.0 Class name changed: this class is now namespaced. * @since 1.0.0 This sniff has been moved from the `VIP` category to the `DB` category. * + * @covers \WordPressCS\WordPress\AbstractArrayAssignmentRestrictionsSniff * @covers \WordPressCS\WordPress\Sniffs\DB\SlowDBQuerySniff */ final class SlowDBQueryUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/PHP/StrictInArrayUnitTest.php b/WordPress/Tests/PHP/StrictInArrayUnitTest.php index 6f5225a65a..c430d94a34 100644 --- a/WordPress/Tests/PHP/StrictInArrayUnitTest.php +++ b/WordPress/Tests/PHP/StrictInArrayUnitTest.php @@ -19,6 +19,7 @@ * @since 0.9.0 * @since 0.13.0 Class name changed: this class is now namespaced. * + * @covers \WordPressCS\WordPress\AbstractFunctionParameterSniff * @covers \WordPressCS\WordPress\Sniffs\PHP\StrictInArraySniff */ final class StrictInArrayUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php b/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php index fbb88b14e1..93827ee355 100644 --- a/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php +++ b/WordPress/Tests/WP/DiscouragedFunctionsUnitTest.php @@ -19,6 +19,7 @@ * @since 0.11.0 * @since 0.13.0 Class name changed: this class is now namespaced. * + * @covers \WordPressCS\WordPress\AbstractFunctionRestrictionsSniff * @covers \WordPressCS\WordPress\Sniffs\WP\DiscouragedFunctionsSniff */ final class DiscouragedFunctionsUnitTest extends AbstractSniffUnitTest { diff --git a/WordPress/Tests/WP/PostsPerPageUnitTest.php b/WordPress/Tests/WP/PostsPerPageUnitTest.php index ef848320d2..42ea579a78 100644 --- a/WordPress/Tests/WP/PostsPerPageUnitTest.php +++ b/WordPress/Tests/WP/PostsPerPageUnitTest.php @@ -22,6 +22,7 @@ * limit being part of the WP category, and the check for pagination * disabling being part of the VIP category. * + * @covers \WordPressCS\WordPress\AbstractArrayAssignmentRestrictionsSniff * @covers \WordPressCS\WordPress\Sniffs\WP\PostsPerPageSniff */ final class PostsPerPageUnitTest extends AbstractSniffUnitTest {