Make WordPress Core


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

    r60251 r60253  
    55 */
    66class Tests_Taxonomy extends WP_UnitTestCase {
     7
     8        /**
     9         * Editor user ID.
     10         *
     11         * @var int $editor_id
     12         */
     13        public static $editor_id;
     14
     15        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     16                self::$editor_id = $factory->user->create( array( 'role' => 'editor' ) );
     17        }
     18
    719        public function test_get_post_taxonomies() {
    820                $this->assertSame( array( 'category', 'post_tag', 'post_format' ), get_object_taxonomies( 'post' ) );
     
    10111023                );
    10121024
    1013                 wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     1025                wp_set_current_user( self::$editor_id );
    10141026                $updated_post_id = edit_post(
    10151027                        array(
     
    10371049        public function test_default_term_for_custom_taxonomy() {
    10381050
    1039                 wp_set_current_user( self::factory()->user->create( array( 'role' => 'editor' ) ) );
     1051                wp_set_current_user( self::$editor_id );
    10401052
    10411053                $tax = 'custom-tax';
Note: See TracChangeset for help on using the changeset viewer.