| 19 | * Comments query |
| 20 | * @ticket 12668 |
| 21 | */ |
| 22 | public function test_query() { |
| 23 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 24 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 25 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 26 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 27 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 28 | |
| 29 | $q = new WP_Comment_Query(); |
| 30 | $found = $q->query( array( |
| 31 | 'fields' => 'ids', |
| 32 | ) ); |
| 33 | |
| 34 | $this->assertEquals( array( $c1, $c2, $c3, $c4, $c5 ), $found ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Query comments with blank |
| 39 | * @ticket 12668 |
| 40 | */ |
| 41 | public function test_query_for___type() { |
| 42 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 43 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 44 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 45 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 46 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 47 | |
| 48 | $q = new WP_Comment_Query(); |
| 49 | $found = $q->query( array( |
| 50 | 'type' => '', |
| 51 | 'fields' => 'ids', |
| 52 | ) ); |
| 53 | |
| 54 | $this->assertEquals( array( $c1, $c2, $c3, $c4, $c5 ), $found ); |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * Query comments with 'comments' |
| 59 | * @ticket 12668 |
| 60 | */ |
| 61 | public function test_query_for_comment_type() { |
| 62 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 63 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 64 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 65 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 66 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 67 | |
| 68 | $q = new WP_Comment_Query(); |
| 69 | $found = $q->query( array( |
| 70 | 'type' => 'comment', |
| 71 | 'fields' => 'ids', |
| 72 | ) ); |
| 73 | |
| 74 | $this->assertEquals( array( $c1 ), $found ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Query pingback via string |
| 79 | * @ticket 12668 |
| 80 | */ |
| 81 | public function test_query_for_pingback_type() { |
| 82 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 83 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 84 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 85 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 86 | |
| 87 | $q = new WP_Comment_Query(); |
| 88 | $found = $q->query( array( |
| 89 | 'type' => 'pingback', |
| 90 | 'fields' => 'ids', |
| 91 | ) ); |
| 92 | |
| 93 | $this->assertEquals( array( $c2, $c3 ), $found ); |
| 94 | |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Query trackback via string |
| 99 | * @ticket 12668 |
| 100 | */ |
| 101 | public function test_query_for_trackback_type() { |
| 102 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 103 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 104 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 105 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 106 | |
| 107 | $q = new WP_Comment_Query(); |
| 108 | $found = $q->query( array( |
| 109 | 'type' => 'trackback', |
| 110 | 'fields' => 'ids', |
| 111 | ) ); |
| 112 | |
| 113 | $this->assertEquals( array( $c2, $c3 ), $found ); |
| 114 | |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Comments and Pings |
| 119 | * @ticket 12668 |
| 120 | */ |
| 121 | public function test_query_for_pings() { |
| 122 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 123 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 124 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 125 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 126 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 127 | |
| 128 | $q = new WP_Comment_Query(); |
| 129 | $found = $q->query( array( |
| 130 | 'type' => 'pings', |
| 131 | 'fields' => 'ids', |
| 132 | ) ); |
| 133 | |
| 134 | $this->assertEquals( array( $c2, $c3 ), $found ); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Comments query |
| 139 | * @ticket 12668 |
| 140 | */ |
| 141 | public function test_get_approved_comments() { |
| 142 | $ca1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 143 | $ca2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 144 | $ca3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0' ) ); |
| 145 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 146 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 147 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 148 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 149 | |
| 150 | $q = get_approved_comments( $this->post_id ); |
| 151 | $found = array(); |
| 152 | foreach ( $q as $key => $c ) { |
| 153 | $found[] = (int) $c->comment_ID; |
| 154 | } |
| 155 | // all comments types will be returned |
| 156 | $this->assertEquals( array( $ca1, $ca2, $c2, $c3, $c4, $c5 ), $found ); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Comments and custom |
| 161 | * @ticket 12668 |
| 162 | */ |
| 163 | public function test_type_array_comments_and_custom() { |
| 164 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 165 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 166 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 167 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 168 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 169 | $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 170 | |
| 171 | $q = new WP_Comment_Query(); |
| 172 | $found = $q->query( array( |
| 173 | 'type' => array( 'comments', 'mario' ), |
| 174 | 'fields' => 'ids', |
| 175 | ) ); |
| 176 | |
| 177 | $this->assertEquals( array( $c1, $c4, $c6 ), $found ); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Comments and custom |
| 182 | * @ticket 12668 |
| 183 | */ |
| 184 | public function test__not_type_array_custom() { |
| 185 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 186 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 187 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 188 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 189 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 190 | $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 191 | |
| 192 | $q = new WP_Comment_Query(); |
| 193 | $found = $q->query( array( |
| 194 | 'type__not_in' => array( 'luigi' ), |
| 195 | 'fields' => 'ids', |
| 196 | ) ); |
| 197 | |
| 198 | $this->assertEquals( array( $c1, $c2, $c3, $c4, $c6 ), $found ); |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * Comments and custom |
| 203 | * @ticket 12668 |
| 204 | */ |
| 205 | public function test_type__in_array_and_not_type_array_custom() { |
| 206 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 207 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 208 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 209 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 210 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 211 | $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 212 | |
| 213 | $q = new WP_Comment_Query(); |
| 214 | $found = $q->query( array( |
| 215 | 'type__in' => array( 'comments' ), |
| 216 | 'type__not_in' => array( 'luigi' ), |
| 217 | 'fields' => 'ids', |
| 218 | ) ); |
| 219 | |
| 220 | $this->assertEquals( array( $c1 ), $found ); |
| 221 | } |
| 222 | |
| 223 | /** |
| 224 | * Comments and custom |
| 225 | * @ticket 12668 |
| 226 | */ |
| 227 | public function test_type_array_and_not_type_array_custom() { |
| 228 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 229 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 230 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 231 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 232 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 233 | $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 234 | |
| 235 | $q = new WP_Comment_Query(); |
| 236 | $found = $q->query( array( |
| 237 | 'type' => array( 'pings' ), |
| 238 | 'type__not_in' => array( 'mario' ), |
| 239 | 'fields' => 'ids', |
| 240 | ) ); |
| 241 | |
| 242 | $this->assertEquals( array( $c2, $c3 ), $found ); |
| 243 | } |
| 244 | |
| 245 | /** |
| 246 | * Comments and custom |
| 247 | * @ticket 12668 |
| 248 | */ |
| 249 | public function test__not_type_custom() { |
| 250 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 251 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 252 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 253 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 254 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 255 | $c6 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 256 | |
| 257 | $q = new WP_Comment_Query(); |
| 258 | $found = $q->query( array( |
| 259 | 'type__not_in' => 'luigi', |
| 260 | 'fields' => 'ids', |
| 261 | ) ); |
| 262 | |
| 263 | $this->assertEquals( array( $c1, $c2, $c3, $c4, $c6 ), $found ); |
| 264 | } |
| 265 | |
| 266 | /** |
| 267 | * Comments and Pings |
| 268 | * @ticket 12668 |
| 269 | */ |
| 270 | public function test_type_array_comments_and_pings() { |
| 271 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 272 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 273 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 274 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'mario' ) ); |
| 275 | $c5 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'luigi' ) ); |
| 276 | |
| 277 | $q = new WP_Comment_Query(); |
| 278 | $found = $q->query( array( |
| 279 | 'type' => array( 'comments', 'pings' ), |
| 280 | 'fields' => 'ids', |
| 281 | ) ); |
| 282 | |
| 283 | $this->assertEquals( array( $c1, $c2, $c3 ), $found ); |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Comments and Pings |
| 288 | * @ticket 12668 |
| 289 | */ |
| 290 | public function test_type_array_comment_pings() { |
| 291 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 292 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 293 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 294 | |
| 295 | $q = new WP_Comment_Query(); |
| 296 | $found = $q->query( array( |
| 297 | 'type' => array( 'comment', 'pings' ), |
| 298 | 'fields' => 'ids', |
| 299 | ) ); |
| 300 | |
| 301 | $this->assertEquals( array( $c1, $c2, $c3 ), $found ); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Query pingback type |
| 306 | * @ticket 12668 |
| 307 | */ |
| 308 | public function test_type_array_pingback() { |
| 309 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 310 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 311 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 312 | |
| 313 | $q = new WP_Comment_Query(); |
| 314 | $found = $q->query( array( |
| 315 | 'type' => array( 'pingback' ), |
| 316 | 'fields' => 'ids', |
| 317 | ) ); |
| 318 | |
| 319 | $this->assertEquals( array( $c2 ), $found ); |
| 320 | } |
| 321 | |
| 322 | /** |
| 323 | * Query pingback type with a custom type thrown in |
| 324 | * @ticket 12668 |
| 325 | */ |
| 326 | public function test_type_array_custom_pingpack() { |
| 327 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 328 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 329 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 330 | |
| 331 | $q = new WP_Comment_Query(); |
| 332 | $found = $q->query( array( |
| 333 | 'type' => array( 'peach', 'pingback' ), |
| 334 | 'fields' => 'ids', |
| 335 | ) ); |
| 336 | |
| 337 | $this->assertEquals( array( $c2 ), $found ); |
| 338 | } |
| 339 | |
| 340 | /** |
| 341 | * Query pingback type via 'pings' |
| 342 | * @ticket 12668 |
| 343 | */ |
| 344 | public function test_type_array_pings() { |
| 345 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 346 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 347 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 348 | |
| 349 | $q = new WP_Comment_Query(); |
| 350 | $found = $q->query( array( |
| 351 | 'type' => array( 'pings' ), |
| 352 | 'fields' => 'ids', |
| 353 | ) ); |
| 354 | |
| 355 | $this->assertEquals( array( $c2, $c3 ), $found ); |
| 356 | } |
| 357 | |
| 358 | /** |
| 359 | * Query trackbacks and pingbacks |
| 360 | * @ticket 12668 |
| 361 | */ |
| 362 | public function test_type_status_approved_array_comment_pings() { |
| 363 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 364 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 365 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 366 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'pingback' ) ); |
| 367 | |
| 368 | $q = new WP_Comment_Query(); |
| 369 | $found = $q->query( array( |
| 370 | 'status' => 'approve', |
| 371 | 'type' => array( 'pings' ), |
| 372 | 'fields' => 'ids', |
| 373 | ) ); |
| 374 | |
| 375 | $this->assertEquals( array( $c3, $c2 ), $found ); |
| 376 | } |
| 377 | |
| 378 | /** |
| 379 | * Query trackback type |
| 380 | * @ticket 12668 |
| 381 | */ |
| 382 | public function test_type_array_trackback() { |
| 383 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 384 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 385 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 386 | |
| 387 | $q = new WP_Comment_Query(); |
| 388 | $found = $q->query( array( |
| 389 | 'type' => array( 'trackback' ), |
| 390 | 'fields' => 'ids', |
| 391 | ) ); |
| 392 | |
| 393 | $this->assertEquals( array( $c2 ), $found ); |
| 394 | } |
| 395 | |
| 396 | /** |
| 397 | * Query trackback type with a custom type thrown in |
| 398 | * @ticket 12668 |
| 399 | */ |
| 400 | public function test_type_array_custom_trackback() { |
| 401 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 402 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 403 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'pingback' ) ); |
| 404 | |
| 405 | $q = new WP_Comment_Query(); |
| 406 | $found = $q->query( array( |
| 407 | 'type' => array( 'toad', 'trackback' ), |
| 408 | 'fields' => 'ids', |
| 409 | ) ); |
| 410 | |
| 411 | $this->assertEquals( array( $c2 ), $found ); |
| 412 | } |
| 413 | |
| 414 | /** |
| 415 | * Query trackbacks and pingbacks |
| 416 | * @ticket 12668 |
| 417 | */ |
| 418 | public function test_type_array_pings_approved() { |
| 419 | $c1 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1' ) ); |
| 420 | $c2 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 421 | $c3 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '1', 'comment_type' => 'trackback' ) ); |
| 422 | $c4 = $this->factory->comment->create( array( 'comment_post_ID' => $this->post_id, 'comment_approved' => '0', 'comment_type' => 'trackback' ) ); |
| 423 | |
| 424 | $q = new WP_Comment_Query(); |
| 425 | $found = $q->query( array( |
| 426 | 'status' => 'approve', |
| 427 | 'type' => array( 'pings' ), |
| 428 | 'fields' => 'ids', |
| 429 | ) ); |
| 430 | |
| 431 | $this->assertEquals( array( $c3, $c2 ), $found ); |
| 432 | } |
| 433 | |
| 434 | |
| 435 | /** |