mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Tests: Consistently skip tests for non-implemented methods in REST API test classes.
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. Some of these empty tests were already marked as skipped, but not in a consistent manner. Since skipping these tests is intentional for the time being, this commit aims to bring some consistency and adjust them all to be more accurately reported as skipped instead of risky. The skipping 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]. Props Mte90, tomepajk, johnbillion, zieladam, SergeyBiryukov. See #40538, #41463, #55652. git-svn-id: https://develop.svn.wordpress.org/trunk@53921 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -270,7 +270,7 @@ class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle
|
||||
}
|
||||
|
||||
public function test_delete_item() {
|
||||
// Doesn't exist.
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
public function test_prepare_item() {
|
||||
|
||||
@@ -131,19 +131,19 @@ class WP_REST_Block_Directory_Controller_Test extends WP_Test_REST_Controller_Te
|
||||
}
|
||||
|
||||
public function test_get_item() {
|
||||
$this->markTestSkipped( 'Controller does not have get_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement get_item().' );
|
||||
}
|
||||
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not have create_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not have update_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not have delete_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -641,10 +641,10 @@ class REST_Block_Renderer_Controller_Test extends WP_Test_REST_Controller_Testca
|
||||
}
|
||||
|
||||
/**
|
||||
* The context_param() method does not exist for block rendering.
|
||||
* The get_context_param() method is not used for block rendering.
|
||||
*/
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not implement context_param().' );
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -551,17 +551,23 @@ class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_create_item() method does not exist for block types.
|
||||
* The create_item() method does not exist for block types.
|
||||
*/
|
||||
public function test_create_item() {}
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_update_item() method does not exist for block types.
|
||||
* The update_item() method does not exist for block types.
|
||||
*/
|
||||
public function test_update_item() {}
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_delete_item() method does not exist for block types.
|
||||
* The delete_item() method does not exist for block types.
|
||||
*/
|
||||
public function test_delete_item() {}
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ class WP_REST_Global_Styles_Controller_Test extends WP_Test_REST_Controller_Test
|
||||
}
|
||||
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not implement context_param().' );
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
|
||||
public function test_get_items() {
|
||||
|
||||
@@ -410,7 +410,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
}
|
||||
|
||||
public function test_get_item() {
|
||||
|
||||
$this->markTestSkipped( 'Controller does not implement get_item().' );
|
||||
}
|
||||
|
||||
public function test_get_item_invalid_post_type() {
|
||||
@@ -421,7 +421,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
}
|
||||
|
||||
public function test_create_item() {
|
||||
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
public function test_create_item_with_template() {
|
||||
@@ -486,7 +486,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
}
|
||||
|
||||
public function test_update_item() {
|
||||
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
public function test_delete_item() {
|
||||
@@ -509,7 +509,7 @@ class WP_Test_REST_Pages_Controller extends WP_Test_REST_Post_Type_Controller_Te
|
||||
}
|
||||
|
||||
public function test_prepare_item() {
|
||||
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
public function test_prepare_item_limit_fields() {
|
||||
|
||||
@@ -311,19 +311,19 @@ class WP_REST_Pattern_Directory_Controller_Test extends WP_Test_REST_Controller_
|
||||
}
|
||||
|
||||
public function test_get_item() {
|
||||
$this->markTestSkipped( 'Controller does not have get_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement get_item().' );
|
||||
}
|
||||
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not have create_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not have update_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not have delete_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,6 +71,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase
|
||||
}
|
||||
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
|
||||
public function test_get_item_is_not_public_not_authenticated() {
|
||||
@@ -379,6 +380,7 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase
|
||||
|
||||
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
public function test_update_item() {
|
||||
@@ -659,9 +661,11 @@ class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase
|
||||
}
|
||||
|
||||
public function test_prepare_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
public function test_get_item_schema() {
|
||||
$this->markTestSkipped( 'Controller does not implement get_item_schema().' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -573,9 +573,10 @@ class WP_Test_REST_Sidebars_Controller extends WP_Test_REST_Controller_Testcase
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_create_item() method does not exist for sidebar.
|
||||
* The create_item() method does not exist for sidebar.
|
||||
*/
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -890,15 +891,17 @@ class WP_Test_REST_Sidebars_Controller extends WP_Test_REST_Controller_Testcase
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_delete_item() method does not exist for sidebar.
|
||||
* The delete_item() method does not exist for sidebar.
|
||||
*/
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_prepare_item() method does not exist for sidebar.
|
||||
* The prepare_item() method does not exist for sidebar.
|
||||
*/
|
||||
public function test_prepare_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1201,12 +1201,16 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
/**
|
||||
* The create_item() method does not exist for themes.
|
||||
*/
|
||||
public function test_create_item() {}
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The update_item() method does not exist for themes.
|
||||
*/
|
||||
public function test_update_item() {}
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test single theme.
|
||||
@@ -1395,10 +1399,14 @@ class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
/**
|
||||
* The delete_item() method does not exist for themes.
|
||||
*/
|
||||
public function test_delete_item() {}
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Context is not supported for themes.
|
||||
*/
|
||||
public function test_context_param() {}
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,17 +531,23 @@ class WP_Test_REST_Widget_Types_Controller extends WP_Test_REST_Controller_Testc
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_create_item() method does not exist for widget types.
|
||||
* The create_item() method does not exist for widget types.
|
||||
*/
|
||||
public function test_create_item() {}
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_update_item() method does not exist for widget types.
|
||||
* The update_item() method does not exist for widget types.
|
||||
*/
|
||||
public function test_update_item() {}
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_delete_item() method does not exist for widget types.
|
||||
* The delete_item() method does not exist for widget types.
|
||||
*/
|
||||
public function test_delete_item() {}
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,6 +217,7 @@ class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
* @ticket 41683
|
||||
*/
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1508,9 +1509,10 @@ class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_prepare_item() method does not exist for sidebar.
|
||||
* The prepare_item() method does not exist for sidebar.
|
||||
*/
|
||||
public function test_prepare_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -146,30 +146,30 @@ class Tests_REST_WpRestBlockPatternCategoriesController extends WP_Test_REST_Con
|
||||
}
|
||||
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not use context_param.' );
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
|
||||
public function test_get_item() {
|
||||
$this->markTestSkipped( 'Controller does not have get_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement get_item().' );
|
||||
}
|
||||
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not have create_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not have update_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not have delete_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
public function test_prepare_item() {
|
||||
$this->markTestSkipped( 'Controller does not have prepare_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
public function test_get_item_schema() {
|
||||
$this->markTestSkipped( 'Controller does not have get_item_schema route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement get_item_schema().' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,30 +172,30 @@ class Tests_REST_WpRestBlockPatternsController extends WP_Test_REST_Controller_T
|
||||
}
|
||||
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not use context_param.' );
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
|
||||
public function test_get_item() {
|
||||
$this->markTestSkipped( 'Controller does not have get_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement get_item().' );
|
||||
}
|
||||
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not have create_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not have update_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not have delete_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
public function test_prepare_item() {
|
||||
$this->markTestSkipped( 'Controller does not have prepare_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
public function test_get_item_schema() {
|
||||
$this->markTestSkipped( 'Controller does not have get_item_schema route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement get_item_schema().' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class Tests_REST_WpRestEditSiteExportController extends WP_Test_REST_Controller_
|
||||
* @ticket 54448
|
||||
*/
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not implement context_param().' );
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,24 +140,32 @@ class Tests_REST_WpRestMenuLocationsController extends WP_Test_REST_Controller_T
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_create_item() method does not exist for menu locations.
|
||||
* The create_item() method does not exist for menu locations.
|
||||
*/
|
||||
public function test_create_item() {}
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_update_item() method does not exist for menu locations.
|
||||
* The update_item() method does not exist for menu locations.
|
||||
*/
|
||||
public function test_update_item() {}
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_delete_item() method does not exist for menu locations.
|
||||
* The delete_item() method does not exist for menu locations.
|
||||
*/
|
||||
public function test_delete_item() {}
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* The test_prepare_item() method does not exist for menu locations.
|
||||
* The prepare_item() method does not exist for menu locations.
|
||||
*/
|
||||
public function test_prepare_item() {}
|
||||
public function test_prepare_item() {
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 40878
|
||||
|
||||
@@ -615,7 +615,7 @@ class Tests_REST_WpRestTemplatesController extends WP_Test_REST_Controller_Testc
|
||||
}
|
||||
|
||||
public function test_prepare_item() {
|
||||
// TODO: Implement test_prepare_item() method.
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
public function test_prepare_item_limit_fields() {
|
||||
|
||||
@@ -1049,27 +1049,27 @@ class Tests_REST_WpRestUrlDetailsController extends WP_Test_REST_Controller_Test
|
||||
}
|
||||
|
||||
public function test_context_param() {
|
||||
$this->markTestSkipped( 'Controller does not use context_param.' );
|
||||
$this->markTestSkipped( 'Controller does not use get_context_param().' );
|
||||
}
|
||||
|
||||
public function test_get_item() {
|
||||
$this->markTestSkipped( 'Controller does not have get_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement get_item().' );
|
||||
}
|
||||
|
||||
public function test_create_item() {
|
||||
$this->markTestSkipped( 'Controller does not have create_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement create_item().' );
|
||||
}
|
||||
|
||||
public function test_update_item() {
|
||||
$this->markTestSkipped( 'Controller does not have update_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement update_item().' );
|
||||
}
|
||||
|
||||
public function test_delete_item() {
|
||||
$this->markTestSkipped( 'Controller does not have delete_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement delete_item().' );
|
||||
}
|
||||
|
||||
public function test_prepare_item() {
|
||||
$this->markTestSkipped( 'Controller does not have prepare_item route.' );
|
||||
$this->markTestSkipped( 'Controller does not implement prepare_item().' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user