Make WordPress Core

Changeset 56594 for trunk/phpcs.xml.dist


Ignore:
Timestamp:
09/15/2023 10:45:18 AM (12 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Remove the custom property for the FileName sniff.

Test files should comply with the naming conventions accepted by PHPUnit, not with the WP naming conventions.

While the WordPress.File.FileName sniff makes a best effort to prevent throwing errors for files containing test classes, the recommended manner to deal with test files is to exclude the complete test directory from being subject to this sniff.

This updates the ruleset to follow the recommendation.

Follow-up to [42346], [45607].

Props jrf.
See #59161.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/phpcs.xml.dist

    r56593 r56594  
    151151    <rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
    152152        <type>warning</type>
    153     </rule>
    154 
    155     <!-- Allow test classes for select sniffs. -->
    156     <rule ref="WordPress.Files.FileName">
    157         <properties>
    158             <property name="custom_test_class_whitelist" type="array">
    159                 <!-- Test case parent classes in the "includes" folder, not yet accounted for in WPCS. -->
    160                 <element value="PHPUnit_Adapter_TestCase"/>
    161                 <element value="WP_Test_XML_TestCase"/>
    162 
    163                 <!-- Test case parent classes outside of the "includes" folder. -->
    164                 <element value="Tests_Query_Conditionals"/>
    165                 <element value="WP_Block_Templates_UnitTestCase"/>
    166                 <element value="WP_Filesystem_UnitTestCase"/>
    167                 <element value="WP_HTTP_UnitTestCase"/>
    168                 <element value="WP_Image_UnitTestCase"/>
    169                 <element value="WP_Import_UnitTestCase"/>
    170                 <element value="WP_Test_Adjacent_Image_Link_TestCase"/>
    171                 <element value="WP_Tests_Image_Resize_UnitTestCase"/>
    172                 <element value="WP_Theme_UnitTestCase"/>
    173                 <element value="WP_Font_Face_UnitTestCase"/>
    174 
    175                 <!-- Mock classes. -->
    176                 <element value="Spy_REST_Server"/>
    177                 <element value="WP_REST_Test_Controller"/>
    178                 <element value="WP_Image_Editor_Mock"/>
    179                 <element value="WP_Filesystem_MockFS"/>
    180                 <element value="Mock_Invokable"/>
    181                 <element value="MockPHPMailer"/>
    182                 <element value="MockAction"/>
    183                 <element value="WP_Object_Cache"/>
    184 
    185                 <!-- PHPUnit helpers. -->
    186                 <element value="TracTickets"/>
    187                 <element value="WP_PHPUnit_Util_Getopt"/>
    188                 <element value="PHPUnit_Util_Test"/>
    189                 <element value="WPProfiler"/>
    190                 <element value="PHPUnit_Framework_Exception"/>
    191                 <element value="Polyfill_TestCase"/>
    192             </property>
    193         </properties>
    194153    </rule>
    195154
     
    344303    </rule>
    345304
     305    <!-- Exclude the unit tests from the file name rules. -->
     306    <rule ref="WordPress.Files.FileName">
     307        <exclude-pattern>/tests/phpunit/*</exclude-pattern>
     308    </rule>
     309
    346310    <!-- WPCS1620: template.php isn't a template tag file. -->
    347311    <rule ref="WordPress.Files.FileName.InvalidTemplateTagFileName">
    348312        <exclude-pattern>/src/wp-includes/template\.php</exclude-pattern>
    349     </rule>
    350 
    351     <!-- Exclude the unit tests from select sniffs. -->
    352     <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
    353         <exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
    354313    </rule>
    355314
Note: See TracChangeset for help on using the changeset viewer.