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/query/conditionals.php

    r56559 r60253  
    1515        protected $post_ids;
    1616
     17        /**
     18         * ID of the user-a.
     19         *
     20         * @var int
     21         */
     22        public static $user_a_id;
     23
     24        /**
     25         * Set up the shared fixture.
     26         *
     27         * @param WP_UnitTest_Factory $factory Factory instance.
     28         */
     29        public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     30                self::$user_a_id = $factory->user->create( array( 'user_login' => 'user-a' ) );
     31        }
     32
    1733        public function set_up() {
    1834                parent::set_up();
    … …  
    589605        // 'author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',
    590606        public function test_author_feed() {
    591                 self::factory()->user->create( array( 'user_login' => 'user-a' ) );
    592607                // Check the long form.
    593608                $types = array( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
    … …  
    608623        public function test_author_paged() {
    609624                update_option( 'posts_per_page', 2 );
    610                 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
     625                $user_id = self::$user_a_id;
    611626                self::factory()->post->create_many( 3, array( 'post_author' => $user_id ) );
    612627                $this->go_to( '/author/user-a/page/2/' );
    … …  
    616631        // 'author/([^/]+)/?$' => 'index.php?author_name=$matches[1]',
    617632        public function test_author() {
    618                 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
     633                $user_id = self::$user_a_id;
    619634                self::factory()->post->create( array( 'post_author' => $user_id ) );
    620635                $this->go_to( '/author/user-a/' );
    … …  
    623638
    624639        public function test_author_with_no_posts() {
    625                 $user_id = self::factory()->user->create( array( 'user_login' => 'user-a' ) );
    626640                $this->go_to( '/author/user-a/' );
    627641                $this->assertQueryTrue( 'is_archive', 'is_author' );
    … …  
    11231137         */
    11241138        public function test_is_author_with_nicename_that_begins_with_a_number_that_clashes_with_another_author_id() {
    1125                 $u1 = self::factory()->user->create();
     1139                $u1 = self::$user_a_id;
    11261140
    11271141                $u2_name = $u1 . '_user';
    … …  
    12801294
    12811295                // We need a non-post that shares an ID with a post assigned a template.
    1282                 $user_id = self::factory()->user->create();
     1296                $user_id = self::$user_a_id;
    12831297                if ( ! get_post( $user_id ) ) {
    12841298                        $post_id = self::factory()->post->create( array( 'post_type' => 'post' ) );
    … …  
    13531367         */
    13541368        public function test_is_author_should_not_match_numeric_id_to_nickname_beginning_with_id() {
    1355                 $u1 = self::factory()->user->create(
    1356                         array(
    1357                                 'nickname'      => 'Foo',
    1358                                 'user_nicename' => 'foo',
    1359                         )
    1360                 );
     1369                $u1 = self::$user_a_id;
    13611370                $u2 = self::factory()->user->create(
    13621371                        array(
    … …  
    13761385         */
    13771386        public function test_is_author_should_not_match_numeric_id_to_user_nicename_beginning_with_id() {
    1378                 $u1 = self::factory()->user->create(
    1379                         array(
    1380                                 'nickname'      => 'Foo',
    1381                                 'user_nicename' => 'foo',
    1382                         )
    1383                 );
     1387                $u1 = self::$user_a_id;
    13841388                $u2 = self::factory()->user->create(
    13851389                        array(
Note: See TracChangeset for help on using the changeset viewer.