| | 20 | /** |
| | 21 | * @group 37966 |
| | 22 | */ |
| | 23 | public function test_children_present() { |
| | 24 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); |
| | 25 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c1 ) ); |
| | 26 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); |
| | 27 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_parent' => $c3 ) ); |
| | 28 | |
| | 29 | $q = new WP_Comment_Query(); |
| | 30 | $found = $q->query( array( |
| | 31 | 'orderby' => 'comment_date_gmt', |
| | 32 | 'order' => 'ASC', |
| | 33 | 'status' => 'approve', |
| | 34 | 'post_id' => self::$post_id, |
| | 35 | 'no_found_rows' => false, |
| | 36 | 'hierarchical' => 'threaded', |
| | 37 | 'number' => 1, |
| | 38 | 'offset' => 1, |
| | 39 | ) ); |
| | 40 | |
| | 41 | $this->assertNotEmpty( $found ); |
| | 42 | |
| | 43 | $comment = array_shift( $found ); |
| | 44 | |
| | 45 | $this->assertNotEmpty( $comment->get_children() ); |
| | 46 | |
| | 47 | } |
| | 48 | |
| 20 | 49 | public function test_query() { |
| 21 | 50 | $c1 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1' ) ); |
| 22 | 51 | $c2 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 23 | 52 | $c3 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 24 | 53 | $c4 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 25 | 54 | $c5 = self::factory()->comment->create( array( 'comment_post_ID' => self::$post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 26 | 55 | |
| 27 | 56 | $q = new WP_Comment_Query(); |
| 28 | 57 | $found = $q->query( array( |
| 29 | 58 | 'fields' => 'ids', |
| 30 | 59 | ) ); |
| 31 | 60 | |
| 32 | 61 | $this->assertEqualSets( array( $c1, $c2, $c3, $c4, $c5 ), $found ); |
| 33 | 62 | } |
| 34 | 63 | |