Make WordPress Core


Ignore:
Timestamp:
05/26/2025 02:34:12 PM (15 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/widgets.php

    r56746 r60253  
    2121        protected $backup_registered_sidebars;
    2222
     23        /**
     24         * ID of the administrator user.
     25         *
     26         * @var int
     27         */
     28        public static $administrator_id;
     29
     30        /**
     31         * Set up the shared fixture.
     32         *
     33         * @param WP_UnitTest_Factory $factory Factory instance.
     34         */
     35        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     36                self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) );
     37        }
     38
    2339        public function set_up() {
    2440                parent::set_up();
     
    2844                add_action( 'widgets_init', array( $this, 'remove_widgets_block_editor' ) );
    2945
    30                 $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    31                 wp_set_current_user( $user_id );
     46                wp_set_current_user( self::$administrator_id );
    3247
    3348                update_option(
Note: See TracChangeset for help on using the changeset viewer.