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/admin/includesTemplate.php

    r59564 r60253  
    44 */
    55class Tests_Admin_IncludesTemplate extends WP_UnitTestCase {
     6    /**
     7     * Editor user ID.
     8     *
     9     * @var int $editor_id
     10     */
     11    public static $editor_id;
     12
     13    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     14        self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
     15    }
    616
    717    /**
     
    6575
    6676        // Test that get_inline_data() has `post_category` div containing the assigned term.
    67         wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     77        wp_set_current_user( self::$editor_id );
    6878        get_inline_data( $post );
    6979        $this->expectOutputRegex( '/<div class="post_category" id="wptests_tax_1_' . $post->ID . '">' . $term['term_id'] . '<\/div>/' );
     
    91101
    92102        // Test that get_inline_data() has `tags_input` div containing the assigned term.
    93         wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     103        wp_set_current_user( self::$editor_id );
    94104        get_inline_data( $post );
    95105        $this->expectOutputRegex( '/<div class="tags_input" id="wptests_tax_1_' . $post->ID . '">Test<\/div>/' );
Note: See TracChangeset for help on using the changeset viewer.