| 201 | |
| 202 | /** |
| 203 | * @ticket |
| 204 | */ |
| 205 | function test_fields_comment_id__in() { |
| 206 | $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 207 | $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 208 | $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 209 | |
| 210 | $comment_ids = get_comments( array( |
| 211 | 'fields' => 'ids', |
| 212 | 'comment_id__in' => array( $comment_1, $comment_3 ), |
| 213 | ) ); |
| 214 | |
| 215 | $this->assertEqualSets( array( $comment_1, $comment_3 ), $comment_ids ); |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * @ticket |
| 220 | */ |
| 221 | function test_fields_comment_id__not_in() { |
| 222 | $comment_1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 223 | $comment_2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 224 | $comment_3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 225 | |
| 226 | $comment_ids = get_comments( array( |
| 227 | 'fields' => 'ids', |
| 228 | 'comment_id__not_in' => array( $comment_2, $comment_3 ), |
| 229 | ) ); |
| 230 | |
| 231 | $this->assertEqualSets( array( $comment_1 ), $comment_ids ); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * @ticket |
| 236 | */ |
| 237 | function test_fields_post_id__in() { |
| 238 | $p1 = $this->factory->post->create(); |
| 239 | $p2 = $this->factory->post->create(); |
| 240 | $p3 = $this->factory->post->create(); |
| 241 | |
| 242 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 243 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 244 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 245 | |
| 246 | $comment_ids = get_comments( array( |
| 247 | 'fields' => 'ids', |
| 248 | 'post_id__in' => array( $p1, $p2 ), |
| 249 | ) ); |
| 250 | |
| 251 | $this->assertEqualSets( array( $c1, $c2 ), $comment_ids ); |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * @ticket |
| 256 | */ |
| 257 | function test_fields_post_id__not_in() { |
| 258 | $p1 = $this->factory->post->create(); |
| 259 | $p2 = $this->factory->post->create(); |
| 260 | $p3 = $this->factory->post->create(); |
| 261 | |
| 262 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 7, 'comment_approved' => '1' ) ); |
| 263 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 264 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| 265 | |
| 266 | $comment_ids = get_comments( array( |
| 267 | 'fields' => 'ids', |
| 268 | 'post_id__not_in' => array( $p1, $p2 ), |
| 269 | ) ); |
| 270 | |
| 271 | $this->assertEqualSets( array( $c3 ), $comment_ids ); |
| 272 | } |