Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/phpunit/tests/comment/commentsTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/tests/comment/pingback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down
55 changes: 33 additions & 22 deletions tests/phpunit/tests/comment/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -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 );
}
}

Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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(
Expand All @@ -1483,24 +1483,24 @@ 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(
'meta_value' => 'value3',
'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(
'meta_value' => 'value3',
'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.
Expand Down Expand Up @@ -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(
Expand All @@ -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 );
}

/**
Expand Down Expand Up @@ -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' )
);
}

/**
Expand Down Expand Up @@ -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' )
);
}

/**
Expand Down Expand Up @@ -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() );
}

Expand Down
Loading