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/rest-block-renderer-controller.php

    r53921 r54058  
    615615    /**
    616616     * The update_item() method does not exist for block rendering.
     617     *
     618     * @doesNotPerformAssertions
    617619     */
    618620    public function test_update_item() {
    619         $this->markTestSkipped( 'Controller does not implement update_item().' );
     621        // Controller does not implement update_item().
    620622    }
    621623
    622624    /**
    623625     * The create_item() method does not exist for block rendering.
     626     *
     627     * @doesNotPerformAssertions
    624628     */
    625629    public function test_create_item() {
    626         $this->markTestSkipped( 'Controller does not implement create_item().' );
     630        // Controller does not implement create_item().
    627631    }
    628632
    629633    /**
    630634     * The delete_item() method does not exist for block rendering.
     635     *
     636     * @doesNotPerformAssertions
    631637     */
    632638    public function test_delete_item() {
    633         $this->markTestSkipped( 'Controller does not implement delete_item().' );
     639        // Controller does not implement delete_item().
    634640    }
    635641
    636642    /**
    637643     * The get_items() method does not exist for block rendering.
     644     *
     645     * @doesNotPerformAssertions
    638646     */
    639647    public function test_get_items() {
    640         $this->markTestSkipped( 'Controller does not implement get_items().' );
     648        // Controller does not implement get_items().
    641649    }
    642650
    643651    /**
    644652     * The get_context_param() method is not used for block rendering.
     653     *
     654     * @doesNotPerformAssertions
    645655     */
    646656    public function test_context_param() {
    647         $this->markTestSkipped( 'Controller does not use get_context_param().' );
     657        // Controller does not use get_context_param().
    648658    }
    649659
    650660    /**
    651661     * The prepare_item() method does not exist for block rendering.
     662     *
     663     * @doesNotPerformAssertions
    652664     */
    653665    public function test_prepare_item() {
    654         $this->markTestSkipped( 'Controller does not implement prepare_item().' );
     666        // Controller does not implement prepare_item().
    655667    }
    656668}
Note: See TracChangeset for help on using the changeset viewer.