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/post/getPostsByAuthorSql.php

    r51566 r60253  
    55 */
    66class Tests_Post_GetPostsByAuthorSql extends WP_UnitTestCase {
     7
     8    /**
     9     * ID of the first user.
     10     *
     11     * @var int
     12     */
     13    public static $user_id_1;
     14
     15    /**
     16     * ID of the second user.
     17     *
     18     * @var int
     19     */
     20    public static $user_id_2;
     21
     22    /**
     23     * Set up the shared fixture.
     24     *
     25     * @param WP_UnitTest_Factory $factory Factory instance.
     26     */
     27    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     28        self::$user_id_1 = $factory->user->create();
     29        self::$user_id_2 = $factory->user->create();
     30    }
    731
    832    public function test_post_type_post() {
     
    6084    public function test_public_only_true_should_not_allow_any_private_posts_for_loggedin_user() {
    6185        $current_user = get_current_user_id();
    62         $u            = self::factory()->user->create();
     86        $u            = self::$user_id_1;
    6387        wp_set_current_user( $u );
    6488
     
    7195    public function test_public_only_should_default_to_false() {
    7296        $current_user = get_current_user_id();
    73         $u            = self::factory()->user->create();
     97        $u            = self::$user_id_1;
    7498        wp_set_current_user( $u );
    7599
     
    81105    public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_current_user_matches_post_author() {
    82106        $current_user = get_current_user_id();
    83         $u            = self::factory()->user->create();
     107        $u            = self::$user_id_1;
    84108        wp_set_current_user( $u );
    85109
     
    92116    public function test_public_only_false_should_not_allow_access_to_private_posts_if_current_user_is_not_post_author() {
    93117        $current_user = get_current_user_id();
    94         $u1           = self::factory()->user->create();
    95         $u2           = self::factory()->user->create();
     118        $u1           = self::$user_id_1;
     119        $u2           = self::$user_id_2;
    96120        wp_set_current_user( $u1 );
    97121
     
    104128    public function test_public_only_false_should_allow_current_user_access_to_own_private_posts_when_post_author_is_not_provided() {
    105129        $current_user = get_current_user_id();
    106         $u            = self::factory()->user->create();
     130        $u            = self::$user_id_1;
    107131        wp_set_current_user( $u );
    108132
Note: See TracChangeset for help on using the changeset viewer.