Opened 5 months ago
Last modified 11 days ago
#65252 new enhancement
Test Progress: src/wp-admin/includes/ajax-actions.php
| Reported by: | pbearne | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 7.2 |
| Component: | Administration | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: | tests |
Description (last modified by )
Test Progress: src/wp-admin/includes/ajax-actions.php
This file tracks the status of unit tests for functions in src/wp-admin/includes/ajax-actions.php.
Completed Functions (Tests Found)
| Function | Status |
|---|---|
| wp_ajax_ajax_tag_search | ✅ Found |
| wp_ajax_wp_compression_test | ✅ Found |
| _wp_ajax_delete_comment_response | ✅ Found |
| wp_ajax_delete_comment | ✅ Found |
| wp_ajax_dim_comment | ✅ Found |
| wp_ajax_add_tag | ✅ Found |
| wp_ajax_get_comments | ✅ Found |
| wp_ajax_replyto_comment | ✅ Found |
| wp_ajax_edit_comment | ✅ Found |
| wp_ajax_add_meta | ✅ Found |
| wp_ajax_inline_save | ✅ Found |
| wp_ajax_image_editor | ✅ Found |
| wp_ajax_set_attachment_thumbnail | ✅ Found |
| wp_ajax_send_attachment_to_editor | ✅ Found |
| wp_ajax_heartbeat | ✅ Found |
| wp_ajax_crop_image | ✅ Found |
| wp_ajax_update_theme | ✅ Found |
| wp_ajax_update_plugin | ✅ Found |
| wp_ajax_delete_plugin | ✅ Found |
| wp_ajax_wp_privacy_export_personal_data | ✅ Found |
| wp_ajax_wp_privacy_erase_personal_data | ✅ Found |
| wp_ajax_parse_media_shortcode | ✅ Found |
These tests were moved to tests/phpunit/tests/admin/includes/ajax-actions in ticket 65226.
Missing Functions (Tests Not Found)
| Function | Status | Ticket | Pull Request | Committed |
|---|---|---|---|---|
| wp_ajax_nopriv_heartbeat | created | ✅ #65236 | 65236-ajax-actions-wp_ajax_nopriv_heartbeat | |
| wp_ajax_fetch_list | created | ✅ #65237 | 65237-ajax-actions-wp_ajax_fetch_list | |
| wp_ajax_imgedit_preview | created | #65252 | 11845 | |
| wp_ajax_oembed_cache | created | #65252 | 11846 | |
| wp_ajax_autocomplete_user | created | #65252 | 11866 | |
| wp_ajax_get_community_events | created | #65252 | 11867 | |
| wp_ajax_dashboard_widgets | created | #65252 | 11869 | |
| wp_ajax_logged_in | created | ✅ #65242 | 65242-ajax-actions-wp_ajax_logged_in | |
| _wp_ajax_add_hierarchical_term | created | #65252 | 11871 | |
| wp_ajax_delete_tag | created | #65252 | 11870 | |
| wp_ajax_delete_link | created | #65252 | 11872 | |
| wp_ajax_delete_meta | created | #65252 | 11873 | |
| wp_ajax_delete_post | created | #65252 | 11874 | |
| wp_ajax_trash_post | created | #65252 | 11875 | |
| wp_ajax_untrash_post | created | #65252 | 11876 | |
| wp_ajax_delete_page | created | #65252 | 11877 | |
| wp_ajax_add_link_category | created | #65252 | 11878 | |
| wp_ajax_get_tagcloud | created | #65252 | 11879 | |
| wp_ajax_add_menu_item | created | #65252 | 11880 | |
| wp_ajax_add_user | created | #65252 | 11881 | |
| wp_ajax_closed_postboxes | created | #65252 | 11882 | |
| wp_ajax_hidden_columns | created | #65252 | 11895 | |
| wp_ajax_update_welcome_panel | created | #65252 | 11896 | |
| wp_ajax_menu_get_metabox | created | #65252 | 11897 | |
| wp_ajax_wp_link_ajax | created | #65252 | 11898 | |
| wp_ajax_menu_locations_save | created | #65252 | 11899 | |
| wp_ajax_meta_box_order | created | #65252 | 11900 | |
| wp_ajax_menu_quick_search | created | #65252 | 11901 | |
| wp_ajax_get_permalink | created | #65252 | 11906 | |
| wp_ajax_sample_permalink | created | #65252 | 11907 | |
| wp_ajax_inline_save_tax | created | #65252 | 11908 | |
| wp_ajax_find_posts | created | #65252 | 11909 | |
| wp_ajax_widgets_order | created | #65341 | 11963 | |
| wp_ajax_save_widget | created | #65252 | 12075 | |
| wp_ajax_update_widget | created | #65252 | 12076 | |
| wp_ajax_delete_inactive_widgets | created | #65252 | 12090 | |
| wp_ajax_media_create_image_subsizes | created | #65252 | 12092 | |
| wp_ajax_upload_attachment | created | #65252 | 12092 | |
| wp_ajax_set_post_thumbnail | created | #65252 | 12091 | |
| wp_ajax_get_post_thumbnail_html | created | #65252 | 12091 | |
| wp_ajax_date_format | created | ✅ #65225 | 65225-ajax-date_format | |
| wp_ajax_time_format | created | ✅ #65228 | 65228-ajax-time_format | |
| wp_ajax_wp_fullscreen_save_post | created | #65252 | 12138 | |
| wp_ajax_wp_remove_post_lock | created | #65252 | 12138 | |
| wp_ajax_dismiss_wp_pointer | created | #65252 | 12138 | |
| wp_ajax_get_attachment | created | #65252 | 12093 | |
| wp_ajax_query_attachments | created | #65252 | 12093 | |
| wp_ajax_save_attachment | created | #65252 | 12096 | |
| wp_ajax_save_attachment_compat | created | #65252 | 12094 | |
| wp_ajax_save_attachment_order | created | #65252 | 12095 | |
| wp_ajax_send_attachment_to_editor | created | #65252 | 12095 | |
| wp_ajax_get_revision_diffs | created | #65252 | 12097 | |
| wp_ajax_send_link_to_editor | created | #65252 | 12097 | |
| wp_ajax_save_user_color_scheme | created | #65252 | 12098 | |
| wp_ajax_query_themes | created | #65252 | 12128 | |
| wp_ajax_parse_embed | created | #65252 | 12128 | |
| wp_ajax_destroy_sessions | created | #65252 | 12128 | |
| wp_ajax_generate_password | created | #65252 | 12129 | |
| wp_ajax_nopriv_generate_password | created | #65252 | 12129 | |
| wp_ajax_save_wporg_username | created | #65252 | 12129 | |
| wp_ajax_install_theme | created | #65252 | 12129 | |
| wp_ajax_delete_theme | created | #65252 | 12129 | |
| wp_ajax_install_plugin | created | #65252 | 12129 | |
| wp_ajax_activate_plugin | created | #65252 | 12129 | |
| wp_ajax_search_plugins | created | #65252 | 12129 | |
| wp_ajax_search_install_plugins | created | #65252 | 12129 | |
| wp_ajax_edit_theme_plugin_file | created | #65252 | 12129 | |
| wp_ajax_health_check_dotorg_communication | created | #65252 | 12130 | |
| wp_ajax_health_check_background_updates | created | #65252 | 12130 | |
| wp_ajax_health_check_loopback_requests | created | #65252 | 12130 | |
| wp_ajax_health_check_site_status_result | created | #65252 | 12130 | |
| wp_ajax_health_check_get_sizes | created | #65252 | 12130 | |
| wp_ajax_rest_nonce | created | ✅ #65243 | 11837 | |
| wp_ajax_toggle_auto_updates | created | #65252 | 12130 | |
| wp_ajax_send_password_reset | created | #65252 | 12130 |
Change History (94)
This ticket was mentioned in PR #11845 on WordPress/wordpress-develop by @pbearne.
5 months ago
#2
- Keywords has-patch has-unit-tests added
This ticket was mentioned in PR #11846 on WordPress/wordpress-develop by @pbearne.
5 months ago
#4
- Keywords has-patch has-unit-tests added
This PR adds unit tests for the wp_ajax_oembed_cache() function, which handles oEmbed caching via AJAX.
The tests cover:
- Successful trigger of oEmbed caching for a post.
- Handling of invalid post IDs (should still exit with 0 as per implementation).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
#6
@
5 months ago
- Description modified (diff)
(adjusted to Trac WikiFormatting for links and tables)
This ticket was mentioned in PR #11866 on WordPress/wordpress-develop by @pbearne.
5 months ago
#7
- Keywords has-patch has-unit-tests added
This PR adds unit tests for the wp_ajax_autocomplete_user() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Searching for users by login.
- Searching for users by email.
- Adding users to a site (which should exclude existing members).
- Non-member inclusion when adding users.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11867 on WordPress/wordpress-develop by @pbearne.
5 months ago
#8
This PR adds unit tests for the wp_ajax_get_community_events() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful retrieval of community events with mocked API response.
- Proper handling of API errors (e.g., non-200 response codes).
- Nonce validation for security.
- Verification of user meta update for saved location.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11869 on WordPress/wordpress-develop by @pbearne.
5 months ago
#9
This PR adds unit tests for the wp_ajax_dashboard_widgets() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful retrieval of community events with mocked API response.
- Proper handling of API errors (e.g., non-200 response codes).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11870 on WordPress/wordpress-develop by @pbearne.
5 months ago
#11
This PR adds unit tests for the wp_ajax_delete_tag() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful deletion of tags (post_tag).
- Successful deletion of categories.
- Proper handling of invalid nonces.
- Verification of user permissions (delete_term capability).
- Behavior when attempting to delete a non-existent tag ID.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11871 on WordPress/wordpress-develop by @pbearne.
5 months ago
#12
This PR adds unit tests for the _wp_ajax_add_hierarchical_term() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful creation of hierarchical terms (e.g., categories).
- Creation of child terms with a specified parent.
- Adding multiple terms at once (comma-separated).
- Nonce validation for security.
- Verification of user permissions (edit_terms capability).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11872 on WordPress/wordpress-develop by @pbearne.
5 months ago
#13
This PR adds unit tests for the wp_ajax_delete_link() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful deletion of links (bookmarks).
- Proper handling of invalid nonces.
- Verification of user permissions (
manage_linkscapability). - Behavior when attempting to delete a non-existent link ID (idempotent success).
Note: The tests enable the link_manager_enabled option to allow the manage_links capability to be correctly checked, as the Link Manager is disabled by default in modern WordPress.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11873 on WordPress/wordpress-develop by @pbearne.
5 months ago
#14
This PR adds unit tests for the wp_ajax_delete_meta() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful deletion of post metadata.
- Proper handling of invalid nonces.
- Verification of user permissions (
delete_post_metacapability). - Prevention of deleting protected meta keys (keys starting with
_). - Behavior when attempting to delete a non-existent meta ID (idempotent success).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11874 on WordPress/wordpress-develop by @pbearne.
5 months ago
#15
This PR adds unit tests for the wp_ajax_delete_post() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful deletion of posts (when they are already in the trash).
- Proper handling of invalid nonces.
- Verification of user permissions (
delete_postcapability). - Behavior when attempting to delete a non-existent post ID.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11875 on WordPress/wordpress-develop by @pbearne.
5 months ago
#16
This PR adds unit tests for the wp_ajax_trash_post() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful trashing of posts.
- Proper handling of invalid nonces.
- Verification of user permissions (
delete_postcapability). - Behavior when attempting to trash a non-existent post ID (verified that permission check fails first).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11876 on WordPress/wordpress-develop by @pbearne.
5 months ago
#17
This PR adds unit tests for the wp_ajax_untrash_post() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful untrashing of posts (restoring from trash).
- Proper handling of invalid nonces.
- Verification of user permissions (
delete_postcapability). - Behavior when attempting to untrash a non-existent post ID.
The tests use the $factory = self::factory(); pattern to access the unit test factory.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11877 on WordPress/wordpress-develop by @pbearne.
5 months ago
#18
This PR adds unit tests for the wp_ajax_delete_page() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful permanent deletion of pages (when they are already in the trash).
- Proper handling of invalid nonces.
- Verification of user permissions (
delete_pagecapability). - Behavior when attempting to delete a non-existent page ID.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11878 on WordPress/wordpress-develop by @pbearne.
5 months ago
#19
This PR adds unit tests for the wp_ajax_add_link_category() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful addition of a single link category.
- Successful addition of multiple comma-separated link categories.
- Proper handling of invalid nonces.
- Verification of user permissions (
manage_termscapability forlink_categorytaxonomy). - Behavior when attempting to add an empty category name.
Note: The tests enable the link_manager_enabled option and re-run taxonomy initialization to ensure the link_category taxonomy is available for testing.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11879 on WordPress/wordpress-develop by @pbearne.
5 months ago
#20
This PR adds unit tests for the wp_ajax_get_tagcloud() function located in src/wp-admin/includes/ajax-actions.php. The tests cover:
- Successful generation of a tag cloud for a given taxonomy.
- Proper handling of missing or invalid taxonomy parameters.
- Verification of user permissions (edit_posts capability).
Behavior when no terms are found for the requested taxonomy.
The tests ensure that the function returns the expected HTML for the tag cloud or the appropriate error/empty messages based on the input and environment.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, file management, and workflow orchestration.
This ticket was mentioned in PR #11880 on WordPress/wordpress-develop by @pbearne.
5 months ago
#21
This PR adds unit tests for the wp_ajax_add_menu_item() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful addition of custom menu items (links).
- Successful addition of post-based menu items (e.g., pages).
- Proper handling of invalid nonces.
- Verification of user permissions (
edit_theme_optionscapability).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11881 on WordPress/wordpress-develop by @pbearne.
5 months ago
#22
This PR adds unit tests for the wp_ajax_add_user() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful creation of a new user via AJAX.
- Proper handling of invalid nonces.
- Verification of user permissions (
create_userscapability). - Behavior when
edit_user()returns aWP_Error(e.g., invalid email address).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11882 on WordPress/wordpress-develop by @pbearne.
5 months ago
#23
This PR adds unit tests for the wp_ajax_closed_postboxes() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful update of closed and hidden postboxes for a given page.
- Proper handling of invalid nonces.
- Verification of page key sanitization (rejection of invalid keys).
- Ensuring that protected postboxes (e.g.,
submitdiv) are not hidden.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11895 on WordPress/wordpress-develop by @pbearne.
5 months ago
#25
This PR adds unit tests for the wp_ajax_hidden_columns() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful update of hidden columns in user meta.
- Proper handling of invalid nonces.
- Validation of the page parameter (ensuring it passes
sanitize_key). - Correct behavior when the
hiddenparameter is empty.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11896 on WordPress/wordpress-develop by @pbearne.
5 months ago
#26
This PR adds unit tests for the wp_ajax_update_welcome_panel() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful update of the welcome panel visibility (both showing and hiding).
- Proper handling of invalid nonces.
- Verification of user permissions (
edit_theme_optionscapability).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11897 on WordPress/wordpress-develop by @pbearne.
5 months ago
#27
This PR adds unit tests for the wp_ajax_menu_get_metabox() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful retrieval of post type metaboxes (e.g., for 'post').
- Successful retrieval of taxonomy metaboxes (e.g., for 'category').
- Proper handling of insufficient user permissions (verification of
edit_theme_optionscapability). - Validation of input parameters (
item-typeanditem-object).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11898 on WordPress/wordpress-develop by @pbearne.
5 months ago
#28
This PR adds unit tests for the wp_ajax_wp_link_ajax() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful internal link searching using the
searchPOST parameter. - Successful internal link searching using the
termPOST parameter. - Proper handling of pagination through the
pageparameter. - Validation of AJAX nonces (
_ajax_linking_nonce). - Behavior when no results are found (ensuring it dies with
0).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11899 on WordPress/wordpress-develop by @pbearne.
5 months ago
#29
This PR adds unit tests for the wp_ajax_menu_locations_save() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful saving of menu locations in theme modifications.
- Proper handling of invalid nonces (
add-menu_itemnonce). - Verification of user permissions (
edit_theme_optionscapability). - Correct behavior when the
menu-locationsparameter is missing.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11900 on WordPress/wordpress-develop by @pbearne.
5 months ago
#30
This PR adds unit tests for the wp_ajax_meta_box_order() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful update of meta box order in user meta.
- Successful update of screen layout (page columns), including the 'auto' value.
- Proper handling of invalid nonces.
- Validation of the page parameter (ensuring it passes
sanitize_key). - Behavior when no user is logged in (ensuring it dies with
-1).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11901 on WordPress/wordpress-develop by @pbearne.
5 months ago
#31
This PR adds unit tests for the wp_ajax_menu_quick_search() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful retrieval of post items by ID in JSON format.
- Successful retrieval of post items by ID in markup format (HTML).
- Successful retrieval of taxonomy terms by ID in JSON format.
- Successful search for menu items using a search query (q parameter).
- Proper handling of insufficient user permissions (verification of
edit_theme_optionscapability).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11906 on WordPress/wordpress-develop by @pbearne.
5 months ago
#32
This PR adds unit tests for the wp_ajax_get_permalink() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful retrieval of a post permalink.
- Proper handling of invalid nonces (
getpermalinknonce). - Behavior when the
post_idparameter is missing.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11907 on WordPress/wordpress-develop by @pbearne.
5 months ago
#33
This PR adds unit tests for the wp_ajax_sample_permalink() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful retrieval of a sample permalink HTML with custom title and slug.
- Proper handling of invalid nonces (
samplepermalinknonce). - Correct behavior when using default inputs (missing
new_titleornew_slug).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11908 on WordPress/wordpress-develop by @pbearne.
5 months ago
#34
This PR adds unit tests for the wp_ajax_inline_save_tax() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful update of a term via Quick Edit.
- Proper handling of invalid nonces (
taxinlineeditnonce). - Validation of the taxonomy parameter.
- Behavior when the
tax_IDparameter is missing. - Verification of user permissions (
edit_termcapability).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11909 on WordPress/wordpress-develop by @pbearne.
5 months ago
#35
This PR adds unit tests for the wp_ajax_find_posts() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful post searching using the
psPOST parameter. - Proper handling of invalid nonces (
find-postsnonce). - Behavior when no results are found (ensuring it returns a JSON error).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11910 on WordPress/wordpress-develop by @pbearne.
5 months ago
#36
This PR adds unit tests for the wp_ajax_inline_save() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful Quick Edit save for both posts and pages.
- Proper handling of invalid nonces (
inlineeditnonce). - Behavior when the
post_IDparameter is missing. - Verification of user permissions (
edit_postandedit_pagecapabilities). - Correct behavior when a post is locked by another user.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #11911 on WordPress/wordpress-develop by @pbearne.
5 months ago
#37
This PR adds unit tests for the wp_ajax_widgets_order() function located in src/wp-admin/includes/ajax-actions.php.
The tests cover:
- Successful saving of the widgets order for multiple sidebars.
- Proper handling of invalid nonces (
save-sidebar-widgetsnonce). - Verification of user permissions (
edit_theme_optionscapability). - Behavior when the
sidebarsparameter is missing.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
@pbearne commented on PR #11910:
5 months ago
#38
already tested
@pbearne commented on PR #11911:
5 months ago
#41
move to https://github.com/WordPress/wordpress-develop/pull/11963
As a change, the function was needed
@orionaselite commented on PR #11907:
4 months ago
#42
Tested PR #11907 locally against current trunk.
Environment:
- WordPress develop at 7.1-alpha-src
- PHP 8.3.31 in the Docker local environment
- MySQL 9.7 Docker service
- PHPUnit 9.6.34
Results:
- Targeted Ajax tests for the new class pass:
- npm run test:php -- --group ajax --filter Tests_wp_ajax_sample_permalink
- Result: 3 tests, 5 assertions
- PHPCS passes for the new test file:
- vendor/bin/phpcs --standard=phpcs.xml.dist tests/phpunit/tests/admin/includes/ajax-actions/samplePermalink.php
The added coverage for wp_ajax_sample_permalink() looks good from this local test pass.
This ticket was mentioned in PR #12075 on WordPress/wordpress-develop by @pbearne.
4 months ago
#43
This PR adds unit tests for the wp_ajax_save_widget() function in src/wp-admin/includes/ajax-actions.php, covering successful widget deletion, adding new multi-widgets, and various failure scenarios (invalid nonce, insufficient permissions, missing parameters).
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management
This ticket was mentioned in PR #12076 on WordPress/wordpress-develop by @pbearne.
4 months ago
#44
This PR adds unit tests for the wp_ajax_update_widget() function in src/wp-admin/includes/ajax-actions.php, which delegates to the Customizer's widget update mechanism. The tests cover validation of the AJAX nonce, handling of missing widget IDs, and rejection of template widget updates.
•
Trac ticket: https://core.trac.wordpress.org/ticket/65252
•
AI Disclosure:
◦
AI assistance: Yes
◦
Tool(s): Junie (JetBrains)
◦
Model(s): gemini-3-flash-preview
◦
Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #12090 on WordPress/wordpress-develop by @pbearne.
4 months ago
#46
This PR adds unit tests for the wp_ajax_delete_inactive_widgets() function in src/wp-admin/includes/ajax-actions.php. The tests cover the successful removal of widgets from the inactive widgets sidebar (and their corresponding options), as well as failure cases for invalid AJAX nonces and insufficient user permissions.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #12091 on WordPress/wordpress-develop by @pbearne.
4 months ago
#47
This PR adds unit tests for wp_ajax_set_post_thumbnail() and wp_ajax_get_post_thumbnail_html() in src/wp-admin/includes/ajax-actions.php. The tests cover setting and removing featured images using both traditional and JSON-based requests, as well as permission and nonce validation.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and verification.
This ticket was mentioned in PR #12092 on WordPress/wordpress-develop by @pbearne.
4 months ago
#48
…onality
This PR adds unit tests for wp_ajax_media_create_image_subsizes() and wp_ajax_upload_attachment() in src/wp-admin/includes/ajax-actions.php. The tests cover successful image sub-size generation, attachment uploading with mocked filesystem checks, and various error conditions including invalid nonces and insufficient permissions.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and complex mocking of internal WordPress functions.
This ticket was mentioned in PR #12093 on WordPress/wordpress-develop by @pbearne.
4 months ago
#49
Ajax: Add tests for attachment retrieval and querying
- Description: This PR adds unit tests for
wp_ajax_get_attachment()andwp_ajax_query_attachments()insrc/wp-admin/includes/ajax-actions.php. The tests cover successful data retrieval, search functionality, and error handling for permissions and invalid inputs.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and debugging environment-specific AJAX test behavior.
This ticket was mentioned in PR #12094 on WordPress/wordpress-develop by @pbearne.
4 months ago
#50
…achment_compat`.
This PR reorganizes the AJAX unit tests for several media and widget handlers. Each AJAX call now has its own dedicated test class and file, improving maintainability and following the requested project structure.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code refactoring, test organization, and verification.
This ticket was mentioned in PR #12095 on WordPress/wordpress-develop by @pbearne.
4 months ago
#51
This PR adds unit tests for wp_ajax_save_attachment_order() and wp_ajax_send_attachment_to_editor() in src/wp-admin/includes/ajax-actions.php. The tests cover updating the menu order of multiple attachments, generating HTML for editor insertion (for both images and other files), and validating nonces and permissions.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and verification.
This ticket was mentioned in PR #12096 on WordPress/wordpress-develop by @pbearne.
4 months ago
#52
This PR adds unit tests for wp_ajax_save_attachment() in src/wp-admin/includes/ajax-actions.php. The tests cover updating the menu order of multiple attachments, generating HTML for editor insertion (for both images and other files), and validating nonces and permissions.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
AI assistance: Yes
Tool(s): Junie (JetBrains)
Model(s): gemini-3-flash-preview
Used for: Code analysis, test implementation, and verification.
This ticket was mentioned in PR #12097 on WordPress/wordpress-develop by @pbearne.
4 months ago
#53
…p_ajax_send_link_to_editor`.
This PR adds unit tests for wp_ajax_get_revision_diffs() and wp_ajax_send_link_to_editor() in src/wp-admin/includes/ajax-actions.php. The tests cover updating the menu order of multiple attachments, generating HTML for editor insertion (for both images and other files), and validating nonces and permissions.
Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure:
AI assistance: Yes
Tool(s): Junie (JetBrains)
Model(s): gemini-3-flash-preview
Used for: Code analysis, test implementation, and verification.
This ticket was mentioned in PR #12098 on WordPress/wordpress-develop by @pbearne.
4 months ago
#54
This PR adds comprehensive unit tests for the wp_ajax_save_user_color_scheme AJAX handler, covering success scenarios with different color schemes and failure cases for invalid schemes or nonces.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #12128 on WordPress/wordpress-develop by @pbearne.
4 months ago
#56
…tions
This PR adds comprehensive unit tests for the wp_ajax_destroy_sessions, wp_ajax_parse_embed and wp_ajax_query_themes AJAX handler, covering success scenarios with different color schemes and failure cases for invalid schemes or nonces.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and workflow management.
This ticket was mentioned in PR #12129 on WordPress/wordpress-develop by @pbearne.
4 months ago
#57
wp_ajax_generate_password/wp_ajax_nopriv_generate_passwordwp_ajax_save_wporg_usernamewp_ajax_install_themewp_ajax_delete_themewp_ajax_install_pluginwp_ajax_activate_pluginwp_ajax_search_pluginswp_ajax_search_install_pluginswp_ajax_edit_theme_plugin_file
This PR adds unit tests for various theme and plugin-related AJAX handlers in src/wp-admin/includes/ajax-actions.php. The tests cover successful operations, permission checks, and error handling for invalid nonces or missing parameters.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and verification.
This ticket was mentioned in PR #12130 on WordPress/wordpress-develop by @pbearne.
4 months ago
#58
…nd REST nonce handlers
wp_ajax_health_check_dotorg_communicationwp_ajax_health_check_background_updateswp_ajax_health_check_loopback_requestswp_ajax_health_check_site_status_resultwp_ajax_health_check_get_sizeswp_ajax_toggle_auto_updateswp_ajax_send_password_resetwp_ajax_rest_nonce
This PR adds unit tests for several AJAX handlers in src/wp-admin/includes/ajax-actions.php, including Site Health checks (dotorg communication, background updates, loopback requests, result saving, and directory sizes), plugin/theme auto-update toggling, password reset emails, and REST nonce retrieval.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, and environment verification.
This ticket was mentioned in PR #12138 on WordPress/wordpress-develop by @pbearne.
4 months ago
#60
…ax_wp_fullscreen_save_post, and wp_ajax_wp_remove_post_lock`.
This PR adds unit tests for three AJAX handlers in
ajax-actions.phpto improve test coverage and ensure stability.
- Trac ticket: https://core.trac.wordpress.org/ticket/65252
- AI Disclosure:
- AI assistance: Yes
- Tool(s): Junie (JetBrains)
- Model(s): gemini-3-flash-preview
- Used for: Code analysis, test implementation, refactoring to meet guidelines, and workflow management.
#63
@
2 months ago
- Milestone 7.1 → 7.2
Unfortunately, the 7.1 RC1 release is next week, and we don't have time to review all the PRs associated with this ticket. Let's punt this to a future release.
This ticket was mentioned in Slack in #core by pbearne. View the logs.
5 weeks ago
@ugyensupport commented on PR #12138:
5 weeks ago
#65
### Test report
Applied this PR's diff cleanly to current trunk and ran it against the WP core PHPUnit suite (PHPUnit 9.6.36, PHP 8.3, local MySQL test DB).
Results:
- ✅ Patch applies cleanly — purely additive, 3 new test files, no production code touched.
- ✅ All 7 new tests pass:
wp_ajax_dismiss_wp_pointer: 3 tests, 6 assertionswp_ajax_wp_fullscreen_save_post: 2 tests, 6 assertionswp_ajax_wp_remove_post_lock: 2 tests, 7 assertions
- ✅ Mutation check — deliberately broke
wp_ajax_dismiss_wp_pointer()(forced an earlywp_die( 0 )) and the suite correctly caught it (1 failure, expected'1'got'0'), confirming the tests aren't tautological. - ✅ No naming/registration collisions with the existing
tests/phpunit/tests/ajax/suite. - ✅ WPCS: 0 violations across all 3 new files (
phpcs.xml.dist).
Also manually reviewed the wp_ajax_wp_remove_post_lock() window-math assertion (time() - 145) against the source — it's correct, no false-positive risk there.
LGTM.
#66
@
11 days ago
I reviewed the 23 open PRs here that add files under tests/phpunit/tests/admin/includes/ajax-actions/, then ran them on trunk@64009: PHP 8.3, MySQL 9.7, PHPUnit 9.6, single site and multisite, --group ajax. The existing ajax tests still pass alongside them.
Two changes cover most of them:
- Drop the
admin_inithook inset_up()._handleAjax()firesadmin_initbeforewp_ajax_{action}, so the handler runs before its real hook. It also hides wrong action names, such asdelete_postfordelete-post. If the test harness doesn't register an action, hookwp_ajax_{action}inset_up()instead. - Don't assert only inside
catch. A normal return skips every check. UseexpectException()andexpectExceptionMessage(), as the tests intests/phpunit/tests/ajax/do.
| PR | Status |
| 11907, 11908, 12093 | ready |
| 11872, 11873, 11876, 11877, 11878, 11879, 11882, 11895 | 1 and 2 |
| 11867, 11874, 11909, 12098 | 1, plus the right action name |
| 11871 | 1; the asserts after expectException() never run
|
| 12091 | 2 |
| 11900 | the "no user" test takes the success path |
| 12075 | the permission test also omits id_base
|
| 12076 | restore $GLOBALS['wp_customize']
|
| 11845 | rework: the action is imgedit-preview, so the handler never runs
|
| 11869 | rework: skips the ajax handler; fails on live feed requests |
| 11906 | rework: the handler returns '' for a missing ID; fails
|
@lancewillett commented on PR #11907:
11 days ago
#67
Thanks, @pbearne. This looks good to me and passes on current trunk, single site and multisite. Notes on the rest of the batch: #65252 comment:66
@lancewillett commented on PR #11908:
11 days ago
#68
Thanks, @pbearne. This looks good to me and passes on current trunk, single site and multisite. Notes on the rest of the batch: #65252 comment:66
@lancewillett commented on PR #12093:
11 days ago
#69
Thanks, @pbearne. This looks good to me and passes on current trunk, single site and multisite. Notes on the rest of the batch: #65252 comment:66
@lancewillett commented on PR #11872:
11 days ago
#70
Thanks, @pbearne. Two changes, explained in #65252 comment:66: drop the admin_init hook in set_up(), and move the assertions out of catch.
@lancewillett commented on PR #11873:
11 days ago
#71
Thanks, @pbearne. Two changes, explained in #65252 comment:66: drop the admin_init hook in set_up(), and move the assertions out of catch.
@lancewillett commented on PR #11876:
11 days ago
#72
Thanks, @pbearne. Two changes, explained in #65252 comment:66: drop the admin_init hook in set_up(), and move the assertions out of catch.
@lancewillett commented on PR #11877:
11 days ago
#73
Thanks, @pbearne. Two changes, explained in #65252 comment:66: drop the admin_init hook in set_up(), and move the assertions out of catch.
@lancewillett commented on PR #11878:
11 days ago
#74
Thanks, @pbearne. Two changes, explained in #65252 comment:66: drop the admin_init hook in set_up(), and move the assertions out of catch.
@lancewillett commented on PR #11879:
11 days ago
#75
Thanks, @pbearne. Two changes, explained in #65252 comment:66: drop the admin_init hook in set_up(), and move the assertions out of catch.
@lancewillett commented on PR #11882:
11 days ago
#76
Thanks, @pbearne. Two changes, explained in #65252 comment:66: drop the admin_init hook in set_up(), and move the assertions out of catch.
@lancewillett commented on PR #11895:
11 days ago
#77
Thanks, @pbearne. Two changes, explained in #65252 comment:66: drop the admin_init hook in set_up(), and move the assertions out of catch.
@lancewillett commented on PR #11867:
11 days ago
#78
Thanks, @pbearne. Please drop the admin_init hook and dispatch get-community-events, hooking wp_ajax_get-community-events in set_up() since the harness doesn't register it. Details: #65252 comment:66
@lancewillett commented on PR #11874:
11 days ago
#79
Thanks, @pbearne. Please drop the admin_init hook and dispatch delete-post, the registered action. Details: #65252 comment:66
@lancewillett commented on PR #11909:
11 days ago
#80
Thanks, @pbearne. Please dispatch find_posts, the registered action, and drop the custom wp_ajax_find-posts hook. Details: #65252 comment:66
@lancewillett commented on PR #12098:
11 days ago
#81
Thanks, @pbearne. Please dispatch save-user-color-scheme, the registered action, and keep save-color-scheme as the nonce only. Details: #65252 comment:66
@lancewillett commented on PR #11871:
11 days ago
#82
Thanks, @pbearne. Please drop the admin_init hook; the taxonomy already registers wp_ajax_add-category. In the nonce test, the asserts after expectException() never run. Details: #65252 comment:66
@lancewillett commented on PR #12091:
11 days ago
#83
Thanks, @pbearne. Please move the nonce and permission assertions out of catch, so a normal return can't skip them. Details: #65252 comment:66
@lancewillett commented on PR #11900:
11 days ago
#84
Thanks, @pbearne. The "no user" test takes the success path, because wp_get_current_user() returns an object even for ID 0. Please assert what it returns and name the test to match. Details: #65252 comment:66
@lancewillett commented on PR #12075:
11 days ago
#85
Thanks, @pbearne. The permission test also omits id_base, which gets the same -1, so it passes even without the capability check. Please send a valid id_base. Details: #65252 comment:66
@lancewillett commented on PR #12076:
11 days ago
#86
Thanks, @pbearne. Please save and restore $GLOBALS[https://core.trac.wordpress.org/ticket/65252#comment:66 'wp_customize'] in tear_down(), since the base test case doesn't reset it. Details: comment:66
@lancewillett commented on PR #11845:
11 days ago
#87
Thanks, @pbearne. The registered action is imgedit-preview, so imgedit_preview never reaches the handler and the tests pass anyway. Details: #65252 comment:66
@lancewillett commented on PR #11869:
11 days ago
#88
Thanks, @pbearne. This calls wp_dashboard_primary() instead of the ajax handler, and it fails because it requests the live WordPress.org feeds. Please dispatch dashboard-widgets and mock the feeds with pre_http_request. Details: #65252 comment:66
@lancewillett commented on PR #11906:
11 days ago
#89
Thanks, @pbearne. For a missing post ID, the handler returns an empty string on purpose (wp_die( '' )), so this test fails. Please assert the empty response. Details: #65252 comment:66
@lancewillett commented on PR #11907:
11 days ago
#90
Added 7f2235e58d to create a real post in the invalid-nonce test. With the hard-coded ID, even a valid nonce could return -1 because the post did not exist, allowing the test to pass for the wrong reason.
Verified that the corrected test rejects the valid-nonce negative control. All 16 batch tests pass on current trunk in randomized order, single site and multisite; PHPCS passes too.
---
<sub>Adversarial review · <code>gpt-6</code></sub>
@lancewillett commented on PR #11907:
11 days ago
#92
Committed in r64011. Thanks, @pbearne!
@lancewillett commented on PR #11908:
11 days ago
#93
Committed in r64011. Thanks, @pbearne!
@lancewillett commented on PR #12093:
11 days ago
#94
Committed in r64011. Thanks, @pbearne!
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
This PR adds unit tests for the
wp_ajax_imgedit_preview()function, which handles image editor previews via AJAX.The tests cover:
postid.postid.Trac ticket: https://core.trac.wordpress.org/ticket/65252
AI Disclosure: