diff --git a/tests/phpunit/tests/comment/commentsTemplate.php b/tests/phpunit/tests/comment/commentsTemplate.php index bc260545ad93e..8ee623e8c828c 100644 --- a/tests/phpunit/tests/comment/commentsTemplate.php +++ b/tests/phpunit/tests/comment/commentsTemplate.php @@ -1045,7 +1045,7 @@ static function ( $args ) use ( $top_level_query_args ) { } $this->assertSame( $expected_ids, array_map( 'intval', $matches[1] ) ); - $this->assertEquals( $expected['offset'], $offset ); + $this->assertSame( $expected['offset'], $offset ); } public function data_comments_template_top_level_query_args() { diff --git a/tests/phpunit/tests/comment/pingback.php b/tests/phpunit/tests/comment/pingback.php index 769552ad7930b..a7eab58b0bc4f 100644 --- a/tests/phpunit/tests/comment/pingback.php +++ b/tests/phpunit/tests/comment/pingback.php @@ -41,7 +41,7 @@ public function test_pingback() { ); $post = get_post( self::$post_id ); - $this->assertEquals( array( 'http://example1.org/test' => false ), pingback( $post->post_content, self::$post_id ) ); + $this->assertSame( array( 'http://example1.org/test' => false ), pingback( $post->post_content, self::$post_id ) ); } public function test_pingback_no_ping_back() { @@ -65,7 +65,7 @@ public function test_pingback_no_ping_back() { ); $post = get_post( self::$post_id ); - $this->assertEquals( array(), pingback( $post->post_content, self::$post_id ) ); + $this->assertSame( array(), pingback( $post->post_content, self::$post_id ) ); } public function test_pingback_error_response() { @@ -82,7 +82,7 @@ public function test_pingback_error_response() { ); $post = get_post( self::$post_id ); - $this->assertEquals( array(), pingback( $post->post_content, self::$post_id ) ); + $this->assertSame( array(), pingback( $post->post_content, self::$post_id ) ); } public function request_response() { diff --git a/tests/phpunit/tests/comment/query.php b/tests/phpunit/tests/comment/query.php index 9d2722cf4e4cc..68bb475caa298 100644 --- a/tests/phpunit/tests/comment/query.php +++ b/tests/phpunit/tests/comment/query.php @@ -1379,7 +1379,7 @@ public function test_get_comments_for_post() { $comments = get_comments( array( 'post_id' => $post_id ) ); $this->assertCount( $limit, $comments ); foreach ( $comments as $comment ) { - $this->assertEquals( $post_id, $comment->comment_post_ID ); + $this->assertSame( (string) $post_id, $comment->comment_post_ID ); } $post_id2 = self::factory()->post->create(); @@ -1388,7 +1388,7 @@ public function test_get_comments_for_post() { $comments = get_comments( array( 'post_id' => $post_id2 ) ); $this->assertCount( $limit, $comments ); foreach ( $comments as $comment ) { - $this->assertEquals( $post_id2, $comment->comment_post_ID ); + $this->assertSame( (string) $post_id2, $comment->comment_post_ID ); } $post_id3 = self::factory()->post->create(); @@ -1397,7 +1397,7 @@ public function test_get_comments_for_post() { $comments = get_comments( array( 'post_id' => $post_id3 ) ); $this->assertCount( $limit, $comments ); foreach ( $comments as $comment ) { - $this->assertEquals( $post_id3, $comment->comment_post_ID ); + $this->assertSame( (string) $post_id3, $comment->comment_post_ID ); } $comments = get_comments( @@ -1408,7 +1408,7 @@ public function test_get_comments_for_post() { ); $this->assertCount( $limit, $comments ); foreach ( $comments as $comment ) { - $this->assertEquals( $post_id3, $comment->comment_post_ID ); + $this->assertSame( (string) $post_id3, $comment->comment_post_ID ); } $comments = get_comments( @@ -1423,7 +1423,7 @@ public function test_get_comments_for_post() { $comments = get_comments( array( 'post_id' => $post_id3 ) ); $this->assertCount( $limit * 2, $comments ); foreach ( $comments as $comment ) { - $this->assertEquals( $post_id3, $comment->comment_post_ID ); + $this->assertSame( (string) $post_id3, $comment->comment_post_ID ); } } @@ -1451,8 +1451,8 @@ public function test_orderby_meta() { ) ); $this->assertCount( 2, $comments ); - $this->assertEquals( $comment_id2, $comments[0]->comment_ID ); - $this->assertEquals( $comment_id, $comments[1]->comment_ID ); + $this->assertSame( (string) $comment_id2, $comments[0]->comment_ID ); + $this->assertSame( (string) $comment_id, $comments[1]->comment_ID ); $comments = get_comments( array( @@ -1461,8 +1461,8 @@ public function test_orderby_meta() { ) ); $this->assertCount( 2, $comments ); - $this->assertEquals( $comment_id2, $comments[0]->comment_ID ); - $this->assertEquals( $comment_id, $comments[1]->comment_ID ); + $this->assertSame( (string) $comment_id2, $comments[0]->comment_ID ); + $this->assertSame( (string) $comment_id, $comments[1]->comment_ID ); $comments = get_comments( array( @@ -1472,8 +1472,8 @@ public function test_orderby_meta() { ) ); $this->assertCount( 2, $comments ); - $this->assertEquals( $comment_id, $comments[0]->comment_ID ); - $this->assertEquals( $comment_id2, $comments[1]->comment_ID ); + $this->assertSame( (string) $comment_id, $comments[0]->comment_ID ); + $this->assertSame( (string) $comment_id2, $comments[1]->comment_ID ); $comments = get_comments( array( @@ -1483,8 +1483,8 @@ public function test_orderby_meta() { ) ); $this->assertCount( 2, $comments ); - $this->assertEquals( $comment_id, $comments[0]->comment_ID ); - $this->assertEquals( $comment_id2, $comments[1]->comment_ID ); + $this->assertSame( (string) $comment_id, $comments[0]->comment_ID ); + $this->assertSame( (string) $comment_id2, $comments[1]->comment_ID ); $comments = get_comments( array( @@ -1492,7 +1492,7 @@ public function test_orderby_meta() { 'orderby' => array( 'key' ), ) ); - $this->assertEquals( array( $comment_id3, $comment_id ), wp_list_pluck( $comments, 'comment_ID' ) ); + $this->assertSame( array( (string) $comment_id3, (string) $comment_id ), wp_list_pluck( $comments, 'comment_ID' ) ); $comments = get_comments( array( @@ -1500,7 +1500,7 @@ public function test_orderby_meta() { 'orderby' => array( 'meta_value' ), ) ); - $this->assertEquals( array( $comment_id3, $comment_id ), wp_list_pluck( $comments, 'comment_ID' ) ); + $this->assertSame( array( (string) $comment_id3, (string) $comment_id ), wp_list_pluck( $comments, 'comment_ID' ) ); // 'value1' is present on two different keys for $comment_id, // yet we should get only one instance of that comment in the results. @@ -1731,8 +1731,8 @@ public function test_get_comments_by_user() { ); $this->assertCount( 2, $comments ); - $this->assertEquals( $users[0], $comments[0]->user_id ); - $this->assertEquals( $users[0], $comments[1]->user_id ); + $this->assertSame( (string) $users[0], $comments[0]->user_id ); + $this->assertSame( (string) $users[0], $comments[1]->user_id ); $comments = get_comments( array( @@ -1743,9 +1743,9 @@ public function test_get_comments_by_user() { ); $this->assertCount( 3, $comments ); - $this->assertEquals( $users[0], $comments[0]->user_id ); - $this->assertEquals( $users[0], $comments[1]->user_id ); - $this->assertEquals( $users[1], $comments[2]->user_id ); + $this->assertSame( (string) $users[0], $comments[0]->user_id ); + $this->assertSame( (string) $users[0], $comments[1]->user_id ); + $this->assertSame( (string) $users[1], $comments[2]->user_id ); } /** @@ -3019,7 +3019,10 @@ public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_cas ); // $comments is ASC by default. - $this->assertEquals( $comments, wp_list_pluck( $found, 'comment_ID' ) ); + $this->assertSame( + array_map( 'strval', $comments ), + wp_list_pluck( $found, 'comment_ID' ) + ); } /** @@ -3048,7 +3051,10 @@ public function test_orderby_date_modified_gmt_should_order_by_comment_ID_in_cas // $comments is ASC by default. rsort( $comments ); - $this->assertEquals( $comments, wp_list_pluck( $found, 'comment_ID' ) ); + $this->assertSame( + array_map( 'strval', $comments ), + wp_list_pluck( $found, 'comment_ID' ) + ); } /** @@ -3578,6 +3584,11 @@ public function test_comment_query_object() { $query2 = new WP_Comment_Query( array( 'status' => 'all' ) ); $this->assertNotEmpty( $query2->query_vars ); $this->assertNotEmpty( $query2->comments ); + + /* + * Keep assertEquals() because the different objects instances + * in the array are compared by value. + */ $this->assertEquals( $query2->comments, $query1->get_comments() ); }