mirror of
git://develop.git.wordpress.org/
synced 2025-03-22 04:49:49 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@52259 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
164a61aeb6
commit
ca2b4936b3
@ -407,17 +407,12 @@ 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…';
|
||||
$this->expectOutputRegex( '/' . $expect . '/' );
|
||||
|
||||
wp_dashboard_recent_drafts();
|
||||
|
||||
$actual = $this->getActualOutput();
|
||||
|
||||
restore_previous_locale();
|
||||
|
||||
$this->assertMatchesRegularExpression( '/' . $expect . '/', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -436,17 +431,12 @@ 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 …';
|
||||
$this->expectOutputRegex( '/' . $expect . '/' );
|
||||
|
||||
wp_dashboard_recent_drafts();
|
||||
|
||||
$actual = $this->getActualOutput();
|
||||
|
||||
restore_previous_locale();
|
||||
|
||||
$this->assertMatchesRegularExpression( '/' . $expect . '/', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -465,17 +455,12 @@ 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 ) . '…';
|
||||
$this->expectOutputRegex( '/' . $expect . '/' );
|
||||
|
||||
wp_dashboard_recent_drafts();
|
||||
|
||||
$actual = $this->getActualOutput();
|
||||
|
||||
restore_previous_locale();
|
||||
|
||||
$this->assertMatchesRegularExpression( '/' . $expect . '/', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -611,8 +611,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
}
|
||||
);
|
||||
|
||||
// Effectively ignore the output until retrieving it later via `getActualOutput()`.
|
||||
$this->expectOutputRegex( '`.`' );
|
||||
$this->expectOutputRegex( '/Test Title/' );
|
||||
|
||||
$widget->display_callback(
|
||||
array(
|
||||
@ -624,11 +623,7 @@ class Tests_Widgets extends WP_UnitTestCase {
|
||||
2
|
||||
);
|
||||
|
||||
$actual = $this->getActualOutput();
|
||||
|
||||
unregister_widget( $widget );
|
||||
|
||||
$this->assertStringContainsString( 'Test Title', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user