From 970084d023f69c1256e154313b329dfb5522683a Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Mon, 1 Dec 2025 15:45:04 -0700 Subject: [PATCH] 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. --- .../wpBlockProcessor-BlockProcessing.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/tests/block-processor/wpBlockProcessor-BlockProcessing.php b/tests/phpunit/tests/block-processor/wpBlockProcessor-BlockProcessing.php index 838fdb6494450..6f3e657d3e024 100644 --- a/tests/phpunit/tests/block-processor/wpBlockProcessor-BlockProcessing.php +++ b/tests/phpunit/tests/block-processor/wpBlockProcessor-BlockProcessing.php @@ -49,31 +49,34 @@ public function test_get_depth() { } $processor = new WP_Block_Processor( $html ); - $n = new NumberFormatter( 'en-US', NumberFormatter::ORDINAL ); for ( $i = 0; $i < $max_depth; $i++ ) { + $nth = $i + 1; + $this->assertTrue( $processor->next_delimiter(), - "Should have found {$n->format( $i + 1 )} opening delimiter: check test setup." + "Should have found opening delimiter #{$nth}: check test setup." ); $this->assertSame( $i + 1, $processor->get_depth(), - "Should have identified the proper depth of the {$n->format( $i + 1 )} opening delimiter." + "Should have identified the proper depth of opening delimiter #{$nth}." ); } for ( $i = 0; $i < $max_depth; $i++ ) { + $nth = $i + 1; + $this->assertTrue( $processor->next_delimiter(), - "Should have found {$n->format( $i + 1 )} closing delimiter: check test setup." + "Should have found closing delimiter #{$nth}: check test setup." ); $this->assertSame( $max_depth - $i - 1, $processor->get_depth(), - "Should have identified the proper depth of the {$n->format( $i + 1 )} closing delimiter." + "Should have identified the proper depth of closing delimiter #{$nth}." ); } }