mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
Tests: Replace assertContains() with assertStringContainsString() when used with strings.
Using the `assertContains()` and `assertNotContains()` methods with string haystacks was deprecated in PHPUnit 8 and removed in PHPUnit 9. While WordPress test suite currently only supports PHPUnit up to 7.5.x, this allows us to switch to newer assertions ahead of adding full support for PHPUnit 8+. These methods introduced in PHPUnit 7.5 should be used as an alternative: * `assertStringContainsString()` * `assertStringContainsStringIgnoringCase` * `assertStringNotContainsString()` * `assertStringNotContainsStringIgnoringCase` As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods were added to the `WP_UnitTestCase` class for PHPUnit < 7.5. Follow-up to [51331], [51451], [51461]. Props jrf, dd32, SergeyBiryukov. See #53363, #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51462 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -93,7 +93,7 @@ class Tests_Theme_CustomHeader extends WP_UnitTestCase {
|
||||
|
||||
$html = get_header_image_tag();
|
||||
$this->assertStringStartsWith( '<img ', $html );
|
||||
$this->assertContains( sprintf( 'src="%s"', $default ), $html );
|
||||
$this->assertStringContainsString( sprintf( 'src="%s"', $default ), $html );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ class Tests_Theme_CustomHeader extends WP_UnitTestCase {
|
||||
set_theme_mod( 'header_image', $custom );
|
||||
$html = get_header_image_tag();
|
||||
$this->assertStringStartsWith( '<img ', $html );
|
||||
$this->assertContains( sprintf( 'src="%s"', $custom ), $html );
|
||||
$this->assertStringContainsString( sprintf( 'src="%s"', $custom ), $html );
|
||||
}
|
||||
|
||||
function test_get_custom_header_markup_without_registered_default_image() {
|
||||
@@ -138,7 +138,7 @@ class Tests_Theme_CustomHeader extends WP_UnitTestCase {
|
||||
$html = get_custom_header_markup();
|
||||
$this->assertTrue( has_custom_header() );
|
||||
$this->assertStringStartsWith( '<div id="wp-custom-header" class="wp-custom-header">', $html );
|
||||
$this->assertContains( sprintf( 'src="%s"', $default ), $html );
|
||||
$this->assertStringContainsString( sprintf( 'src="%s"', $default ), $html );
|
||||
}
|
||||
|
||||
function test_get_header_video_url() {
|
||||
|
||||
Reference in New Issue
Block a user