Make WordPress Core


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

    r56746 r60253  
    77 */
    88class Tests_Post_GetPages extends WP_UnitTestCase {
     9
     10    /**
     11     * ID of the first author.
     12     *
     13     * @var int
     14     */
     15    public static $author_id_1;
     16
     17    /**
     18     * ID of the second author.
     19     *
     20     * @var int
     21     */
     22    public static $author_id_2;
     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::$author_id_1 = $factory->user->create(
     31            array(
     32                'user_login' => 'author1',
     33                'role'       => 'author',
     34            )
     35        );
     36
     37        self::$author_id_2 = $factory->user->create(
     38            array(
     39                'user_login' => 'author2',
     40                'role'       => 'author',
     41            )
     42        );
     43    }
     44
    945    /**
    1046     * @ticket 23167
     
    9641000     */
    9651001    public function test_get_pages_author() {
    966         $author_1 = self::factory()->user->create(
    967             array(
    968                 'user_login' => 'author1',
    969                 'role'       => 'author',
    970             )
    971         );
     1002        $author_1 = self::$author_id_1;
    9721003        $posts    = self::factory()->post->create_many(
    9731004            2,
     
    9901021     */
    9911022    public function test_get_pages_multiple_authors() {
    992         $author_1 = self::factory()->user->create(
    993             array(
    994                 'user_login' => 'author1',
    995                 'role'       => 'author',
    996             )
    997         );
     1023        $author_1 = self::$author_id_1;
    9981024        $post_1   = self::factory()->post->create(
    9991025            array(
     
    10051031        );
    10061032
    1007         $author_2 = self::factory()->user->create(
    1008             array(
    1009                 'user_login' => 'author2',
    1010                 'role'       => 'author',
    1011             )
    1012         );
     1033        $author_2 = self::$author_id_2;
    10131034        $post_2   = self::factory()->post->create(
    10141035            array(
     
    10321053     */
    10331054    public function test_get_pages_multiple_authors_by_user_login() {
    1034         $author_1 = self::factory()->user->create(
    1035             array(
    1036                 'user_login' => 'author1',
    1037                 'role'       => 'author',
    1038             )
    1039         );
     1055        $author_1 = self::$author_id_1;
    10401056        $post_1   = self::factory()->post->create(
    10411057            array(
     
    10471063        );
    10481064
    1049         $author_2 = self::factory()->user->create(
    1050             array(
    1051                 'user_login' => 'author2',
    1052                 'role'       => 'author',
    1053             )
    1054         );
     1065        $author_2 = self::$author_id_2;
    10551066        $post_2   = self::factory()->post->create(
    10561067            array(
Note: See TracChangeset for help on using the changeset viewer.