Make WordPress Core


Ignore:
Timestamp:
11/27/2021 04:16:15 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Use a simpler approach to test the output in some tests.

Instead of ignoring the output and catching it later with getActualOutput(), we can use expectOutputRegex() directly, which evaluates the output after the rest of the test code has run, if no unexpected errors were encountered.

Follow-up to [52173], [52253].

Props jrf.
See #53635, #53363.

File:
1 edited

Legend:

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

    r52173 r52259  
    612612        );
    613613
    614         // Effectively ignore the output until retrieving it later via `getActualOutput()`.
    615         $this->expectOutputRegex( '`.`' );
     614        $this->expectOutputRegex( '/Test Title/' );
    616615
    617616        $widget->display_callback(
     
    625624        );
    626625
    627         $actual = $this->getActualOutput();
    628 
    629626        unregister_widget( $widget );
    630 
    631         $this->assertStringContainsString( 'Test Title', $actual );
    632627    }
    633628
Note: See TracChangeset for help on using the changeset viewer.