Make WordPress Core

Changeset 52253


Ignore:
Timestamp:
11/26/2021 01:27:42 AM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/l10n.php

    r52010 r52253  
    408408        $this->factory()->post->create( $args );
    409409
     410        // Effectively ignore the output until retrieving it later via `getActualOutput()`.
     411        $this->expectOutputRegex( '`.`' );
     412
    410413        $expect = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do…';
    411414        wp_dashboard_recent_drafts();
    412415
    413         restore_previous_locale();
    414 
    415         $this->expectOutputRegex( '/' . $expect . '/' );
     416        $actual = $this->getActualOutput();
     417
     418        restore_previous_locale();
     419
     420        $this->assertMatchesRegularExpression( '/' . $expect . '/', $actual );
    416421    }
    417422
     
    432437        $post = $this->factory()->post->create( $args );
    433438
     439        // Effectively ignore the output until retrieving it later via `getActualOutput()`.
     440        $this->expectOutputRegex( '`.`' );
     441
    434442        $expect = 'Lorem ipsum dolor sit amet, consectetur …';
    435443        wp_dashboard_recent_drafts();
    436444
    437         restore_previous_locale();
    438 
    439         $this->expectOutputRegex( '/' . $expect . '/' );
     445        $actual = $this->getActualOutput();
     446
     447        restore_previous_locale();
     448
     449        $this->assertMatchesRegularExpression( '/' . $expect . '/', $actual );
    440450    }
    441451
     
    456466        $this->factory()->post->create( $args );
    457467
     468        // Effectively ignore the output until retrieving it later via `getActualOutput()`.
     469        $this->expectOutputRegex( '`.`' );
     470
    458471        $expect = str_repeat( 'あ', 40 ) . '…';
    459472        wp_dashboard_recent_drafts();
    460473
    461         restore_previous_locale();
    462 
    463         $this->expectOutputRegex( '/' . $expect . '/' );
     474        $actual = $this->getActualOutput();
     475
     476        restore_previous_locale();
     477
     478        $this->assertMatchesRegularExpression( '/' . $expect . '/', $actual );
    464479    }
    465480
Note: See TracChangeset for help on using the changeset viewer.