Make WordPress Core

Changeset 61342


Ignore:
Timestamp:
12/01/2025 11:42:12 PM (12 days ago)
Author:
dmsnell
Message:

Block Processor: Remove use of NumberFormatter from test suite.

The Block Processor tests call NumberFormatter for generating its
error messages, but in environments lacking the intl extension this
led to crashes while running the tests.

This patch reworks the tests so that they avoid calling
NumberFormatter so that the tests run on more diverse setups.

Developed in https://github.com/WordPress/wordpress-develop/pull/10576
Discussed in https://core.trac.wordpress.org/ticket/64329

Follow-up to [60939].

Props desrosj, ellatrix, peterwilsoncc, westonruter.

See #64329.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/block-processor/wpBlockProcessor-BlockProcessing.php

    r61294 r61342  
    5050
    5151        $processor = new WP_Block_Processor( $html );
    52         $n         = new NumberFormatter( 'en-US', NumberFormatter::ORDINAL );
    5352
    5453        for ( $i = 0; $i < $max_depth; $i++ ) {
     54            $nth = $i + 1;
     55
    5556            $this->assertTrue(
    5657                $processor->next_delimiter(),
    57                 "Should have found {$n->format( $i + 1 )} opening delimiter: check test setup."
     58                "Should have found opening delimiter #{$nth}: check test setup."
    5859            );
    5960
     
    6162                $i + 1,
    6263                $processor->get_depth(),
    63                 "Should have identified the proper depth of the {$n->format( $i + 1 )} opening delimiter."
     64                "Should have identified the proper depth of opening delimiter #{$nth}."
    6465            );
    6566        }
    6667
    6768        for ( $i = 0; $i < $max_depth; $i++ ) {
     69            $nth = $i + 1;
     70
    6871            $this->assertTrue(
    6972                $processor->next_delimiter(),
    70                 "Should have found {$n->format( $i + 1 )} closing delimiter: check test setup."
     73                "Should have found closing delimiter #{$nth}: check test setup."
    7174            );
    7275
     
    7477                $max_depth - $i - 1,
    7578                $processor->get_depth(),
    76                 "Should have identified the proper depth of the {$n->format( $i + 1 )} closing delimiter."
     79                "Should have identified the proper depth of closing delimiter #{$nth}."
    7780            );
    7881        }
Note: See TracChangeset for help on using the changeset viewer.