| 395 | | // Remove the following lines when you implement this test. |
| 396 | | $this->markTestIncomplete( |
| 397 | | 'This test has not been implemented yet.' |
| 398 | | ); |
| | 394 | $f = $this->factory->forum->create(); |
| | 395 | |
| | 396 | $t = $this->factory->topic->create( array( |
| | 397 | 'post_parent' => $f, |
| | 398 | 'topic_meta' => array( |
| | 399 | 'forum_id' => $f, |
| | 400 | ), |
| | 401 | ) ); |
| | 402 | |
| | 403 | $r = $this->factory->reply->create_many( 5, array( |
| | 404 | 'post_parent' => $t, |
| | 405 | 'reply_meta' => array( |
| | 406 | 'forum_id' => $f, |
| | 407 | 'topic_id' => $t, |
| | 408 | ), |
| | 409 | ) ); |
| | 410 | |
| | 411 | add_filter( 'bbp_show_lead_topic', '__return_true' ); |
| | 412 | |
| | 413 | $position = get_post_field( 'menu_order', $r[3] ); |
| | 414 | $this->assertSame( 4, $position ); |
| | 415 | |
| | 416 | $position = bbp_get_reply_position( $r[3] ); |
| | 417 | $this->assertSame( 5, $position ); |
| | 418 | |
| | 419 | $position = bbp_get_reply_position_raw( $r[3] ); |
| | 420 | $this->assertSame( 4, $position ); |
| | 421 | |
| | 422 | // Manually switch a reply's 'menu_order' to 0 |
| | 423 | wp_update_post( array( |
| | 424 | 'ID' => $r[3], |
| | 425 | 'menu_order' => 0 |
| | 426 | ) ); |
| | 427 | |
| | 428 | $position = get_post_field( 'menu_order', $r[3] ); |
| | 429 | $this->assertSame( 0, $position ); |
| | 430 | |
| | 431 | $position = bbp_get_reply_position_raw( $r[3] ); |
| | 432 | $this->assertSame( 4, $position ); |
| | 433 | |
| | 434 | $position = bbp_get_reply_position( $r[3] ); |
| | 435 | $this->assertSame( 5, $position ); |
| | 436 | |
| | 437 | add_filter( 'bbp_show_lead_topic', '__return_false' ); |
| | 438 | |
| | 439 | $position = get_post_field( 'menu_order', $r[3] ); |
| | 440 | $this->assertSame( 4, $position ); |
| | 441 | |
| | 442 | $position = bbp_get_reply_position( $r[3] ); |
| | 443 | $this->assertSame( 4, $position ); |
| | 444 | |
| | 445 | $position = bbp_get_reply_position_raw( $r[3] ); |
| | 446 | $this->assertSame( 4, $position ); |
| | 447 | |
| | 448 | // Manually switch a reply's 'menu_order' to 0 |
| | 449 | wp_update_post( array( |
| | 450 | 'ID' => $r[3], |
| | 451 | 'menu_order' => 0 |
| | 452 | ) ); |
| | 453 | |
| | 454 | $position = get_post_field( 'menu_order', $r[3] ); |
| | 455 | $this->assertSame( 0, $position ); |
| | 456 | |
| | 457 | $position = bbp_get_reply_position( $r[3] ); |
| | 458 | $this->assertSame( 4, $position ); |
| | 459 | |
| | 460 | $position = bbp_get_reply_position_raw( $r[3] ); |
| | 461 | $this->assertSame( 4, $position ); |
| | 462 | |
| | 463 | // Repair the topic voice count meta. |
| | 464 | bbp_admin_repair_reply_menu_order(); |
| | 465 | |
| | 466 | $position = bbp_get_reply_position_raw( $r[3] ); |
| | 467 | $this->assertSame( 4, $position ); |