Make WordPress Core

Changeset 46830


Ignore:
Timestamp:
12/09/2019 10:39:39 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Pad incrementors used in factories with leading zeros to make sure MySQL sorting works as expected.

Previously, tests could create sequential objects with names like Term 99, Term 100, which by default would be returned in reverse order when sorted by name alphabetically, causing seemingly random test failures that are extremely hard to debug.

See #48145.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/factory/class-wp-unittest-factory-for-thing.php

    r46586 r46830  
    131131
    132132        // Use the same incrementor for all fields belonging to this object.
    133         $gen  = new WP_UnitTest_Generator_Sequence();
    134         $incr = $gen->get_incr();
     133        $gen = new WP_UnitTest_Generator_Sequence();
     134        // Add leading zeros to make sure MySQL sorting works as expected.
     135        $incr = zeroise( $gen->get_incr(), 7 );
    135136
    136137        foreach ( array_keys( $generation_definitions ) as $field_name ) {
Note: See TracChangeset for help on using the changeset viewer.