Make WordPress Core


Ignore:
Timestamp:
05/26/2025 02:34:12 PM (10 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/customize/custom-css-setting.php

    r54865 r60253  
    2424
    2525    /**
     26     * The user ID to use for the tests.
     27     *
     28     * @var int
     29     */
     30    public static $user_id = 0;
     31
     32    /**
     33     * Set up the test case.
     34     *
     35     * @see WP_UnitTestCase::set_up()
     36     */
     37    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     38        // Create a user to use for the tests.
     39        self::$user_id = $factory->user->create(
     40            array(
     41                'role' => 'administrator',
     42            )
     43        );
     44
     45        if ( is_multisite() ) {
     46            grant_super_admin( self::$user_id );
     47        }
     48    }
     49
     50    /**
    2651     * Set up the test case.
    2752     *
     
    3257        require_once ABSPATH . WPINC . '/class-wp-customize-manager.php';
    3358
    34         $user_id = self::factory()->user->create(
    35             array(
    36                 'role' => 'administrator',
    37             )
    38         );
    39         if ( is_multisite() ) {
    40             grant_super_admin( $user_id );
    41         }
    42 
    43         wp_set_current_user( $user_id );
     59        wp_set_current_user( self::$user_id );
    4460
    4561        global $wp_customize;
Note: See TracChangeset for help on using the changeset viewer.