Make WordPress Core

Changeset 53921


Ignore:
Timestamp:
08/22/2022 10:42:59 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Consistently skip tests for non-implemented methods in REST API test classes.

WordPress core test suite uses PHPUnit's beStrictAboutTestsThatDoNotTestAnything option set to true, which marks a test as risky when no assertions are performed.

REST API test classes have some empty tests for non-implemented methods because these test classes extend the abstract WP_Test_REST_Controller_Testcase class, which requires several methods to be implemented that don't necessarily make sense for all REST API routes.

Some of these empty tests were already marked as skipped, but not in a consistent manner. Since skipping these tests is intentional for the time being, this commit aims to bring some consistency and adjust them all to be more accurately reported as skipped instead of risky.

The skipping can be reconsidered in the future when the tests are either removed as unnecessary or updated to actually perform assertions related to their behavior.

Follow-up to [40534], [41176], [41228].

Props Mte90, tomepajk, johnbillion, zieladam, SergeyBiryukov.
See #40538, #41463, #55652.

Location:
trunk/tests/phpunit/tests/rest-api
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-autosaves-controller.php

    r51568 r53921  
    271271
    272272    public function test_delete_item() {
    273         // Doesn't exist.
     273        $this->markTestSkipped( 'Controller does not implement delete_item().' );
    274274    }
    275275
  • trunk/tests/phpunit/tests/rest-api/rest-block-directory-controller.php

    r53315 r53921  
    132132
    133133    public function test_get_item() {
    134         $this->markTestSkipped( 'Controller does not have get_item route.' );
     134        $this->markTestSkipped( 'Controller does not implement get_item().' );
    135135    }
    136136
    137137    public function test_create_item() {
    138         $this->markTestSkipped( 'Controller does not have create_item route.' );
     138        $this->markTestSkipped( 'Controller does not implement create_item().' );
    139139    }
    140140
    141141    public function test_update_item() {
    142         $this->markTestSkipped( 'Controller does not have update_item route.' );
     142        $this->markTestSkipped( 'Controller does not implement update_item().' );
    143143    }
    144144
    145145    public function test_delete_item() {
    146         $this->markTestSkipped( 'Controller does not have delete_item route.' );
     146        $this->markTestSkipped( 'Controller does not implement delete_item().' );
    147147    }
    148148
  • trunk/tests/phpunit/tests/rest-api/rest-block-renderer-controller.php

    r51657 r53921  
    642642
    643643    /**
    644      * The context_param() method does not exist for block rendering.
     644     * The get_context_param() method is not used for block rendering.
    645645     */
    646646    public function test_context_param() {
    647         $this->markTestSkipped( 'Controller does not implement context_param().' );
     647        $this->markTestSkipped( 'Controller does not use get_context_param().' );
    648648    }
    649649
  • trunk/tests/phpunit/tests/rest-api/rest-block-type-controller.php

    r53268 r53921  
    552552
    553553    /**
    554      * The test_create_item() method does not exist for block types.
    555      */
    556     public function test_create_item() {}
    557 
    558     /**
    559      * The test_update_item() method does not exist for block types.
    560      */
    561     public function test_update_item() {}
    562 
    563     /**
    564      * The test_delete_item() method does not exist for block types.
    565      */
    566     public function test_delete_item() {}
     554     * The create_item() method does not exist for block types.
     555     */
     556    public function test_create_item() {
     557        $this->markTestSkipped( 'Controller does not implement create_item().' );
     558    }
     559
     560    /**
     561     * The update_item() method does not exist for block types.
     562     */
     563    public function test_update_item() {
     564        $this->markTestSkipped( 'Controller does not implement create_item().' );
     565    }
     566
     567    /**
     568     * The delete_item() method does not exist for block types.
     569     */
     570    public function test_delete_item() {
     571        $this->markTestSkipped( 'Controller does not implement delete_item().' );
     572    }
    567573}
  • trunk/tests/phpunit/tests/rest-api/rest-global-styles-controller.php

    r53072 r53921  
    126126
    127127    public function test_context_param() {
    128         $this->markTestSkipped( 'Controller does not implement context_param().' );
     128        $this->markTestSkipped( 'Controller does not use get_context_param().' );
    129129    }
    130130
  • trunk/tests/phpunit/tests/rest-api/rest-pages-controller.php

    r52389 r53921  
    411411
    412412    public function test_get_item() {
    413 
     413        $this->markTestSkipped( 'Controller does not implement get_item().' );
    414414    }
    415415
     
    422422
    423423    public function test_create_item() {
    424 
     424        $this->markTestSkipped( 'Controller does not implement create_item().' );
    425425    }
    426426
     
    487487
    488488    public function test_update_item() {
    489 
     489        $this->markTestSkipped( 'Controller does not implement update_item().' );
    490490    }
    491491
     
    510510
    511511    public function test_prepare_item() {
    512 
     512        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    513513    }
    514514
  • trunk/tests/phpunit/tests/rest-api/rest-pattern-directory-controller.php

    r53665 r53921  
    312312
    313313    public function test_get_item() {
    314         $this->markTestSkipped( 'Controller does not have get_item route.' );
     314        $this->markTestSkipped( 'Controller does not implement get_item().' );
    315315    }
    316316
    317317    public function test_create_item() {
    318         $this->markTestSkipped( 'Controller does not have create_item route.' );
     318        $this->markTestSkipped( 'Controller does not implement create_item().' );
    319319    }
    320320
    321321    public function test_update_item() {
    322         $this->markTestSkipped( 'Controller does not have update_item route.' );
     322        $this->markTestSkipped( 'Controller does not implement update_item().' );
    323323    }
    324324
    325325    public function test_delete_item() {
    326         $this->markTestSkipped( 'Controller does not have delete_item route.' );
     326        $this->markTestSkipped( 'Controller does not implement delete_item().' );
    327327    }
    328328
  • trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php

    r53588 r53921  
    7272
    7373    public function test_context_param() {
     74        $this->markTestSkipped( 'Controller does not use get_context_param().' );
    7475    }
    7576
     
    380381
    381382    public function test_create_item() {
     383        $this->markTestSkipped( 'Controller does not implement create_item().' );
    382384    }
    383385
     
    660662
    661663    public function test_prepare_item() {
     664        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    662665    }
    663666
    664667    public function test_get_item_schema() {
     668        $this->markTestSkipped( 'Controller does not implement get_item_schema().' );
    665669    }
    666670
  • trunk/tests/phpunit/tests/rest-api/rest-sidebars-controller.php

    r52016 r53921  
    574574
    575575    /**
    576      * The test_create_item() method does not exist for sidebar.
     576     * The create_item() method does not exist for sidebar.
    577577     */
    578578    public function test_create_item() {
     579        $this->markTestSkipped( 'Controller does not implement create_item().' );
    579580    }
    580581
     
    891892
    892893    /**
    893      * The test_delete_item() method does not exist for sidebar.
     894     * The delete_item() method does not exist for sidebar.
    894895     */
    895896    public function test_delete_item() {
    896     }
    897 
    898     /**
    899      * The test_prepare_item() method does not exist for sidebar.
     897        $this->markTestSkipped( 'Controller does not implement delete_item().' );
     898    }
     899
     900    /**
     901     * The prepare_item() method does not exist for sidebar.
    900902     */
    901903    public function test_prepare_item() {
     904        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    902905    }
    903906
  • trunk/tests/phpunit/tests/rest-api/rest-themes-controller.php

    r53659 r53921  
    12021202     * The create_item() method does not exist for themes.
    12031203     */
    1204     public function test_create_item() {}
     1204    public function test_create_item() {
     1205        $this->markTestSkipped( 'Controller does not implement create_item().' );
     1206    }
    12051207
    12061208    /**
    12071209     * The update_item() method does not exist for themes.
    12081210     */
    1209     public function test_update_item() {}
     1211    public function test_update_item() {
     1212        $this->markTestSkipped( 'Controller does not implement update_item().' );
     1213    }
    12101214
    12111215    /**
     
    13961400     * The delete_item() method does not exist for themes.
    13971401     */
    1398     public function test_delete_item() {}
     1402    public function test_delete_item() {
     1403        $this->markTestSkipped( 'Controller does not implement delete_item().' );
     1404    }
    13991405
    14001406    /**
    14011407     * Context is not supported for themes.
    14021408     */
    1403     public function test_context_param() {}
     1409    public function test_context_param() {
     1410        $this->markTestSkipped( 'Controller does not use get_context_param().' );
     1411    }
    14041412}
  • trunk/tests/phpunit/tests/rest-api/rest-widget-types-controller.php

    r51882 r53921  
    532532
    533533    /**
    534      * The test_create_item() method does not exist for widget types.
    535      */
    536     public function test_create_item() {}
    537 
    538     /**
    539      * The test_update_item() method does not exist for widget types.
    540      */
    541     public function test_update_item() {}
    542 
    543     /**
    544      * The test_delete_item() method does not exist for widget types.
    545      */
    546     public function test_delete_item() {}
     534     * The create_item() method does not exist for widget types.
     535     */
     536    public function test_create_item() {
     537        $this->markTestSkipped( 'Controller does not implement create_item().' );
     538    }
     539
     540    /**
     541     * The update_item() method does not exist for widget types.
     542     */
     543    public function test_update_item() {
     544        $this->markTestSkipped( 'Controller does not implement update_item().' );
     545    }
     546
     547    /**
     548     * The delete_item() method does not exist for widget types.
     549     */
     550    public function test_delete_item() {
     551        $this->markTestSkipped( 'Controller does not implement delete_item().' );
     552    }
    547553}
  • trunk/tests/phpunit/tests/rest-api/rest-widgets-controller.php

    r52328 r53921  
    218218     */
    219219    public function test_context_param() {
     220        $this->markTestSkipped( 'Controller does not use get_context_param().' );
    220221    }
    221222
     
    15091510
    15101511    /**
    1511      * The test_prepare_item() method does not exist for sidebar.
     1512     * The prepare_item() method does not exist for sidebar.
    15121513     */
    15131514    public function test_prepare_item() {
     1515        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    15141516    }
    15151517
  • trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternCategoriesController.php

    r53152 r53921  
    147147
    148148    public function test_context_param() {
    149         $this->markTestSkipped( 'Controller does not use context_param.' );
     149        $this->markTestSkipped( 'Controller does not use get_context_param().' );
    150150    }
    151151
    152152    public function test_get_item() {
    153         $this->markTestSkipped( 'Controller does not have get_item route.' );
     153        $this->markTestSkipped( 'Controller does not implement get_item().' );
    154154    }
    155155
    156156    public function test_create_item() {
    157         $this->markTestSkipped( 'Controller does not have create_item route.' );
     157        $this->markTestSkipped( 'Controller does not implement create_item().' );
    158158    }
    159159
    160160    public function test_update_item() {
    161         $this->markTestSkipped( 'Controller does not have update_item route.' );
     161        $this->markTestSkipped( 'Controller does not implement update_item().' );
    162162    }
    163163
    164164    public function test_delete_item() {
    165         $this->markTestSkipped( 'Controller does not have delete_item route.' );
     165        $this->markTestSkipped( 'Controller does not implement delete_item().' );
    166166    }
    167167
    168168    public function test_prepare_item() {
    169         $this->markTestSkipped( 'Controller does not have prepare_item route.' );
     169        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    170170    }
    171171
    172172    public function test_get_item_schema() {
    173         $this->markTestSkipped( 'Controller does not have get_item_schema route.' );
     173        $this->markTestSkipped( 'Controller does not implement get_item_schema().' );
    174174    }
    175175}
  • trunk/tests/phpunit/tests/rest-api/wpRestBlockPatternsController.php

    r53152 r53921  
    173173
    174174    public function test_context_param() {
    175         $this->markTestSkipped( 'Controller does not use context_param.' );
     175        $this->markTestSkipped( 'Controller does not use get_context_param().' );
    176176    }
    177177
    178178    public function test_get_item() {
    179         $this->markTestSkipped( 'Controller does not have get_item route.' );
     179        $this->markTestSkipped( 'Controller does not implement get_item().' );
    180180    }
    181181
    182182    public function test_create_item() {
    183         $this->markTestSkipped( 'Controller does not have create_item route.' );
     183        $this->markTestSkipped( 'Controller does not implement create_item().' );
    184184    }
    185185
    186186    public function test_update_item() {
    187         $this->markTestSkipped( 'Controller does not have update_item route.' );
     187        $this->markTestSkipped( 'Controller does not implement update_item().' );
    188188    }
    189189
    190190    public function test_delete_item() {
    191         $this->markTestSkipped( 'Controller does not have delete_item route.' );
     191        $this->markTestSkipped( 'Controller does not implement delete_item().' );
    192192    }
    193193
    194194    public function test_prepare_item() {
    195         $this->markTestSkipped( 'Controller does not have prepare_item route.' );
     195        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    196196    }
    197197
    198198    public function test_get_item_schema() {
    199         $this->markTestSkipped( 'Controller does not have get_item_schema route.' );
     199        $this->markTestSkipped( 'Controller does not implement get_item_schema().' );
    200200    }
    201201}
  • trunk/tests/phpunit/tests/rest-api/wpRestEditSiteExportController.php

    r52340 r53921  
    103103     */
    104104    public function test_context_param() {
    105         $this->markTestSkipped( 'Controller does not implement context_param().' );
     105        $this->markTestSkipped( 'Controller does not use get_context_param().' );
    106106    }
    107107
  • trunk/tests/phpunit/tests/rest-api/wpRestMenuLocationsController.php

    r52079 r53921  
    141141
    142142    /**
    143      * The test_create_item() method does not exist for menu locations.
    144      */
    145     public function test_create_item() {}
    146 
    147     /**
    148      * The test_update_item() method does not exist for menu locations.
    149      */
    150     public function test_update_item() {}
    151 
    152     /**
    153      * The test_delete_item() method does not exist for menu locations.
    154      */
    155     public function test_delete_item() {}
    156 
    157     /**
    158      * The test_prepare_item() method does not exist for menu locations.
    159      */
    160     public function test_prepare_item() {}
     143     * The create_item() method does not exist for menu locations.
     144     */
     145    public function test_create_item() {
     146        $this->markTestSkipped( 'Controller does not implement create_item().' );
     147    }
     148
     149    /**
     150     * The update_item() method does not exist for menu locations.
     151     */
     152    public function test_update_item() {
     153        $this->markTestSkipped( 'Controller does not implement update_item().' );
     154    }
     155
     156    /**
     157     * The delete_item() method does not exist for menu locations.
     158     */
     159    public function test_delete_item() {
     160        $this->markTestSkipped( 'Controller does not implement delete_item().' );
     161    }
     162
     163    /**
     164     * The prepare_item() method does not exist for menu locations.
     165     */
     166    public function test_prepare_item() {
     167        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
     168    }
    161169
    162170    /**
  • trunk/tests/phpunit/tests/rest-api/wpRestTemplatesController.php

    r53416 r53921  
    616616
    617617    public function test_prepare_item() {
    618         // TODO: Implement test_prepare_item() method.
     618        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    619619    }
    620620
  • trunk/tests/phpunit/tests/rest-api/wpRestUrlDetailsController.php

    r52311 r53921  
    10501050
    10511051    public function test_context_param() {
    1052         $this->markTestSkipped( 'Controller does not use context_param.' );
     1052        $this->markTestSkipped( 'Controller does not use get_context_param().' );
    10531053    }
    10541054
    10551055    public function test_get_item() {
    1056         $this->markTestSkipped( 'Controller does not have get_item route.' );
     1056        $this->markTestSkipped( 'Controller does not implement get_item().' );
    10571057    }
    10581058
    10591059    public function test_create_item() {
    1060         $this->markTestSkipped( 'Controller does not have create_item route.' );
     1060        $this->markTestSkipped( 'Controller does not implement create_item().' );
    10611061    }
    10621062
    10631063    public function test_update_item() {
    1064         $this->markTestSkipped( 'Controller does not have update_item route.' );
     1064        $this->markTestSkipped( 'Controller does not implement update_item().' );
    10651065    }
    10661066
    10671067    public function test_delete_item() {
    1068         $this->markTestSkipped( 'Controller does not have delete_item route.' );
     1068        $this->markTestSkipped( 'Controller does not implement delete_item().' );
    10691069    }
    10701070
    10711071    public function test_prepare_item() {
    1072         $this->markTestSkipped( 'Controller does not have prepare_item route.' );
     1072        $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    10731073    }
    10741074
Note: See TracChangeset for help on using the changeset viewer.