diff --git a/tests/phpunit/tests/ajax/Attachments.php b/tests/phpunit/tests/ajax/Attachments.php index baf7c7f4fc..91d6943c99 100644 --- a/tests/phpunit/tests/ajax/Attachments.php +++ b/tests/phpunit/tests/ajax/Attachments.php @@ -18,16 +18,7 @@ class Tests_Ajax_Attachments extends WP_Ajax_UnitTestCase { */ public function test_wp_ajax_send_attachment_to_editor_should_return_an_image() { // Become an administrator. - $post = $_POST; - $user_id = self::factory()->user->create( - array( - 'role' => 'administrator', - 'user_login' => 'user_36578_administrator', - 'user_email' => 'user_36578_administrator@example.com', - ) - ); - wp_set_current_user( $user_id ); - $_POST = array_merge( $_POST, $post ); + $this->_setRole( 'administrator' ); $filename = DIR_TESTDATA . '/images/canola.jpg'; $contents = file_get_contents( $filename ); @@ -74,16 +65,7 @@ class Tests_Ajax_Attachments extends WP_Ajax_UnitTestCase { $this->skipWithMultisite(); // Become an administrator. - $post = $_POST; - $user_id = self::factory()->user->create( - array( - 'role' => 'administrator', - 'user_login' => 'user_36578_administrator', - 'user_email' => 'user_36578_administrator@example.com', - ) - ); - wp_set_current_user( $user_id ); - $_POST = array_merge( $_POST, $post ); + $this->_setRole( 'administrator' ); $filename = DIR_TESTDATA . '/formatting/entities.txt'; $contents = file_get_contents( $filename );