diff --git a/tests/phpunit/tests/ajax/Compression.php b/tests/phpunit/tests/ajax/Compression.php index 8e42a1e66d..fdb52d3f0b 100644 --- a/tests/phpunit/tests/ajax/Compression.php +++ b/tests/phpunit/tests/ajax/Compression.php @@ -25,7 +25,8 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase { $_GET['test'] = 1; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'wp-compression-test' ); } @@ -118,7 +119,8 @@ class Tests_Ajax_CompressionTest extends WP_Ajax_UnitTestCase { $_SERVER['HTTP_ACCEPT_ENCODING'] = 'unknown'; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'wp-compression-test' ); } diff --git a/tests/phpunit/tests/ajax/CustomizeMenus.php b/tests/phpunit/tests/ajax/CustomizeMenus.php index 3baa07758d..861a4ab6ba 100644 --- a/tests/phpunit/tests/ajax/CustomizeMenus.php +++ b/tests/phpunit/tests/ajax/CustomizeMenus.php @@ -53,8 +53,9 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { function test_ajax_load_available_items_cap_check( $role, $expected_results ) { if ( 'administrator' !== $role ) { - // If we're not an admin, we should get a wp_die(-1). - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + // 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 ) ) ); @@ -442,8 +443,9 @@ class Tests_Ajax_CustomizeMenus extends WP_Ajax_UnitTestCase { 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->setExpectedException( 'WPAjaxDieStopException', '-1' ); + // 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 ) ) ); diff --git a/tests/phpunit/tests/ajax/DeleteComment.php b/tests/phpunit/tests/ajax/DeleteComment.php index cc2624872c..70076f001b 100644 --- a/tests/phpunit/tests/ajax/DeleteComment.php +++ b/tests/phpunit/tests/ajax/DeleteComment.php @@ -137,7 +137,8 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase { $_POST['_url'] = admin_url( 'edit-comments.php' ); // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'delete-comment' ); } @@ -168,7 +169,8 @@ class Tests_Ajax_DeleteComment extends WP_Ajax_UnitTestCase { $_POST['_url'] = admin_url( 'edit-comments.php' ); // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'delete-comment' ); } diff --git a/tests/phpunit/tests/ajax/DeletePlugin.php b/tests/phpunit/tests/ajax/DeletePlugin.php index aa22790a42..fb2168c339 100644 --- a/tests/phpunit/tests/ajax/DeletePlugin.php +++ b/tests/phpunit/tests/ajax/DeletePlugin.php @@ -12,7 +12,8 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php'; class Tests_Ajax_Delete_Plugin extends WP_Ajax_UnitTestCase { public function test_missing_nonce() { - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'delete-plugin' ); } diff --git a/tests/phpunit/tests/ajax/DimComment.php b/tests/phpunit/tests/ajax/DimComment.php index 51fb2bb9a6..dcf5ba07ab 100644 --- a/tests/phpunit/tests/ajax/DimComment.php +++ b/tests/phpunit/tests/ajax/DimComment.php @@ -130,7 +130,8 @@ class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase { $_POST['_url'] = admin_url( 'edit-comments.php' ); // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'dim-comment' ); } @@ -158,7 +159,8 @@ class Tests_Ajax_DimComment extends WP_Ajax_UnitTestCase { $_POST['_url'] = admin_url( 'edit-comments.php' ); // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'dim-comment' ); } diff --git a/tests/phpunit/tests/ajax/EditComment.php b/tests/phpunit/tests/ajax/EditComment.php index 66ecdae8b4..83f8fee28b 100644 --- a/tests/phpunit/tests/ajax/EditComment.php +++ b/tests/phpunit/tests/ajax/EditComment.php @@ -149,7 +149,8 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'edit-comment' ); } @@ -177,7 +178,8 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'get-comments' ); } @@ -197,7 +199,8 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'edit-comment' ); } @@ -225,7 +228,8 @@ class Tests_Ajax_EditComment extends WP_Ajax_UnitTestCase { add_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', 'wp_update_comment_data filter fails for this comment.' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( 'wp_update_comment_data filter fails for this comment.' ); $this->_handleAjax( 'edit-comment' ); } diff --git a/tests/phpunit/tests/ajax/GetComments.php b/tests/phpunit/tests/ajax/GetComments.php index b1812ca892..582f5f38ba 100644 --- a/tests/phpunit/tests/ajax/GetComments.php +++ b/tests/phpunit/tests/ajax/GetComments.php @@ -90,7 +90,8 @@ class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase { $_POST['p'] = self::$comment_post->ID; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'get-comments' ); } @@ -110,7 +111,8 @@ class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase { $_POST['p'] = self::$comment_post->ID; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'get-comments' ); } @@ -130,7 +132,8 @@ class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase { $_POST['p'] = 'b0rk'; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'get-comments' ); } @@ -148,7 +151,8 @@ class Tests_Ajax_GetComments extends WP_Ajax_UnitTestCase { $_POST['p'] = self::$no_comment_post->ID; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '1' ); $this->_handleAjax( 'get-comments' ); } } diff --git a/tests/phpunit/tests/ajax/PrivacyErasePersonalData.php b/tests/phpunit/tests/ajax/PrivacyErasePersonalData.php index 3eb54a6df4..36928f940d 100644 --- a/tests/phpunit/tests/ajax/PrivacyErasePersonalData.php +++ b/tests/phpunit/tests/ajax/PrivacyErasePersonalData.php @@ -331,7 +331,8 @@ class Tests_Ajax_PrivacyErasePersonalData extends WP_Ajax_UnitTestCase { * @since 5.2.0 */ public function test_failure_with_invalid_nonce() { - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_make_ajax_call( array( diff --git a/tests/phpunit/tests/ajax/PrivacyExportPersonalData.php b/tests/phpunit/tests/ajax/PrivacyExportPersonalData.php index 6e5c9b8a5b..9ba321e730 100644 --- a/tests/phpunit/tests/ajax/PrivacyExportPersonalData.php +++ b/tests/phpunit/tests/ajax/PrivacyExportPersonalData.php @@ -292,7 +292,8 @@ class Tests_Ajax_PrivacyExportPersonalData extends WP_Ajax_UnitTestCase { * @since 5.2.0 */ public function test_failure_with_invalid_nonce() { - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_make_ajax_call( array( diff --git a/tests/phpunit/tests/ajax/ReplytoComment.php b/tests/phpunit/tests/ajax/ReplytoComment.php index 2b160c4597..3e638aa80c 100644 --- a/tests/phpunit/tests/ajax/ReplytoComment.php +++ b/tests/phpunit/tests/ajax/ReplytoComment.php @@ -113,7 +113,8 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { $_POST['comment_post_ID'] = self::$comment_post->ID; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'replyto-comment' ); } @@ -142,7 +143,8 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { $_POST['comment_post_ID'] = self::$comment_post->ID; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'replyto-comment' ); } @@ -162,7 +164,8 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { $_POST['comment_post_ID'] = 123456789; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'replyto-comment' ); } @@ -182,7 +185,8 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { $_POST['comment_post_ID'] = self::$draft_post->ID; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', 'Error: You can’t reply to a comment on a draft post.' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( 'Error: You can’t reply to a comment on a draft post.' ); $this->_handleAjax( 'replyto-comment' ); } @@ -252,7 +256,8 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { add_filter( 'pre_comment_approved', array( $this, '_pre_comment_approved_filter' ), 10, 2 ); // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', 'pre_comment_approved filter fails for new comment' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( 'pre_comment_approved filter fails for new comment.' ); $this->_handleAjax( 'replyto-comment' ); } @@ -260,6 +265,6 @@ class Tests_Ajax_ReplytoComment extends WP_Ajax_UnitTestCase { * Blocks comments from being saved on 'pre_comment_approved', by returning WP_Error. */ function _pre_comment_approved_filter( $approved, $commentdata ) { - return new WP_Error( 'comment_wrong', 'pre_comment_approved filter fails for new comment', 403 ); + return new WP_Error( 'comment_wrong', 'pre_comment_approved filter fails for new comment.', 403 ); } } diff --git a/tests/phpunit/tests/ajax/TagSearch.php b/tests/phpunit/tests/ajax/TagSearch.php index 80a327ee93..a92694f46d 100644 --- a/tests/phpunit/tests/ajax/TagSearch.php +++ b/tests/phpunit/tests/ajax/TagSearch.php @@ -74,7 +74,8 @@ class Tests_Ajax_TagSearch extends WP_Ajax_UnitTestCase { // Make the request. // No output, so we get a stop exception. - $this->setExpectedException( 'WPAjaxDieStopException', '' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '' ); $this->_handleAjax( 'ajax-tag-search' ); } @@ -114,7 +115,8 @@ class Tests_Ajax_TagSearch extends WP_Ajax_UnitTestCase { $_GET['q'] = 'chat'; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'ajax-tag-search' ); } @@ -131,7 +133,8 @@ class Tests_Ajax_TagSearch extends WP_Ajax_UnitTestCase { $_GET['q'] = 'chat'; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '0' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '0' ); $this->_handleAjax( 'ajax-tag-search' ); } @@ -148,7 +151,8 @@ class Tests_Ajax_TagSearch extends WP_Ajax_UnitTestCase { $_GET['q'] = 'chat'; // Make the request. - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'ajax-tag-search' ); } diff --git a/tests/phpunit/tests/ajax/UpdatePlugin.php b/tests/phpunit/tests/ajax/UpdatePlugin.php index c9690d4f7b..648164c7b2 100644 --- a/tests/phpunit/tests/ajax/UpdatePlugin.php +++ b/tests/phpunit/tests/ajax/UpdatePlugin.php @@ -12,7 +12,8 @@ require_once ABSPATH . 'wp-admin/includes/ajax-actions.php'; class Tests_Ajax_Update_Plugin extends WP_Ajax_UnitTestCase { public function test_missing_nonce() { - $this->setExpectedException( 'WPAjaxDieStopException', '-1' ); + $this->expectException( 'WPAjaxDieStopException' ); + $this->expectExceptionMessage( '-1' ); $this->_handleAjax( 'update-plugin' ); }