Changeset 34569 for trunk/tests/phpunit/tests/comment/query.php
- Timestamp:
- 09/26/2015 02:24:17 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/comment/query.php
r34550 r34569 2024 2024 ) ); 2025 2025 2026 $q = new WP_Comment_Query( array( 2027 'post_id' => $this->post_id, 2026 $args = array( 2028 2027 'hierarchical' => 'threaded', 2029 2028 'orderby' => 'comment_ID', 2030 2029 'order' => 'ASC', 2031 ) ); 2030 ); 2031 2032 $query_args = array_merge( $args, array( 2033 'post_id' => $this->post_id, 2034 ) ); 2035 2036 $q = new WP_Comment_Query( $query_args ); 2032 2037 2033 2038 // Top-level comments. … … 2035 2040 2036 2041 // Direct descendants of $c1. 2037 $this->assertEqualSets( array( $c2, $c4 ), array_values( wp_list_pluck( $q->comments[ $c1 ]->get_children( ), 'comment_ID' ) ) );2042 $this->assertEqualSets( array( $c2, $c4 ), array_values( wp_list_pluck( $q->comments[ $c1 ]->get_children( $args ), 'comment_ID' ) ) ); 2038 2043 2039 2044 // Direct descendants of $c2. 2040 $this->assertEqualSets( array( $c3 ), array_values( wp_list_pluck( $q->comments[ $c1 ]->get_child( $c2 )->get_children( ), 'comment_ID' ) ) );2045 $this->assertEqualSets( array( $c3 ), array_values( wp_list_pluck( $q->comments[ $c1 ]->get_child( $c2 )->get_children( $args ), 'comment_ID' ) ) ); 2041 2046 2042 2047 // Direct descendants of $c5. 2043 $this->assertEqualSets( array( $c6 ), array_values( wp_list_pluck( $q->comments[ $c5 ]->get_children(), 'comment_ID' ) ) ); 2048 $this->assertEqualSets( array( $c6 ), array_values( wp_list_pluck( $q->comments[ $c5 ]->get_children( $args ), 'comment_ID' ) ) ); 2049 } 2050 2051 /** 2052 * @ticket 8071 2053 */ 2054 public function test_hierarchical_threaded_approved() { 2055 $c1 = $this->factory->comment->create( array( 2056 'comment_post_ID' => $this->post_id, 2057 'comment_approved' => '1', 2058 ) ); 2059 2060 $c2 = $this->factory->comment->create( array( 2061 'comment_post_ID' => $this->post_id, 2062 'comment_approved' => '1', 2063 'comment_parent' => $c1, 2064 ) ); 2065 2066 $c3 = $this->factory->comment->create( array( 2067 'comment_post_ID' => $this->post_id, 2068 'comment_approved' => '0', 2069 'comment_parent' => $c2, 2070 ) ); 2071 2072 $c4 = $this->factory->comment->create( array( 2073 'comment_post_ID' => $this->post_id, 2074 'comment_approved' => '1', 2075 'comment_parent' => $c1, 2076 ) ); 2077 2078 $c5 = $this->factory->comment->create( array( 2079 'comment_post_ID' => $this->post_id, 2080 'comment_approved' => '1', 2081 ) ); 2082 2083 $this->factory->comment->create( array( 2084 'comment_post_ID' => $this->post_id, 2085 'comment_approved' => '1', 2086 'comment_parent' => $c5, 2087 ) ); 2088 2089 $args = array( 2090 'hierarchical' => 'threaded', 2091 'status' => 'approve', 2092 'orderby' => 'comment_ID', 2093 'order' => 'ASC', 2094 ); 2095 2096 $query_args = array_merge( $args, array( 2097 'post_id' => $this->post_id, 2098 ) ); 2099 2100 $q = new WP_Comment_Query( $query_args ); 2101 2102 // Top-level comments. 2103 $this->assertEqualSets( array( $c1, $c5 ), array_values( wp_list_pluck( $q->comments, 'comment_ID' ) ) ); 2104 2105 // Direct descendants of $c1. 2106 $this->assertEqualSets( array( $c2, $c4 ), array_values( wp_list_pluck( $q->comments[ $c1 ]->get_children( $args ), 'comment_ID' ) ) ); 2107 2108 // Direct descendants of $c2. 2109 $this->assertEqualSets( array(), array_values( wp_list_pluck( $q->comments[ $c1 ]->get_child( $c2 )->get_children( $args ), 'comment_ID' ) ) ); 2044 2110 } 2045 2111 }
Note: See TracChangeset
for help on using the changeset viewer.