Make WordPress Core


Ignore:
Timestamp:
09/01/2022 10:54:19 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Explicitly mark empty REST API tests as not performing any assertions.

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.

As these tests are intentionally empty, they were previously marked as skipped, so that they are not reported as risky.

This commit aims to further reduce noise in the test suite and effectively ignores these empty tests altogether, which seems like a more appropriate option at this time.

The @doesNotPerformAssertions annotation 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], [53921].

See #40538, #41463, #55652.

File:
1 edited

Legend:

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

    r53921 r54058  
    172172    }
    173173
     174    /**
     175     * @doesNotPerformAssertions
     176     */
    174177    public function test_context_param() {
    175         $this->markTestSkipped( 'Controller does not use get_context_param().' );
    176     }
    177 
     178        // Controller does not use get_context_param().
     179    }
     180
     181    /**
     182     * @doesNotPerformAssertions
     183     */
    178184    public function test_get_item() {
    179         $this->markTestSkipped( 'Controller does not implement get_item().' );
    180     }
    181 
     185        // Controller does not implement get_item().
     186    }
     187
     188    /**
     189     * @doesNotPerformAssertions
     190     */
    182191    public function test_create_item() {
    183         $this->markTestSkipped( 'Controller does not implement create_item().' );
    184     }
    185 
     192        // Controller does not implement create_item().
     193    }
     194
     195    /**
     196     * @doesNotPerformAssertions
     197     */
    186198    public function test_update_item() {
    187         $this->markTestSkipped( 'Controller does not implement update_item().' );
    188     }
    189 
     199        // Controller does not implement update_item().
     200    }
     201
     202    /**
     203     * @doesNotPerformAssertions
     204     */
    190205    public function test_delete_item() {
    191         $this->markTestSkipped( 'Controller does not implement delete_item().' );
    192     }
    193 
     206        // Controller does not implement delete_item().
     207    }
     208
     209    /**
     210     * @doesNotPerformAssertions
     211     */
    194212    public function test_prepare_item() {
    195         $this->markTestSkipped( 'Controller does not implement prepare_item().' );
    196     }
    197 
     213        // Controller does not implement prepare_item().
     214    }
     215
     216    /**
     217     * @doesNotPerformAssertions
     218     */
    198219    public function test_get_item_schema() {
    199         $this->markTestSkipped( 'Controller does not implement get_item_schema().' );
     220        // Controller does not implement get_item_schema().
    200221    }
    201222}
Note: See TracChangeset for help on using the changeset viewer.