Make WordPress Core

Ticket #53363: 53363-01.patch

File 53363-01.patch, 8.4 KB (added by jrf, 3 years ago)

Annotate when tests do deliberately do not perform assertions, so the test won't be marked as risky

  • tests/phpunit/tests/rest-api/rest-autosaves-controller.php

    From 6a949a5508cc521d760399a02b4bd738fb8b6f56 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Tue, 20 Jul 2021 13:32:26 +0200
    Subject: [PATCH] Build/Tests: mark empty tests as not performing assertions
    
    The abstract `WP_Test_REST_Controller_Testcase` which these tests extend enforces the implementation of certain test methods.
    However, the underlying _methods under test_ do not always exist, resulting in empty test methods, which are subsequently marked as "risky" and listed as warnings in the PHPUnit output.
    
    By explicitly annotating that these tests do not perform assertions, the warnings about these tests being "risky" are removed.
    ---
     .../tests/rest-api/rest-autosaves-controller.php     |  3 +++
     .../tests/rest-api/rest-block-type-controller.php    |  6 ++++++
     .../tests/rest-api/rest-settings-controller.php      | 12 ++++++++++++
     .../tests/rest-api/rest-sidebars-controller.php      |  6 ++++++
     .../tests/rest-api/rest-templates-controller.php     |  9 +++++++++
     .../tests/rest-api/rest-themes-controller.php        |  8 ++++++++
     .../tests/rest-api/rest-widget-types-controller.php  |  6 ++++++
     .../tests/rest-api/rest-widgets-controller.php       |  4 +++-
     8 files changed, 53 insertions(+), 1 deletion(-)
    
    diff --git a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php
    index cf85a864be..aaf0b2b28f 100644
    a b class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle 
    269269                $this->assertErrorResponse( 'rest_post_invalid_parent', $response, 404 );
    270270        }
    271271
     272        /**
     273         * @doesNotPerformAssertions
     274         */
    272275        public function test_delete_item() {
    273276                // Doesn't exist.
    274277        }
  • tests/phpunit/tests/rest-api/rest-block-type-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-block-type-controller.php b/tests/phpunit/tests/rest-api/rest-block-type-controller.php
    index 38c0bfe2cd..2e7b405c22 100644
    a b class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { 
    531531
    532532        /**
    533533         * The test_create_item() method does not exist for block types.
     534         *
     535         * @doesNotPerformAssertions
    534536         */
    535537        public function test_create_item() {}
    536538
    537539        /**
    538540         * The test_update_item() method does not exist for block types.
     541         *
     542         * @doesNotPerformAssertions
    539543         */
    540544        public function test_update_item() {}
    541545
    542546        /**
    543547         * The test_delete_item() method does not exist for block types.
     548         *
     549         * @doesNotPerformAssertions
    544550         */
    545551        public function test_delete_item() {}
    546552}
  • tests/phpunit/tests/rest-api/rest-settings-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php
    index bb9a4bbdb6..0f11c65ed2 100644
    a b class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase 
    7070                $this->assertSame( 404, $response->get_status() );
    7171        }
    7272
     73        /**
     74         * @doesNotPerformAssertions
     75         */
    7376        public function test_context_param() {
    7477        }
    7578
    class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase 
    374377        }
    375378
    376379
     380        /**
     381         * @doesNotPerformAssertions
     382         */
    377383        public function test_create_item() {
    378384        }
    379385
    class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase 
    654660                $this->assertSame( 404, $response->get_status() );
    655661        }
    656662
     663        /**
     664         * @doesNotPerformAssertions
     665         */
    657666        public function test_prepare_item() {
    658667        }
    659668
     669        /**
     670         * @doesNotPerformAssertions
     671         */
    660672        public function test_get_item_schema() {
    661673        }
    662674
  • tests/phpunit/tests/rest-api/rest-sidebars-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-sidebars-controller.php b/tests/phpunit/tests/rest-api/rest-sidebars-controller.php
    index 850210cc20..025dc555b0 100644
    a b class WP_Test_REST_Sidebars_Controller extends WP_Test_REST_Controller_Testcase 
    431431
    432432        /**
    433433         * The test_create_item() method does not exist for sidebar.
     434         *
     435         * @doesNotPerformAssertions
    434436         */
    435437        public function test_create_item() {
    436438        }
    class WP_Test_REST_Sidebars_Controller extends WP_Test_REST_Controller_Testcase 
    748750
    749751        /**
    750752         * The test_delete_item() method does not exist for sidebar.
     753         *
     754         * @doesNotPerformAssertions
    751755         */
    752756        public function test_delete_item() {
    753757        }
    754758
    755759        /**
    756760         * The test_prepare_item() method does not exist for sidebar.
     761         *
     762         * @doesNotPerformAssertions
    757763         */
    758764        public function test_prepare_item() {
    759765        }
  • tests/phpunit/tests/rest-api/rest-templates-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-templates-controller.php b/tests/phpunit/tests/rest-api/rest-templates-controller.php
    index 356c868d76..a81400d7a3 100644
    a b class WP_REST_Template_Controller_Test extends WP_Test_REST_Controller_Testcase 
    5353                $this->assertArrayHasKey( '/wp/v2/templates/(?P<id>[\/\w-]+)', $routes );
    5454        }
    5555
     56        /**
     57         * @doesNotPerformAssertions
     58         */
    5659        public function test_context_param() {
    5760                // TODO: Implement test_context_param() method.
    5861        }
    class WP_REST_Template_Controller_Test extends WP_Test_REST_Controller_Testcase 
    187190                $this->assertErrorResponse( 'rest_template_not_found', $response, 404 );
    188191        }
    189192
     193        /**
     194         * @doesNotPerformAssertions
     195         */
    190196        public function test_prepare_item() {
    191197                // TODO: Implement test_prepare_item() method.
    192198        }
    193199
     200        /**
     201         * @doesNotPerformAssertions
     202         */
    194203        public function test_get_item_schema() {
    195204                // TODO: Implement test_get_item_schema() method.
    196205        }
  • tests/phpunit/tests/rest-api/rest-themes-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php
    index 5acbf7d0f9..d5962b781a 100644
    a b class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { 
    11961196
    11971197        /**
    11981198         * The create_item() method does not exist for themes.
     1199         *
     1200         * @doesNotPerformAssertions
    11991201         */
    12001202        public function test_create_item() {}
    12011203
    12021204        /**
    12031205         * The update_item() method does not exist for themes.
     1206         *
     1207         * @doesNotPerformAssertions
    12041208         */
    12051209        public function test_update_item() {}
    12061210
    class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { 
    12831287
    12841288        /**
    12851289         * The delete_item() method does not exist for themes.
     1290         *
     1291         * @doesNotPerformAssertions
    12861292         */
    12871293        public function test_delete_item() {}
    12881294
    12891295        /**
    12901296         * Context is not supported for themes.
     1297         *
     1298         * @doesNotPerformAssertions
    12911299         */
    12921300        public function test_context_param() {}
    12931301}
  • tests/phpunit/tests/rest-api/rest-widget-types-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-widget-types-controller.php b/tests/phpunit/tests/rest-api/rest-widget-types-controller.php
    index fd0b3007ec..6648c21f5c 100644
    a b class WP_Test_REST_Widget_Types_Controller extends WP_Test_REST_Controller_Testc 
    516516
    517517        /**
    518518         * The test_create_item() method does not exist for widget types.
     519         *
     520         * @doesNotPerformAssertions
    519521         */
    520522        public function test_create_item() {}
    521523
    522524        /**
    523525         * The test_update_item() method does not exist for widget types.
     526         *
     527         * @doesNotPerformAssertions
    524528         */
    525529        public function test_update_item() {}
    526530
    527531        /**
    528532         * The test_delete_item() method does not exist for widget types.
     533         *
     534         * @doesNotPerformAssertions
    529535         */
    530536        public function test_delete_item() {}
    531537}
  • tests/phpunit/tests/rest-api/rest-widgets-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-widgets-controller.php b/tests/phpunit/tests/rest-api/rest-widgets-controller.php
    index a44512cf5a..04332d5f29 100644
    a b class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase { 
    214214        }
    215215
    216216        /**
    217          * @ticket 41683
     217         * @doesNotPerformAssertions
    218218         */
    219219        public function test_context_param() {
    220220        }
    class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase { 
    14361436
    14371437        /**
    14381438         * The test_prepare_item() method does not exist for sidebar.
     1439         *
     1440         * @doesNotPerformAssertions
    14391441         */
    14401442        public function test_prepare_item() {
    14411443        }