From 6717df2b48e6c7f59a8d2b45d56249dbcaffb660 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 26 Nov 2021 01:27:42 +0000 Subject: [PATCH] Tests: Remove unexpected output in `wp_dashboard_recent_drafts()` tests on PHP 8.1. This follows the approach used in other tests to let PHPUnit manage the output catching and effectively ignore the output until retrieving it later via `getActualOutput()`. Follow-up to [45505], [51968], [52173]. See #53635, #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@52253 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/tests/l10n.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/l10n.php b/tests/phpunit/tests/l10n.php index 09c4ddfd62..51bb0468d4 100644 --- a/tests/phpunit/tests/l10n.php +++ b/tests/phpunit/tests/l10n.php @@ -407,12 +407,17 @@ class Tests_L10n extends WP_UnitTestCase { $this->factory()->post->create( $args ); + // Effectively ignore the output until retrieving it later via `getActualOutput()`. + $this->expectOutputRegex( '`.`' ); + $expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do…'; wp_dashboard_recent_drafts(); + $actual = $this->getActualOutput(); + restore_previous_locale(); - $this->expectOutputRegex( '/' . $expect . '/' ); + $this->assertMatchesRegularExpression( '/' . $expect . '/', $actual ); } /** @@ -431,12 +436,17 @@ class Tests_L10n extends WP_UnitTestCase { $post = $this->factory()->post->create( $args ); + // Effectively ignore the output until retrieving it later via `getActualOutput()`. + $this->expectOutputRegex( '`.`' ); + $expect = 'Lorem ipsum dolor sit amet, consectetur …'; wp_dashboard_recent_drafts(); + $actual = $this->getActualOutput(); + restore_previous_locale(); - $this->expectOutputRegex( '/' . $expect . '/' ); + $this->assertMatchesRegularExpression( '/' . $expect . '/', $actual ); } /** @@ -455,12 +465,17 @@ class Tests_L10n extends WP_UnitTestCase { $this->factory()->post->create( $args ); + // Effectively ignore the output until retrieving it later via `getActualOutput()`. + $this->expectOutputRegex( '`.`' ); + $expect = str_repeat( 'あ', 40 ) . '…'; wp_dashboard_recent_drafts(); + $actual = $this->getActualOutput(); + restore_previous_locale(); - $this->expectOutputRegex( '/' . $expect . '/' ); + $this->assertMatchesRegularExpression( '/' . $expect . '/', $actual ); } /**