| | 273 | |
| | 274 | /** |
| | 275 | * @ticket 29885 |
| | 276 | */ |
| | 277 | function test_fields_post_author__in() { |
| | 278 | $author_id1 = 105; |
| | 279 | $author_id2 = 106; |
| | 280 | |
| | 281 | $p1 = $this->factory->post->create( array( 'post_author' => $author_id1 ) ); |
| | 282 | $p2 = $this->factory->post->create( array( 'post_author' => $author_id1 ) ); |
| | 283 | $p3 = $this->factory->post->create( array( 'post_author' => $author_id2 ) ); |
| | 284 | |
| | 285 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| | 286 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| | 287 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| | 288 | |
| | 289 | $comment_ids = get_comments( array( |
| | 290 | 'fields' => 'ids', |
| | 291 | 'post_author__in' => array( $author_id1 ), |
| | 292 | ) ); |
| | 293 | |
| | 294 | $this->assertCount( 2, $comment_ids ); |
| | 295 | } |
| | 296 | |
| | 297 | /** |
| | 298 | * @ticket 29885 |
| | 299 | */ |
| | 300 | function test_fields_post_author__not_in() { |
| | 301 | $author_id1 = 111; |
| | 302 | $author_id2 = 112; |
| | 303 | |
| | 304 | $p1 = $this->factory->post->create( array( 'post_author' => $author_id1 ) ); |
| | 305 | $p2 = $this->factory->post->create( array( 'post_author' => $author_id1 ) ); |
| | 306 | $p3 = $this->factory->post->create( array( 'post_author' => $author_id2 ) ); |
| | 307 | |
| | 308 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $p1, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| | 309 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $p2, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| | 310 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $p3, 'user_id' => 1, 'comment_approved' => '1' ) ); |
| | 311 | |
| | 312 | $comment_ids = get_comments( array( |
| | 313 | 'fields' => 'ids', |
| | 314 | 'post_author__not_in' => array( $author_id1 ), |
| | 315 | ) ); |
| | 316 | |
| | 317 | $this->assertCount( 1, $comment_ids ); |
| | 318 | } |