mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +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:
@@ -28,7 +28,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
$term = (int) $t1;
|
||||
|
||||
$actual = get_term_link( $term, 'wptests_tax' );
|
||||
$this->assertContains( 'wptests_tax=foo', $actual );
|
||||
$this->assertStringContainsString( 'wptests_tax=foo', $actual );
|
||||
}
|
||||
|
||||
public function test_numeric_string_should_be_interpreted_as_term_slug() {
|
||||
@@ -48,7 +48,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
$term = (string) $t1;
|
||||
|
||||
$actual = get_term_link( $term, 'wptests_tax' );
|
||||
$this->assertContains( 'wptests_tax=' . $term, $actual );
|
||||
$this->assertStringContainsString( 'wptests_tax=' . $term, $actual );
|
||||
}
|
||||
|
||||
public function test_invalid_term_should_return_wp_error() {
|
||||
@@ -60,7 +60,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
$c = self::factory()->category->create();
|
||||
|
||||
$actual = get_term_link( $c, 'category' );
|
||||
$this->assertContains( 'cat=' . $c, $actual );
|
||||
$this->assertStringContainsString( 'cat=' . $c, $actual );
|
||||
}
|
||||
|
||||
public function test_taxonomy_with_query_var_should_use_that_query_var_with_term_slug() {
|
||||
@@ -80,7 +80,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$actual = get_term_link( $t, 'wptests_tax2' );
|
||||
$this->assertContains( 'foo=bar', $actual );
|
||||
$this->assertStringContainsString( 'foo=bar', $actual );
|
||||
}
|
||||
|
||||
public function test_taxonomy_without_query_var_should_use_taxonomy_query_var_and_term_query_var_with_term_slug() {
|
||||
@@ -100,8 +100,8 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
);
|
||||
|
||||
$actual = get_term_link( $t, 'wptests_tax2' );
|
||||
$this->assertContains( 'taxonomy=wptests_tax2', $actual );
|
||||
$this->assertContains( 'term=bar', $actual );
|
||||
$this->assertStringContainsString( 'taxonomy=wptests_tax2', $actual );
|
||||
$this->assertStringContainsString( 'term=bar', $actual );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +131,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
|
||||
remove_permastruct( 'wptests_tax2' );
|
||||
|
||||
$this->assertContains( '/foo/bar/', $actual );
|
||||
$this->assertStringContainsString( '/foo/bar/', $actual );
|
||||
}
|
||||
|
||||
public function test_taxonomy_permastruct_with_hierarchical_rewrite_should_put_term_ancestors_in_link() {
|
||||
@@ -168,7 +168,7 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
|
||||
$actual = get_term_link( $t2, 'wptests_tax2' );
|
||||
|
||||
$this->assertContains( '/foo/term1/term2/', $actual );
|
||||
$this->assertStringContainsString( '/foo/term1/term2/', $actual );
|
||||
}
|
||||
|
||||
public function test_taxonomy_permastruct_with_nonhierarchical_rewrite_should_not_put_term_ancestors_in_link() {
|
||||
@@ -205,6 +205,6 @@ class Tests_Term_GetTermLink extends WP_UnitTestCase {
|
||||
|
||||
$actual = get_term_link( $t2, 'wptests_tax2' );
|
||||
|
||||
$this->assertContains( '/foo/term2/', $actual );
|
||||
$this->assertStringContainsString( '/foo/term2/', $actual );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user