Make WordPress Core


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

    r57920 r60253  
    1717     */
    1818    public $undefined;
     19
     20    /**
     21     * Shared admin user ID for the tests.
     22     *
     23     * @var int
     24     */
     25    public static $admin_id = 0;
     26
     27    /**
     28     * Set up shared fixtures.
     29     *
     30     * @param WP_UnitTest_Factory $factory Factory.
     31     */
     32    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     33        self::$admin_id = $factory->user->create( array( 'role' => 'administrator' ) );
     34    }
    1935
    2036    public function set_up() {
     
    138154     */
    139155    public function test_preview_standard_types_non_multidimensional() {
    140         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     156        wp_set_current_user( self::$admin_id );
    141157        $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
    142158
     
    217233     */
    218234    public function test_preview_standard_types_multidimensional() {
    219         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     235        wp_set_current_user( self::$admin_id );
    220236        $_POST['customized'] = wp_slash( wp_json_encode( $this->post_data_overrides ) );
    221237
     
    363379     */
    364380    public function test_preview_custom_type() {
    365         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     381        wp_set_current_user( self::$admin_id );
    366382        $type                = 'custom_type';
    367383        $post_data_overrides = array(
     
    514530
    515531        // Satisfy all requirements for save to happen.
    516         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     532        wp_set_current_user( self::$admin_id );
    517533        $this->assertNotFalse( $setting->save() );
    518534        $this->assertTrue( 1 === did_action( 'customize_update_custom' ) );
     
    552568     */
    553569    public function test_is_current_blog_previewed() {
    554         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     570        wp_set_current_user( self::$admin_id );
    555571        $type       = 'option';
    556572        $name       = 'blogname';
     
    574590     */
    575591    public function test_previewing_with_switch_to_blog() {
    576         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     592        wp_set_current_user( self::$admin_id );
    577593        $type       = 'option';
    578594        $name       = 'blogdescription';
     
    597613    public function test_option_autoloading() {
    598614        global $wpdb;
    599         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     615        wp_set_current_user( self::$admin_id );
    600616
    601617        $name    = 'autoloaded1';
     
    744760     */
    745761    public function test_multidimensional_value_when_previewed() {
    746         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     762        wp_set_current_user( self::$admin_id );
    747763        WP_Customize_Setting::reset_aggregated_multidimensionals();
    748764
Note: See TracChangeset for help on using the changeset viewer.