Make WordPress Core


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

    r56547 r60253  
    77 */
    88class Tests_WP_Customize_Panel extends WP_UnitTestCase {
     9
     10    /**
     11     * ID of the administrator user.
     12     *
     13     * @var int
     14     */
     15    public static $administrator_id;
     16
     17    /**
     18     * Set up the shared fixture.
     19     *
     20     * @param WP_UnitTest_Factory $factory Factory instance.
     21     */
     22    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     23        self::$administrator_id = $factory->user->create( array( 'role' => 'administrator' ) );
     24    }
    925
    1026    /**
     
    132148     */
    133149    public function test_check_capabilities() {
    134         $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    135         wp_set_current_user( $user_id );
     150        wp_set_current_user( self::$administrator_id );
    136151
    137152        $panel = new WP_Customize_Panel( $this->manager, 'foo' );
     
    158173     */
    159174    public function test_maybe_render() {
    160         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     175        wp_set_current_user( self::$administrator_id );
    161176        $panel                        = new WP_Customize_Panel( $this->manager, 'bar' );
    162177        $customize_render_panel_count = did_action( 'customize_render_panel' );
     
    183198     */
    184199    public function test_print_templates_standard() {
    185         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     200        wp_set_current_user( self::$administrator_id );
    186201
    187202        $panel = new WP_Customize_Panel( $this->manager, 'baz' );
     
    201216     */
    202217    public function test_print_templates_custom() {
    203         wp_set_current_user( self::factory()->user->create( array( 'role' => 'administrator' ) ) );
     218        wp_set_current_user( self::$administrator_id );
    204219
    205220        $panel = new Custom_Panel_Test( $this->manager, 'baz' );
Note: See TracChangeset for help on using the changeset viewer.