You appear to be a bot. Output may be restricted
Description
Testing the error messages for ajax_search_available_items
Usage
Tests_Ajax_CustomizeMenus::test_ajax_search_available_items_caps_check( $role, $expected_results );
Parameters
- $role
- ( string ) required – Role.
- $expected_results
- ( array ) required – Expected results.
Returns
void
Source
File name: wordpress-develop-tests/phpunit/tests/ajax/CustomizeMenus.php
Lines:
1 to 27 of 27
public function test_ajax_search_available_items_caps_check( $role, $expected_results ) { if ( 'administrator' !== $role ) { // If we're not an admin, we should get a wp_die( -1 ). $this->expectException( 'WPAjaxDieStopException' ); $this->expectExceptionMessage( '-1' ); } wp_set_current_user( self::factory()->user->create( array( 'role' => $role ) ) ); $_POST = array( 'action' => 'search-available-menu-items-customizer', 'customize-menus-nonce' => wp_create_nonce( 'customize-menus' ), ); $this->make_ajax_call( 'search-available-menu-items-customizer' ); // If we are an admin, we should get a proper response. if ( 'administrator' === $role ) { // Get the results. $response = json_decode( $this->_last_response, true ); $this->assertSame( $expected_results, $response ); } }