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:
@@ -822,7 +822,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
rest_url( '/wp/v2/comments' )
|
||||
);
|
||||
$this->assertStringNotContainsString( 'rel="prev"', $headers['Link'] );
|
||||
$this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] );
|
||||
$this->assertStringContainsString( '<' . $next_link . '>; rel="next"', $headers['Link'] );
|
||||
|
||||
// 3rd page.
|
||||
$this->factory->comment->create(
|
||||
@@ -844,14 +844,14 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
),
|
||||
rest_url( '/wp/v2/comments' )
|
||||
);
|
||||
$this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
|
||||
$this->assertStringContainsString( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
|
||||
$next_link = add_query_arg(
|
||||
array(
|
||||
'page' => 4,
|
||||
),
|
||||
rest_url( '/wp/v2/comments' )
|
||||
);
|
||||
$this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] );
|
||||
$this->assertStringContainsString( '<' . $next_link . '>; rel="next"', $headers['Link'] );
|
||||
|
||||
// Last page.
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
|
||||
@@ -866,7 +866,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
),
|
||||
rest_url( '/wp/v2/comments' )
|
||||
);
|
||||
$this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
|
||||
$this->assertStringContainsString( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
|
||||
$this->assertStringNotContainsString( 'rel="next"', $headers['Link'] );
|
||||
|
||||
// Out of bounds.
|
||||
@@ -882,7 +882,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
),
|
||||
rest_url( '/wp/v2/comments' )
|
||||
);
|
||||
$this->assertContains( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
|
||||
$this->assertStringContainsString( '<' . $prev_link . '>; rel="prev"', $headers['Link'] );
|
||||
$this->assertStringNotContainsString( 'rel="next"', $headers['Link'] );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user