Changeset 53783 for trunk/tests/phpunit/tests/post.php
- Timestamp:
- 07/26/2022 02:28:57 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/post.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post.php
r53782 r53783 596 596 } 597 597 598 public function test_wp_publish_post() {599 $draft_id = self::factory()->post->create(600 array(601 'post_status' => 'draft',602 )603 );604 605 $post = get_post( $draft_id );606 $this->assertSame( 'draft', $post->post_status );607 608 wp_publish_post( $draft_id );609 610 $post = get_post( $draft_id );611 $this->assertSame( 'publish', $post->post_status );612 }613 614 /**615 * @ticket 22944616 */617 public function test_wp_insert_post_and_wp_publish_post_with_future_date() {618 $future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 );619 $post_id = self::factory()->post->create(620 array(621 'post_status' => 'publish',622 'post_date' => $future_date,623 )624 );625 626 $post = get_post( $post_id );627 $this->assertSame( 'future', $post->post_status );628 $this->assertSame( $future_date, $post->post_date );629 630 wp_publish_post( $post_id );631 632 $post = get_post( $post_id );633 $this->assertSame( 'publish', $post->post_status );634 $this->assertSame( $future_date, $post->post_date );635 }636 637 /**638 * @ticket 48145639 */640 public function test_wp_insert_post_should_default_to_publish_if_post_date_is_within_59_seconds_from_current_time() {641 $future_date = gmdate( 'Y-m-d H:i:s', time() + 59 );642 $post_id = self::factory()->post->create(643 array(644 'post_date' => $future_date,645 )646 );647 648 $post = get_post( $post_id );649 $this->assertSame( 'publish', $post->post_status );650 $this->assertSame( $future_date, $post->post_date );651 }652 653 /**654 * @ticket 22944655 */656 public function test_publish_post_with_content_filtering() {657 kses_remove_filters();658 659 $post_id = wp_insert_post(660 array(661 'post_title' => '<script>Test</script>',662 )663 );664 $post = get_post( $post_id );665 $this->assertSame( '<script>Test</script>', $post->post_title );666 $this->assertSame( 'draft', $post->post_status );667 668 kses_init_filters();669 670 wp_update_post(671 array(672 'ID' => $post->ID,673 'post_status' => 'publish',674 )675 );676 677 kses_remove_filters();678 679 $post = get_post( $post->ID );680 $this->assertSame( 'Test', $post->post_title );681 }682 683 /**684 * @ticket 22944685 */686 public function test_wp_publish_post_and_avoid_content_filtering() {687 kses_remove_filters();688 689 $post_id = wp_insert_post(690 array(691 'post_title' => '<script>Test</script>',692 )693 );694 $post = get_post( $post_id );695 $this->assertSame( '<script>Test</script>', $post->post_title );696 $this->assertSame( 'draft', $post->post_status );697 698 kses_init_filters();699 700 wp_publish_post( $post->ID );701 702 kses_remove_filters();703 704 $post = get_post( $post->ID );705 $this->assertSame( '<script>Test</script>', $post->post_title );706 }707 708 598 /** 709 599 * @ticket 23708
Note: See TracChangeset
for help on using the changeset viewer.