Make WordPress Core


Ignore:
Timestamp:
05/26/2025 02:34:12 PM (9 months ago)
Author:
johnbillion
Message:

Build/Test Tools: Increase shared user fixtures following switch to bcrypt hashing.

User creation is somewhat more expensive since switching the default password hashing algorithm to bcrypt in 6.8. This speeds up the tests by making more use of shared user fixtures, thus reducing the number of users that are created during tests.

Props peterwilsoncc.

See #63026

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/wpAjaxSendAttachmentToEditor.php

    r55764 r60253  
    1313 */
    1414class Tests_Ajax_wpAjaxSendAttachmentToEditor extends WP_Ajax_UnitTestCase {
     15
     16    /**
     17     * Shared user ID for the tests.
     18     *
     19     * @var int
     20     */
     21    public static $user_id = 0;
     22
     23    /**
     24     * Set up shared fixtures.
     25     *
     26     * @param WP_UnitTest_Factory $factory
     27     */
     28    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     29        self::$user_id = $factory->user->create(
     30            array(
     31                'role'       => 'administrator',
     32                'user_login' => 'user_36578_administrator',
     33                'user_email' => 'user_36578_administrator@example.com',
     34            )
     35        );
     36    }
    1537
    1638    /**
     
    106128        // Become an administrator.
    107129        $post    = $_POST;
    108         $user_id = self::factory()->user->create(
    109             array(
    110                 'role'       => 'administrator',
    111                 'user_login' => 'user_36578_administrator',
    112                 'user_email' => 'user_36578_administrator@example.com',
    113             )
    114         );
     130        $user_id = self::$user_id;
    115131        wp_set_current_user( $user_id );
    116132        $_POST = array_merge( $_POST, $post );
     
    152168        // Become an administrator.
    153169        $post    = $_POST;
    154         $user_id = self::factory()->user->create(
    155             array(
    156                 'role'       => 'administrator',
    157                 'user_login' => 'user_36578_administrator',
    158                 'user_email' => 'user_36578_administrator@example.com',
    159             )
    160         );
     170        $user_id = self::$user_id;
    161171        wp_set_current_user( $user_id );
    162172        $_POST = array_merge( $_POST, $post );
Note: See TracChangeset for help on using the changeset viewer.