Make WordPress Core


Ignore:
Timestamp:
09/01/2022 10:54:19 PM (20 months 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-global-styles-controller.php

    r54036 r54058  
    125125    }
    126126
     127    /**
     128     * @doesNotPerformAssertions
     129     */
    127130    public function test_context_param() {
    128         $this->markTestSkipped( 'Controller does not use get_context_param().' );
    129     }
    130 
     131        // Controller does not use get_context_param().
     132    }
     133
     134    /**
     135     * @doesNotPerformAssertions
     136     */
    131137    public function test_get_items() {
    132         $this->markTestSkipped( 'Controller does not implement get_items().' );
     138        // Controller does not implement get_items().
    133139    }
    134140
     
    383389    }
    384390
     391    /**
     392     * @doesNotPerformAssertions
     393     */
    385394    public function test_create_item() {
    386         $this->markTestSkipped( 'Controller does not implement create_item().' );
     395        // Controller does not implement create_item().
    387396    }
    388397
     
    438447    }
    439448
     449    /**
     450     * @doesNotPerformAssertions
     451     */
    440452    public function test_delete_item() {
    441         $this->markTestSkipped( 'Controller does not implement delete_item().' );
    442     }
    443 
     453        // Controller does not implement delete_item().
     454    }
     455
     456    /**
     457     * @doesNotPerformAssertions
     458     */
    444459    public function test_prepare_item() {
    445         $this->markTestSkipped( 'Controller does not implement prepare_item().' );
     460        // Controller does not implement prepare_item().
    446461    }
    447462
Note: See TracChangeset for help on using the changeset viewer.