Make WordPress Core


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

    r58876 r60253  
    55 */
    66class Tests_Admin_IncludesPlugin extends WP_UnitTestCase {
     7
     8        /**
     9         * Admin user ID.
     10         *
     11         * @var int $admin_id
     12         */
     13        public static $admin_id;
     14
    715        public static function wpSetUpBeforeClass( $factory ) {
     16                self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
    817                self::_back_up_mu_plugins();
    918        }
    … …  
    3847        public function test_menu_page_url() {
    3948                $current_user = get_current_user_id();
    40                 wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     49                wp_set_current_user( self::$admin_id );
    4150                update_option( 'siteurl', 'http://example.com' );
    4251
    … …  
    8291                global $menu;
    8392                $current_user = get_current_user_id();
    84                 $admin_user   = self::factory()->user->create( array( 'role' => 'administrator' ) );
     93                $admin_user   = self::$admin_id;
    8594                wp_set_current_user( $admin_user );
    8695                set_current_screen( 'dashboard' );
    … …  
    135144
    136145                $current_user = get_current_user_id();
    137                 $admin_user   = self::factory()->user->create( array( 'role' => 'administrator' ) );
     146                $admin_user   = self::$admin_id;
    138147                wp_set_current_user( $admin_user );
    139148                set_current_screen( 'dashboard' );
    … …  
    284293                $menu         = array();
    285294                $current_user = get_current_user_id();
    286                 $admin_user   = self::factory()->user->create( array( 'role' => 'administrator' ) );
     295                $admin_user   = self::$admin_id;
    287296                wp_set_current_user( $admin_user );
    288297                set_current_screen( 'dashboard' );
    … …  
    317326                $menu         = array();
    318327                $current_user = get_current_user_id();
    319                 $admin_user   = self::factory()->user->create( array( 'role' => 'administrator' ) );
     328                $admin_user   = self::$admin_id;
    320329                wp_set_current_user( $admin_user );
    321330                set_current_screen( 'dashboard' );
    … …  
    345354                $menu         = array();
    346355                $current_user = get_current_user_id();
    347                 $admin_user   = self::factory()->user->create( array( 'role' => 'administrator' ) );
     356                $admin_user   = self::$admin_id;
    348357                wp_set_current_user( $admin_user );
    349358                set_current_screen( 'dashboard' );
Note: See TracChangeset for help on using the changeset viewer.