Make WordPress Core


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

    r56549 r60253  
    88class Tests_URL extends WP_UnitTestCase {
    99
     10    /**
     11     * Author user ID.
     12     *
     13     * @var int $author_id
     14     */
     15    public static $author_id;
     16
     17    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     18        self::$author_id = $factory->user->create( array( 'role' => 'author' ) );
     19    }
     20
    1021    public function set_up() {
    1122        parent::set_up();
     
    387398     */
    388399    public function test_get_adjacent_post_should_return_private_posts_belonging_to_the_current_user() {
    389         $u       = self::factory()->user->create( array( 'role' => 'author' ) );
     400        $u       = self::$author_id;
    390401        $old_uid = get_current_user_id();
    391402        wp_set_current_user( $u );
     
    426437     */
    427438    public function test_get_adjacent_post_should_return_private_posts_belonging_to_other_users_if_the_current_user_can_read_private_posts() {
    428         $u1      = self::factory()->user->create( array( 'role' => 'author' ) );
     439        $u1      = self::$author_id;
    429440        $u2      = self::factory()->user->create( array( 'role' => 'administrator' ) );
    430441        $old_uid = get_current_user_id();
     
    466477     */
    467478    public function test_get_adjacent_post_should_not_return_private_posts_belonging_to_other_users_if_the_current_user_cannot_read_private_posts() {
    468         $u1      = self::factory()->user->create( array( 'role' => 'author' ) );
     479        $u1      = self::$author_id;
    469480        $u2      = self::factory()->user->create( array( 'role' => 'author' ) );
    470481        $old_uid = get_current_user_id();
Note: See TracChangeset for help on using the changeset viewer.