mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-08 22:54:36 +00:00
Tests: Use more appropriate assertions in various tests.
This replaces instances of `assertFalse( stripos( ... ) )` with `assertStringNotContainsString()` or `assertStringNotContainsStringIgnoringCase()` to use native PHPUnit functionality. Going forward, these methods introduced in PHPUnit 7.5 should be used for similar assertions: * `assertStringContainsString()` * `assertStringContainsStringIgnoringCase()` * `assertStringNotContainsString()` * `assertStringNotContainsStringIgnoringCase()` As WordPress currently uses PHPUnit 5.7.x to run tests on PHP 5.6, polyfills for these methods are now added to the `WP_UnitTestCase` class for PHPUnit < 7.5. Follow-up to [51335], [51337], [51367], [51397], [51403], [51404], [51436], [51438], [51448], [51449], [51451], [51453], [51454]. See #53363. git-svn-id: https://develop.svn.wordpress.org/trunk@51461 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -821,7 +821,7 @@ class WP_Test_REST_Comments_Controller extends WP_Test_REST_Controller_Testcase
|
||||
),
|
||||
rest_url( '/wp/v2/comments' )
|
||||
);
|
||||
$this->assertFalse( stripos( $headers['Link'], 'rel="prev"' ) );
|
||||
$this->assertStringNotContainsString( 'rel="prev"', $headers['Link'] );
|
||||
$this->assertContains( '<' . $next_link . '>; rel="next"', $headers['Link'] );
|
||||
|
||||
// 3rd page.
|
||||
@@ -867,7 +867,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->assertFalse( stripos( $headers['Link'], 'rel="next"' ) );
|
||||
$this->assertStringNotContainsString( 'rel="next"', $headers['Link'] );
|
||||
|
||||
// Out of bounds.
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/comments' );
|
||||
@@ -883,7 +883,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->assertFalse( stripos( $headers['Link'], 'rel="next"' ) );
|
||||
$this->assertStringNotContainsString( 'rel="next"', $headers['Link'] );
|
||||
}
|
||||
|
||||
public function test_get_comments_invalid_date() {
|
||||
|
||||
Reference in New Issue
Block a user