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/wpRestBlockPatternCategoriesController.php

    r53921 r54058  
    146146    }
    147147
     148    /**
     149     * @doesNotPerformAssertions
     150     */
    148151    public function test_context_param() {
    149         $this->markTestSkipped( 'Controller does not use get_context_param().' );
     152        // Controller does not use get_context_param().
    150153    }
    151154
     155    /**
     156     * @doesNotPerformAssertions
     157     */
    152158    public function test_get_item() {
    153         $this->markTestSkipped( 'Controller does not implement get_item().' );
     159        // Controller does not implement get_item().
    154160    }
    155161
     162    /**
     163     * @doesNotPerformAssertions
     164     */
    156165    public function test_create_item() {
    157         $this->markTestSkipped( 'Controller does not implement create_item().' );
     166        // Controller does not implement create_item().
    158167    }
    159168
     169    /**
     170     * @doesNotPerformAssertions
     171     */
    160172    public function test_update_item() {
    161         $this->markTestSkipped( 'Controller does not implement update_item().' );
     173        // Controller does not implement update_item().
    162174    }
    163175
     176    /**
     177     * @doesNotPerformAssertions
     178     */
    164179    public function test_delete_item() {
    165         $this->markTestSkipped( 'Controller does not implement delete_item().' );
     180        // Controller does not implement delete_item().
    166181    }
    167182
     183    /**
     184     * @doesNotPerformAssertions
     185     */
    168186    public function test_prepare_item() {
    169         $this->markTestSkipped( 'Controller does not implement prepare_item().' );
     187        // Controller does not implement prepare_item().
    170188    }
    171189
     190    /**
     191     * @doesNotPerformAssertions
     192     */
    172193    public function test_get_item_schema() {
    173         $this->markTestSkipped( 'Controller does not implement get_item_schema().' );
     194        // Controller does not implement get_item_schema().
    174195    }
    175196}
Note: See TracChangeset for help on using the changeset viewer.