mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Tests: Use assertSame() in wp_insert_post() tests.
This ensures that not only the return values match the expected results, but also that their type is the same. Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable. Follow-up to [34085], [35183], [48937], [53782], [53785], [53883], [54402]. Props costdev. See #59655. git-svn-id: https://develop.svn.wordpress.org/trunk@57680 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
05456bf555
commit
3a196ba354
@ -128,7 +128,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
$this->assertSame( $data['post_content'], $post->post_content );
|
||||
$this->assertSame( $data['post_title'], $post->post_title );
|
||||
$this->assertSame( $data['post_status'], $post->post_status );
|
||||
$this->assertEquals( $data['post_author'], $post->post_author );
|
||||
$this->assertSame( (string) $data['post_author'], $post->post_author );
|
||||
|
||||
// Test cache state.
|
||||
$post_cache = wp_cache_get( $post_id, 'posts' );
|
||||
@ -675,7 +675,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
$this->assertGreaterThan( 0, $post_id );
|
||||
|
||||
$post = get_post( $post_id );
|
||||
$this->assertEquals( self::$user_ids['editor'], $post->post_author );
|
||||
$this->assertSame( (string) self::$user_ids['editor'], $post->post_author );
|
||||
$this->assertSame( $title, $post->post_title );
|
||||
}
|
||||
|
||||
@ -787,7 +787,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
public function test_wp_insert_post_author_zero() {
|
||||
$post_id = self::factory()->post->create( array( 'post_author' => 0 ) );
|
||||
|
||||
$this->assertEquals( 0, get_post( $post_id )->post_author );
|
||||
$this->assertSame( '0', get_post( $post_id )->post_author );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -798,7 +798,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
|
||||
$post_id = self::factory()->post->create( array( 'post_author' => null ) );
|
||||
|
||||
$this->assertEquals( self::$user_ids['editor'], get_post( $post_id )->post_author );
|
||||
$this->assertSame( (string) self::$user_ids['editor'], get_post( $post_id )->post_author );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -916,7 +916,7 @@ class Tests_Post_wpInsertPost extends WP_UnitTestCase {
|
||||
|
||||
// Validate that the post has had the default category assigned again.
|
||||
$this->assertCount( 1, $assigned_terms );
|
||||
$this->assertEquals( get_option( 'default_category' ), $assigned_terms[0]->term_id );
|
||||
$this->assertSame( (int) get_option( 'default_category' ), $assigned_terms[0]->term_id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user