Tests: Rename classes in phpunit/tests/ajax/ per the naming conventions.

This updates the test classes to match the names of the functions being tested.

Includes moving the `@covers` tags from individual test methods to the class DocBlocks.

Reference: [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#naming-and-organization Writing PHP Tests: Naming and Organization].

Follow-up to [47780], [48911], [49327], [50291], [50292], [50342], [50452], [50453], [50456], [50967], [50968], [50969], [51491], [51492], [51493], [51623], [51639], [51646], [51650], [51651], [51860], [52264], [52265], [53489], [53561], [54704].

See #56793.

git-svn-id: https://develop.svn.wordpress.org/trunk@54722 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-10-30 01:05:06 +00:00
parent 541ebdfaa5
commit 54eca75d04
22 changed files with 90 additions and 107 deletions

View File

@ -9,12 +9,14 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
* Testing Add Meta AJAX functionality.
*
* @group ajax
*
* @covers ::wp_ajax_add_meta
*/
class Tests_Ajax_AddMeta extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxAddMeta extends WP_Ajax_UnitTestCase {
/**
* @ticket 43559
*
* @covers ::wp_ajax_add_meta
* @covers ::add_post_meta
*/
public function test_wp_ajax_add_meta_allows_empty_values_on_adding() {
@ -43,7 +45,6 @@ class Tests_Ajax_AddMeta extends WP_Ajax_UnitTestCase {
/**
* @ticket 43559
*
* @covers ::wp_ajax_add_meta
* @covers ::update_metadata_by_mid
*/
public function test_wp_ajax_add_meta_allows_empty_values_on_updating() {

View File

@ -9,15 +9,16 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
* Class for testing ajax add tag functionality.
*
* @group ajax
*
* @covers ::wp_ajax_add_tag
*/
class Tests_Ajax_AddTag extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxAddTag extends WP_Ajax_UnitTestCase {
/**
* @dataProvider data_add_tag
*
* @ticket 42937
*
* @covers ::wp_ajax_add_tag
* @covers ::wp_insert_term
*
* @param array $post_data Data to populate $_POST.
@ -93,8 +94,6 @@ class Tests_Ajax_AddTag extends WP_Ajax_UnitTestCase {
/**
* @ticket 42937
*
* @covers ::wp_ajax_add_tag
*/
public function test_adding_category_without_capability_should_error() {
$this->_setRole( 'subscriber' );
@ -114,7 +113,6 @@ class Tests_Ajax_AddTag extends WP_Ajax_UnitTestCase {
/**
* @ticket 42937
*
* @covers ::wp_ajax_add_tag
* @covers ::wp_insert_term
*/
public function test_adding_existing_category_should_error() {

View File

@ -8,14 +8,15 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax tag search functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.4.0
* @group ajax
* @since 3.4.0
*
* @group ajax
*
* @covers ::wp_ajax_ajax_tag_search
*/
class Tests_Ajax_TagSearch extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxAjaxTagSearch extends WP_Ajax_UnitTestCase {
/**
* List of terms to insert on setup

View File

@ -11,6 +11,7 @@ require_once ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php';
* Class for testing ajax crop image functionality.
*
* @group ajax
*
* @covers ::wp_ajax_crop_image
*/
class Tests_Ajax_WpAjaxCropImage extends WP_Ajax_UnitTestCase {

View File

@ -8,12 +8,15 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax comment functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.4.0
* @group ajax
* @since 3.4.0
*
* @group ajax
*
* @covers ::wp_ajax_delete_comment
*/
class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxDeleteComment extends WP_Ajax_UnitTestCase {
/**
* List of comments.
@ -57,7 +60,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
*
* Expects test to pass.
*
* @covers ::wp_ajax_delete_comment
* @covers ::_wp_ajax_delete_comment_response
*
* @param WP_Comment $comment Comment object.
@ -119,8 +121,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
*
* Expects test to fail.
*
* @covers ::wp_ajax_delete_comment
*
* @param WP_Comment $comment Comment object.
* @param string $action Action: 'trash', 'untrash', etc.
*/
@ -153,8 +153,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
*
* Expects test to fail.
*
* @covers ::wp_ajax_delete_comment
*
* @param WP_Comment $comment Comment object.
* @param string $action Action: 'trash', 'untrash', etc.
*/
@ -186,8 +184,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
*
* Expects test to fail.
*
* @covers ::wp_ajax_delete_comment
*
* @param WP_Comment $comment Comment object.
* @param string $action Action: 'trash', 'untrash', etc.
*/
@ -225,8 +221,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
*
* Expects test to fail.
*
* @covers ::wp_ajax_delete_comment
*
* @param WP_Comment $comment Comment object.
* @param string $action Action: 'trash', 'untrash', etc.
*/
@ -275,7 +269,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
/**
* Deletes a comment as an administrator (expects success).
*
* @covers ::wp_ajax_delete_comment
* @covers ::_wp_ajax_delete_comment_response
*/
public function test_ajax_comment_trash_actions_as_administrator() {
@ -293,8 +286,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
/**
* Deletes a comment as a subscriber (expects permission denied).
*
* @covers ::wp_ajax_delete_comment
*/
public function test_ajax_comment_trash_actions_as_subscriber() {
// Test trash/untrash.
@ -312,7 +303,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
/**
* Deletes a comment with no ID.
*
* @covers ::wp_ajax_delete_comment
* @covers ::_wp_ajax_delete_comment_response
*/
public function test_ajax_trash_comment_no_id() {
@ -330,8 +320,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
/**
* Deletes a comment with a bad nonce.
*
* @covers ::wp_ajax_delete_comment
*/
public function test_ajax_trash_comment_bad_nonce() {
// Test trash/untrash.
@ -348,8 +336,6 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase {
/**
* Tests trashing an already trashed comment, etc.
*
* @covers ::wp_ajax_delete_comment
*/
public function test_ajax_trash_double_action() {
// Test trash/untrash.

View File

@ -11,7 +11,7 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
*
* @covers ::wp_ajax_delete_plugin
*/
class Tests_Ajax_Delete_Plugin extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxDeletePlugin extends WP_Ajax_UnitTestCase {
public function test_missing_nonce() {
$this->expectException( 'WPAjaxDieStopException' );
@ -130,7 +130,6 @@ class Tests_Ajax_Delete_Plugin extends WP_Ajax_UnitTestCase {
/**
* @group ms-excluded
*
* @covers ::wp_ajax_delete_plugin
* @covers ::delete_plugins
*/
public function test_delete_plugin() {

View File

@ -8,14 +8,15 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax comment functionality
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.4.0
* @group ajax
* @since 3.4.0
*
* @group ajax
*
* @covers ::wp_ajax_dim_comment
*/
class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxDimComment extends WP_Ajax_UnitTestCase {
/**
* List of comments.

View File

@ -8,14 +8,15 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax comment functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.4.0
* @group ajax
* @since 3.4.0
*
* @group ajax
*
* @covers ::wp_ajax_edit_comment
*/
class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxEditComment extends WP_Ajax_UnitTestCase {
/**
* A post with at least one comment.

View File

@ -8,14 +8,15 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax comment functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.4.0
* @group ajax
* @since 3.4.0
*
* @group ajax
*
* @covers ::wp_ajax_get_comments
*/
class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxGetComments extends WP_Ajax_UnitTestCase {
/**
* A post with at least one comment.

View File

@ -8,12 +8,15 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax save draft functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.4.0
* @group ajax
* @since 3.4.0
*
* @group ajax
*
* @covers ::wp_ajax_heartbeat
*/
class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxHeartbeat extends WP_Ajax_UnitTestCase {
/**
* Post
@ -40,8 +43,6 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase {
/**
* Tests autosaving a post.
*
* @covers ::wp_ajax_heartbeat
*/
public function test_autosave_post() {
// The original post_author.
@ -83,8 +84,6 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase {
/**
* Tests autosaving a locked post.
*
* @covers ::wp_ajax_heartbeat
*/
public function test_autosave_locked_post() {
// Lock the post to another user.
@ -136,8 +135,6 @@ class Tests_Ajax_Autosave extends WP_Ajax_UnitTestCase {
/**
* Tests with an invalid nonce.
*
* @covers ::wp_ajax_heartbeat
*/
public function test_with_invalid_nonce() {

View File

@ -7,14 +7,17 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax media editing.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.5.0
* @group ajax
* @since 3.5.0
*
* @requires function imagejpeg
* @group ajax
*
* @covers ::wp_ajax_image_editor
*
* @requires function imagejpeg
*/
class Tests_Ajax_MediaEdit extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxImageEditor extends WP_Ajax_UnitTestCase {
/**
* Tear down the test fixture.

View File

@ -9,13 +9,14 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
* Testing Quick Edit AJAX functionality.
*
* @group ajax
*
* @covers ::wp_ajax_inline_save
*/
class Tests_Ajax_QuickEdit extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxInlineSave extends WP_Ajax_UnitTestCase {
/**
* @ticket 26948
*
* @covers ::wp_ajax_inline_save
* @covers ::edit_post
*/
public function test_dont_process_terms_if_taxonomy_does_not_allow_show_on_quick_edit() {

View File

@ -8,14 +8,15 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax comment functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.4.0
* @group ajax
* @since 3.4.0
*
* @group ajax
*
* @covers ::wp_ajax_replyto_comment
*/
class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxReplytoComment extends WP_Ajax_UnitTestCase {
/**
* A post with at least one comment.

View File

@ -2,14 +2,15 @@
/**
* Testing Ajax response class
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.5.0
* @group ajax
* @since 3.5.0
*
* @group ajax
*
* @covers WP_Ajax_Response::send
*/
class Tests_Ajax_Response extends WP_UnitTestCase {
class Tests_Ajax_wpAjaxResponse extends WP_UnitTestCase {
/**
* Saved error reporting level

View File

@ -8,12 +8,14 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
* Testing Ajax attachment handling.
*
* @group ajax
*
* @covers ::wp_ajax_send_attachment_to_editor
*/
class Tests_Ajax_Attachments extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxSendAttachmentToEditor extends WP_Ajax_UnitTestCase {
/**
* @ticket 36578
*
* @covers ::wp_ajax_send_attachment_to_editor
* @covers ::get_image_send_to_editor
*/
public function test_wp_ajax_send_attachment_to_editor_should_return_an_image() {
@ -58,8 +60,6 @@ class Tests_Ajax_Attachments extends WP_Ajax_UnitTestCase {
/**
* @ticket 36578
* @group ms-excluded
*
* @covers ::wp_ajax_send_attachment_to_editor
*/
public function test_wp_ajax_send_attachment_to_editor_should_return_a_link() {
// Become an administrator.

View File

@ -11,7 +11,7 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
*
* @covers ::wp_ajax_update_plugin
*/
class Tests_Ajax_Update_Plugin extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxUpdatePlugin extends WP_Ajax_UnitTestCase {
public function test_missing_nonce() {
$this->expectException( 'WPAjaxDieStopException' );

View File

@ -5,13 +5,13 @@
require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax handler for instlaling, updating, and deleting themes.
* Testing Ajax handler for installing, updating, and deleting themes.
*
* @group ajax
*
* @covers ::wp_ajax_update_theme
*/
class Tests_Ajax_Manage_Themes extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxUpdateTheme extends WP_Ajax_UnitTestCase {
private $orig_theme_dir;
private $theme_root;

View File

@ -8,17 +8,18 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php';
/**
* Testing Ajax compression test functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 3.4.0
* @group ajax
* @since 3.4.0
*
* @group ajax
*
* @covers ::wp_ajax_wp_compression_test
*/
class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxWpCompressionTest extends WP_Ajax_UnitTestCase {
/**
* Test as a logged out user
*
* @covers ::wp_ajax_wp_compression_test
*/
public function test_logged_out() {
$this->logout();
@ -34,8 +35,6 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase {
/**
* Fetch the test text
*
* @covers ::wp_ajax_wp_compression_test
*/
public function test_text() {
@ -60,8 +59,6 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase {
* Fetch the test text (gzdeflate)
*
* @requires function gzdeflate
*
* @covers ::wp_ajax_wp_compression_test
*/
public function test_gzdeflate() {
@ -87,8 +84,6 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase {
* Fetch the test text (gzencode)
*
* @requires function gzencode
*
* @covers ::wp_ajax_wp_compression_test
*/
public function test_gzencode() {
@ -112,8 +107,6 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase {
/**
* Fetch the test text (unknown encoding)
*
* @covers ::wp_ajax_wp_compression_test
*/
public function test_unknown_encoding() {
@ -132,8 +125,6 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase {
/**
* Set the 'can_compress_scripts' site option to true
*
* @covers ::wp_ajax_wp_compression_test
*/
public function test_set_yes() {
@ -172,8 +163,6 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase {
/**
* Set the 'can_compress_scripts' site option to false
*
* @covers ::wp_ajax_wp_compression_test
*/
public function test_set_no() {

View File

@ -16,7 +16,7 @@
*
* @covers ::wp_ajax_wp_privacy_erase_personal_data
*/
class Tests_Ajax_PrivacyErasePersonalData extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxWpPrivacyErasePersonalData extends WP_Ajax_UnitTestCase {
/**
* User Request ID.

View File

@ -16,7 +16,7 @@
*
* @covers ::wp_ajax_wp_privacy_export_personal_data
*/
class Tests_Ajax_PrivacyExportPersonalData extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpAjaxWpPrivacyExportPersonalData extends WP_Ajax_UnitTestCase {
/**
* User Request ID.

View File

@ -2,12 +2,13 @@
/**
* Testing Ajax customize manager functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 4.3.0
* @group ajax
* @since 4.3.0
*
* @group ajax
*/
class Tests_Ajax_CustomizeManager extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpCustomizeManager extends WP_Ajax_UnitTestCase {
/**
* Instance of WP_Customize_Manager which is reset for each test.

View File

@ -2,12 +2,13 @@
/**
* Testing Ajax customize menus functionality.
*
* @package WordPress
* @package WordPress
* @subpackage UnitTests
* @since 4.3.0
* @group ajax
* @since 4.3.0
*
* @group ajax
*/
class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase {
class Tests_Ajax_wpCustomizeNavMenus extends WP_Ajax_UnitTestCase {
/**
* Instance of WP_Customize_Manager which is reset for each test.