From 6a949a5508cc521d760399a02b4bd738fb8b6f56 Mon Sep 17 00:00:00 2001
From: jrfnl <jrfnl@users.noreply.github.com>
Date: Tue, 20 Jul 2021 13:32:26 +0200
Subject: [PATCH] Build/Tests: mark empty tests as not performing assertions
The abstract `WP_Test_REST_Controller_Testcase` which these tests extend enforces the implementation of certain test methods.
However, the underlying _methods under test_ do not always exist, resulting in empty test methods, which are subsequently marked as "risky" and listed as warnings in the PHPUnit output.
By explicitly annotating that these tests do not perform assertions, the warnings about these tests being "risky" are removed.
---
.../tests/rest-api/rest-autosaves-controller.php | 3 +++
.../tests/rest-api/rest-block-type-controller.php | 6 ++++++
.../tests/rest-api/rest-settings-controller.php | 12 ++++++++++++
.../tests/rest-api/rest-sidebars-controller.php | 6 ++++++
.../tests/rest-api/rest-templates-controller.php | 9 +++++++++
.../tests/rest-api/rest-themes-controller.php | 8 ++++++++
.../tests/rest-api/rest-widget-types-controller.php | 6 ++++++
.../tests/rest-api/rest-widgets-controller.php | 4 +++-
8 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/tests/phpunit/tests/rest-api/rest-autosaves-controller.php b/tests/phpunit/tests/rest-api/rest-autosaves-controller.php
index cf85a864be..aaf0b2b28f 100644
a
|
b
|
class WP_Test_REST_Autosaves_Controller extends WP_Test_REST_Post_Type_Controlle |
269 | 269 | $this->assertErrorResponse( 'rest_post_invalid_parent', $response, 404 ); |
270 | 270 | } |
271 | 271 | |
| 272 | /** |
| 273 | * @doesNotPerformAssertions |
| 274 | */ |
272 | 275 | public function test_delete_item() { |
273 | 276 | // Doesn't exist. |
274 | 277 | } |
diff --git a/tests/phpunit/tests/rest-api/rest-block-type-controller.php b/tests/phpunit/tests/rest-api/rest-block-type-controller.php
index 38c0bfe2cd..2e7b405c22 100644
a
|
b
|
class REST_Block_Type_Controller_Test extends WP_Test_REST_Controller_Testcase { |
531 | 531 | |
532 | 532 | /** |
533 | 533 | * The test_create_item() method does not exist for block types. |
| 534 | * |
| 535 | * @doesNotPerformAssertions |
534 | 536 | */ |
535 | 537 | public function test_create_item() {} |
536 | 538 | |
537 | 539 | /** |
538 | 540 | * The test_update_item() method does not exist for block types. |
| 541 | * |
| 542 | * @doesNotPerformAssertions |
539 | 543 | */ |
540 | 544 | public function test_update_item() {} |
541 | 545 | |
542 | 546 | /** |
543 | 547 | * The test_delete_item() method does not exist for block types. |
| 548 | * |
| 549 | * @doesNotPerformAssertions |
544 | 550 | */ |
545 | 551 | public function test_delete_item() {} |
546 | 552 | } |
diff --git a/tests/phpunit/tests/rest-api/rest-settings-controller.php b/tests/phpunit/tests/rest-api/rest-settings-controller.php
index bb9a4bbdb6..0f11c65ed2 100644
a
|
b
|
class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase |
70 | 70 | $this->assertSame( 404, $response->get_status() ); |
71 | 71 | } |
72 | 72 | |
| 73 | /** |
| 74 | * @doesNotPerformAssertions |
| 75 | */ |
73 | 76 | public function test_context_param() { |
74 | 77 | } |
75 | 78 | |
… |
… |
class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase |
374 | 377 | } |
375 | 378 | |
376 | 379 | |
| 380 | /** |
| 381 | * @doesNotPerformAssertions |
| 382 | */ |
377 | 383 | public function test_create_item() { |
378 | 384 | } |
379 | 385 | |
… |
… |
class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase |
654 | 660 | $this->assertSame( 404, $response->get_status() ); |
655 | 661 | } |
656 | 662 | |
| 663 | /** |
| 664 | * @doesNotPerformAssertions |
| 665 | */ |
657 | 666 | public function test_prepare_item() { |
658 | 667 | } |
659 | 668 | |
| 669 | /** |
| 670 | * @doesNotPerformAssertions |
| 671 | */ |
660 | 672 | public function test_get_item_schema() { |
661 | 673 | } |
662 | 674 | |
diff --git a/tests/phpunit/tests/rest-api/rest-sidebars-controller.php b/tests/phpunit/tests/rest-api/rest-sidebars-controller.php
index 850210cc20..025dc555b0 100644
a
|
b
|
class WP_Test_REST_Sidebars_Controller extends WP_Test_REST_Controller_Testcase |
431 | 431 | |
432 | 432 | /** |
433 | 433 | * The test_create_item() method does not exist for sidebar. |
| 434 | * |
| 435 | * @doesNotPerformAssertions |
434 | 436 | */ |
435 | 437 | public function test_create_item() { |
436 | 438 | } |
… |
… |
class WP_Test_REST_Sidebars_Controller extends WP_Test_REST_Controller_Testcase |
748 | 750 | |
749 | 751 | /** |
750 | 752 | * The test_delete_item() method does not exist for sidebar. |
| 753 | * |
| 754 | * @doesNotPerformAssertions |
751 | 755 | */ |
752 | 756 | public function test_delete_item() { |
753 | 757 | } |
754 | 758 | |
755 | 759 | /** |
756 | 760 | * The test_prepare_item() method does not exist for sidebar. |
| 761 | * |
| 762 | * @doesNotPerformAssertions |
757 | 763 | */ |
758 | 764 | public function test_prepare_item() { |
759 | 765 | } |
diff --git a/tests/phpunit/tests/rest-api/rest-templates-controller.php b/tests/phpunit/tests/rest-api/rest-templates-controller.php
index 356c868d76..a81400d7a3 100644
a
|
b
|
class WP_REST_Template_Controller_Test extends WP_Test_REST_Controller_Testcase |
53 | 53 | $this->assertArrayHasKey( '/wp/v2/templates/(?P<id>[\/\w-]+)', $routes ); |
54 | 54 | } |
55 | 55 | |
| 56 | /** |
| 57 | * @doesNotPerformAssertions |
| 58 | */ |
56 | 59 | public function test_context_param() { |
57 | 60 | // TODO: Implement test_context_param() method. |
58 | 61 | } |
… |
… |
class WP_REST_Template_Controller_Test extends WP_Test_REST_Controller_Testcase |
187 | 190 | $this->assertErrorResponse( 'rest_template_not_found', $response, 404 ); |
188 | 191 | } |
189 | 192 | |
| 193 | /** |
| 194 | * @doesNotPerformAssertions |
| 195 | */ |
190 | 196 | public function test_prepare_item() { |
191 | 197 | // TODO: Implement test_prepare_item() method. |
192 | 198 | } |
193 | 199 | |
| 200 | /** |
| 201 | * @doesNotPerformAssertions |
| 202 | */ |
194 | 203 | public function test_get_item_schema() { |
195 | 204 | // TODO: Implement test_get_item_schema() method. |
196 | 205 | } |
diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php
index 5acbf7d0f9..d5962b781a 100644
a
|
b
|
class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { |
1196 | 1196 | |
1197 | 1197 | /** |
1198 | 1198 | * The create_item() method does not exist for themes. |
| 1199 | * |
| 1200 | * @doesNotPerformAssertions |
1199 | 1201 | */ |
1200 | 1202 | public function test_create_item() {} |
1201 | 1203 | |
1202 | 1204 | /** |
1203 | 1205 | * The update_item() method does not exist for themes. |
| 1206 | * |
| 1207 | * @doesNotPerformAssertions |
1204 | 1208 | */ |
1205 | 1209 | public function test_update_item() {} |
1206 | 1210 | |
… |
… |
class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { |
1283 | 1287 | |
1284 | 1288 | /** |
1285 | 1289 | * The delete_item() method does not exist for themes. |
| 1290 | * |
| 1291 | * @doesNotPerformAssertions |
1286 | 1292 | */ |
1287 | 1293 | public function test_delete_item() {} |
1288 | 1294 | |
1289 | 1295 | /** |
1290 | 1296 | * Context is not supported for themes. |
| 1297 | * |
| 1298 | * @doesNotPerformAssertions |
1291 | 1299 | */ |
1292 | 1300 | public function test_context_param() {} |
1293 | 1301 | } |
diff --git a/tests/phpunit/tests/rest-api/rest-widget-types-controller.php b/tests/phpunit/tests/rest-api/rest-widget-types-controller.php
index fd0b3007ec..6648c21f5c 100644
a
|
b
|
class WP_Test_REST_Widget_Types_Controller extends WP_Test_REST_Controller_Testc |
516 | 516 | |
517 | 517 | /** |
518 | 518 | * The test_create_item() method does not exist for widget types. |
| 519 | * |
| 520 | * @doesNotPerformAssertions |
519 | 521 | */ |
520 | 522 | public function test_create_item() {} |
521 | 523 | |
522 | 524 | /** |
523 | 525 | * The test_update_item() method does not exist for widget types. |
| 526 | * |
| 527 | * @doesNotPerformAssertions |
524 | 528 | */ |
525 | 529 | public function test_update_item() {} |
526 | 530 | |
527 | 531 | /** |
528 | 532 | * The test_delete_item() method does not exist for widget types. |
| 533 | * |
| 534 | * @doesNotPerformAssertions |
529 | 535 | */ |
530 | 536 | public function test_delete_item() {} |
531 | 537 | } |
diff --git a/tests/phpunit/tests/rest-api/rest-widgets-controller.php b/tests/phpunit/tests/rest-api/rest-widgets-controller.php
index a44512cf5a..04332d5f29 100644
a
|
b
|
class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase { |
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
217 | | * @ticket 41683 |
| 217 | * @doesNotPerformAssertions |
218 | 218 | */ |
219 | 219 | public function test_context_param() { |
220 | 220 | } |
… |
… |
class WP_Test_REST_Widgets_Controller extends WP_Test_REST_Controller_Testcase { |
1436 | 1436 | |
1437 | 1437 | /** |
1438 | 1438 | * The test_prepare_item() method does not exist for sidebar. |
| 1439 | * |
| 1440 | * @doesNotPerformAssertions |
1439 | 1441 | */ |
1440 | 1442 | public function test_prepare_item() { |
1441 | 1443 | } |