| | 570 | |
| | 571 | public function test_close_comments_for_old_post() { |
| | 572 | update_option( 'close_comments_for_old_posts', true ); |
| | 573 | // Close comments more than one day old. |
| | 574 | update_option( 'close_comments_days_old', 1 ); |
| | 575 | |
| | 576 | $old_date = strtotime( '-25 hours' ); |
| | 577 | $old_post_id = self::factory()->post->create_and_get( array( 'post_date' => strftime( '%Y-%m-%d %H:%M:%S', $old_date ) ) ); |
| | 578 | |
| | 579 | $old_post_comment_status = _close_comments_for_old_post( true, $old_post_id ); |
| | 580 | $this->assertFalse( $old_post_comment_status ); |
| | 581 | |
| | 582 | $new_post_comment_status = _close_comments_for_old_post( true, self::$post_id ); |
| | 583 | $this->assertTrue( $new_post_comment_status ); |
| | 584 | } |
| | 585 | |
| | 586 | public function test_close_comments_for_old_post_undated_draft() { |
| | 587 | $draft_id = self::factory()->post->create_and_get( array( 'post_status' => 'draft', 'post_type' => 'post' ) ); |
| | 588 | $draft_comment_status = _close_comments_for_old_post( true, $draft_id ); |
| | 589 | |
| | 590 | $this->assertTrue( $draft_comment_status ); |
| | 591 | } |