Skip to content
Draft
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
65 changes: 58 additions & 7 deletions tests/phpunit/tests/comment/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ public function test_query_type_empty_string() {
'comment_type' => 'luigi',
)
);
$c6 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_type' => 'block_comment',
)
);

$q = new WP_Comment_Query();
$found = $q->query(
Expand All @@ -149,7 +156,8 @@ public function test_query_type_empty_string() {
)
);

$this->assertSameSets( array( $c1, $c2, $c3, $c4, $c5 ), $found );
$this->assertSameSets( array( $c1, $c2, $c3, $c4, $c5 ), $found, 'Empty string should return all public comments.' );
$this->assertNotContains( $c6, $found, 'Empty string should not return block comments.' );
}

/**
Expand Down Expand Up @@ -192,6 +200,13 @@ public function test_query_type_comment() {
'comment_type' => 'luigi',
)
);
$c6 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_type' => 'block_comment',
)
);

$q = new WP_Comment_Query();
$found = $q->query(
Expand All @@ -201,7 +216,7 @@ public function test_query_type_comment() {
)
);

$this->assertSameSets( array( $c1 ), $found );
$this->assertSameSets( array( $c1 ), $found, 'Comment type should return only regular comments.' );
}

/**
Expand Down Expand Up @@ -235,6 +250,13 @@ public function test_query_type_pingback() {
'comment_type' => 'trackback',
)
);
$c5 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_type' => 'block_comment',
)
);

$q = new WP_Comment_Query();
$found = $q->query(
Expand All @@ -244,7 +266,7 @@ public function test_query_type_pingback() {
)
);

$this->assertSameSets( array( $c2, $c3 ), $found );
$this->assertSameSets( array( $c2, $c3 ), $found, 'Pingback type should return only pingbacks.' );
}

/**
Expand Down Expand Up @@ -278,6 +300,13 @@ public function test_query_type_trackback() {
'comment_type' => 'pingback',
)
);
$c5 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_type' => 'block_comment',
)
);

$q = new WP_Comment_Query();
$found = $q->query(
Expand All @@ -287,7 +316,7 @@ public function test_query_type_trackback() {
)
);

$this->assertSameSets( array( $c2, $c3 ), $found );
$this->assertSameSets( array( $c2, $c3 ), $found, 'Trackback type should return only trackbacks.' );
}

/**
Expand Down Expand Up @@ -330,6 +359,13 @@ public function test_query_type_pings() {
'comment_type' => 'luigi',
)
);
$c6 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_type' => 'block_comment',
)
);

$q = new WP_Comment_Query();
$found = $q->query(
Expand All @@ -339,7 +375,7 @@ public function test_query_type_pings() {
)
);

$this->assertSameSets( array( $c2, $c3 ), $found );
$this->assertSameSets( array( $c2, $c3 ), $found, 'Pings type should return only trackbacks and pingbacks.' );
}

/**
Expand Down Expand Up @@ -391,6 +427,13 @@ public function test_type_array_comments_and_custom() {
'comment_type' => 'mario',
)
);
$c7 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_type' => 'block_comment',
)
);

$q = new WP_Comment_Query();
$found = $q->query(
Expand All @@ -400,7 +443,7 @@ public function test_type_array_comments_and_custom() {
)
);

$this->assertSameSets( array( $c1, $c4, $c6 ), $found );
$this->assertSameSets( array( $c1, $c4, $c6 ), $found, 'Comments + custom type should return regular comments and custom type.' );
}

/**
Expand Down Expand Up @@ -450,6 +493,13 @@ public function test_type_not__in_array_custom() {
'comment_type' => 'mario',
)
);
$c7 = self::factory()->comment->create(
array(
'comment_post_ID' => self::$post_id,
'comment_approved' => '1',
'comment_type' => 'block_comment',
)
);

$q = new WP_Comment_Query();
$found = $q->query(
Expand All @@ -459,7 +509,8 @@ public function test_type_not__in_array_custom() {
)
);

$this->assertSameSets( array( $c1, $c2, $c3, $c4, $c6 ), $found );
$this->assertSameSets( array( $c1, $c2, $c3, $c4, $c6 ), $found, 'Not in luigi should return all but luigi.' );
$this->assertNotContains( $c7, $found, 'Not in luigi should not return block comments.' );
}

/**
Expand Down
Loading