mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Use a consistent way of setting the Administrator role in Ajax tests.
This removes some duplicate code in favor of calling the `WP_Ajax_UnitTestCase::_setRole()` method created specifically for this purpose and used in other tests. Follow-up to [500/tests], [37288]. Props martin.krcho. See #56203. git-svn-id: https://develop.svn.wordpress.org/trunk@53701 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
0c4114395d
commit
27cfc58b34
@ -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 );
|
||||
|
||||
Loading…
Reference in New Issue
Block a user