Changeset 35242 for trunk/tests/phpunit/tests/post.php
- Timestamp:
- 10/17/2015 06:02:16 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post.php
r35225 r35242 546 546 global $wpdb; 547 547 548 $attachment = self:: $factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) );549 $page = self:: $factory->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) );550 $other_att = self:: $factory->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) );548 $attachment = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'attachment' ) ); 549 $page = self::factory()->post->create_and_get( array( 'post_title' => 'some-page', 'post_type' => 'page' ) ); 550 $other_att = self::factory()->post->create_and_get( array( 'post_title' => 'some-other-page', 'post_type' => 'attachment' ) ); 551 551 552 552 $wpdb->update( $wpdb->posts, array( 'post_name' => 'some-page' ), array( 'ID' => $page->ID ) ); … … 566 566 567 567 function test_wp_publish_post() { 568 $draft_id = self:: $factory->post->create( array( 'post_status' => 'draft' ) );568 $draft_id = self::factory()->post->create( array( 'post_status' => 'draft' ) ); 569 569 570 570 $post = get_post( $draft_id ); … … 582 582 function test_wp_insert_post_and_wp_publish_post_with_future_date() { 583 583 $future_date = gmdate( 'Y-m-d H:i:s', time() + 10000000 ); 584 $post_id = self:: $factory->post->create( array(584 $post_id = self::factory()->post->create( array( 585 585 'post_status' => 'publish', 586 586 'post_date' => $future_date, … … 642 642 */ 643 643 function test_get_page_uri_with_stdclass_post_object() { 644 $post_id = self:: $factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );644 $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); 645 645 646 646 // Mimick an old stdClass post object, missing the ancestors field. … … 665 665 */ 666 666 function test_get_post_uri_check_orphan() { 667 $parent_id = self:: $factory->post->create( array( 'post_name' => 'parent' ) );668 $child_id = self:: $factory->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) );667 $parent_id = self::factory()->post->create( array( 'post_name' => 'parent' ) ); 668 $child_id = self::factory()->post->create( array( 'post_name' => 'child', 'post_parent' => $parent_id ) ); 669 669 670 670 // check the parent for good measure … … 684 684 function test_get_post_ancestors_within_loop() { 685 685 global $post; 686 $parent_id = self:: $factory->post->create();687 $post = self:: $factory->post->create_and_get( array( 'post_parent' => $parent_id ) );686 $parent_id = self::factory()->post->create(); 687 $post = self::factory()->post->create_and_get( array( 'post_parent' => $parent_id ) ); 688 688 $this->assertEquals( array( $parent_id ), get_post_ancestors( 0 ) ); 689 689 } … … 693 693 */ 694 694 function test_update_invalid_post_id() { 695 $post_id = self:: $factory->post->create( array( 'post_name' => 'get-page-uri-post-name' ) );695 $post_id = self::factory()->post->create( array( 'post_name' => 'get-page-uri-post-name' ) ); 696 696 $post = get_post( $post_id, ARRAY_A ); 697 697 … … 708 708 function test_parse_post_content_single_page() { 709 709 global $multipage, $pages, $numpages; 710 $post_id = self:: $factory->post->create( array( 'post_content' => 'Page 0' ) );710 $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) ); 711 711 $post = get_post( $post_id ); 712 712 setup_postdata( $post ); … … 719 719 function test_parse_post_content_multi_page() { 720 720 global $multipage, $pages, $numpages; 721 $post_id = self:: $factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );721 $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); 722 722 $post = get_post( $post_id ); 723 723 setup_postdata( $post ); … … 730 730 function test_parse_post_content_remaining_single_page() { 731 731 global $multipage, $pages, $numpages; 732 $post_id = self:: $factory->post->create( array( 'post_content' => 'Page 0' ) );732 $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0' ) ); 733 733 $post = get_post( $post_id ); 734 734 setup_postdata( $post ); … … 741 741 function test_parse_post_content_remaining_multi_page() { 742 742 global $multipage, $pages, $numpages; 743 $post_id = self:: $factory->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );743 $post_id = self::factory()->post->create( array( 'post_content' => 'Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); 744 744 $post = get_post( $post_id ); 745 745 setup_postdata( $post ); … … 755 755 function test_parse_post_content_starting_with_nextpage() { 756 756 global $multipage, $pages, $numpages; 757 $post_id = self:: $factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) );757 $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0<!--nextpage-->Page 1<!--nextpage-->Page 2<!--nextpage-->Page 3' ) ); 758 758 $post = get_post( $post_id ); 759 759 setup_postdata( $post ); … … 769 769 function test_parse_post_content_starting_with_nextpage_multi() { 770 770 global $multipage, $pages, $numpages; 771 $post_id = self:: $factory->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) );771 $post_id = self::factory()->post->create( array( 'post_content' => '<!--nextpage-->Page 0' ) ); 772 772 $post = get_post( $post_id ); 773 773 setup_postdata( $post ); … … 810 810 $post_type = rand_str(20); 811 811 register_post_type( $post_type ); 812 self:: $factory->post->create( array(812 self::factory()->post->create( array( 813 813 'post_type' => $post_type, 814 814 'post_author' => self::$editor_id … … 823 823 $post_type = rand_str(20); 824 824 register_post_type( $post_type ); 825 self:: $factory->post->create_many( 3, array(825 self::factory()->post->create_many( 3, array( 826 826 'post_type' => $post_type, 827 827 'post_author' => self::$editor_id … … 843 843 844 844 function test_wp_count_posts_insert_invalidation() { 845 $post_ids = self:: $factory->post->create_many( 3 );845 $post_ids = self::factory()->post->create_many( 3 ); 846 846 $initial_counts = wp_count_posts(); 847 847 … … 861 861 862 862 function test_wp_count_posts_trash_invalidation() { 863 $post_ids = self:: $factory->post->create_many( 3 );863 $post_ids = self::factory()->post->create_many( 3 ); 864 864 $initial_counts = wp_count_posts(); 865 865 … … 882 882 */ 883 883 function test_get_the_date_with_id_returns_correct_time() { 884 $post_id = self:: $factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );884 $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); 885 885 $this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) ); 886 886 } … … 900 900 */ 901 901 function test_get_the_time_with_id_returns_correct_time() { 902 $post_id = self:: $factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );902 $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); 903 903 $this->assertEquals( '16:35:00', get_the_time( 'H:i:s', $post_id ) ); 904 904 } … … 918 918 */ 919 919 function test_get_post_time_with_id_returns_correct_time() { 920 $post_id = self:: $factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );920 $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); 921 921 $this->assertEquals( '16:35:00', get_post_time( 'H:i:s', false, $post_id ) ); 922 922 } … … 936 936 */ 937 937 function test_get_post_modified_time_with_id_returns_correct_time() { 938 $post_id = self:: $factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );938 $post_id = self::factory()->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) ); 939 939 $this->assertEquals( '16:35:00', get_post_modified_time( 'H:i:s', false, $post_id ) ); 940 940 } … … 974 974 register_taxonomy( $tax, $post_type ); 975 975 976 $post = self:: $factory->post->create( array( 'post_type' => $post_type ) );976 $post = self::factory()->post->create( array( 'post_type' => $post_type ) ); 977 977 wp_set_object_terms( $post, rand_str(), $tax ); 978 978 … … 1016 1016 require_once( ABSPATH . '/wp-admin/includes/post.php' ); 1017 1017 1018 $post_id = self:: $factory->post->create();1018 $post_id = self::factory()->post->create(); 1019 1019 1020 1020 $data = array( … … 1044 1044 */ 1045 1045 function test_wp_insert_post_default_comment_ping_status_open() { 1046 $post_id = self:: $factory->post->create( array(1046 $post_id = self::factory()->post->create( array( 1047 1047 'post_author' => self::$editor_id, 1048 1048 'post_status' => 'public', … … 1060 1060 */ 1061 1061 function test_wp_insert_post_page_default_comment_ping_status_closed() { 1062 $post_id = self:: $factory->post->create( array(1062 $post_id = self::factory()->post->create( array( 1063 1063 'post_author' => self::$editor_id, 1064 1064 'post_status' => 'public', … … 1079 1079 $post_type = rand_str(20); 1080 1080 register_post_type( $post_type, array( 'supports' => array( 'comments', 'trackbacks' ) ) ); 1081 $post_id = self:: $factory->post->create( array(1081 $post_id = self::factory()->post->create( array( 1082 1082 'post_author' => self::$editor_id, 1083 1083 'post_status' => 'public', … … 1099 1099 $post_type = rand_str(20); 1100 1100 register_post_type( $post_type ); 1101 $post_id = self:: $factory->post->create( array(1101 $post_id = self::factory()->post->create( array( 1102 1102 'post_author' => self::$editor_id, 1103 1103 'post_status' => 'public', … … 1128 1128 1129 1129 // Create a sticky post. 1130 $post = self:: $factory->post->create_and_get( array(1130 $post = self::factory()->post->create_and_get( array( 1131 1131 'post_title' => 'Will be changed', 1132 1132 'post_content' => 'Will be changed', … … 1157 1157 function test_user_without_publish_cannot_affect_sticky_with_edit_post() { 1158 1158 // Create a sticky post. 1159 $post = self:: $factory->post->create_and_get( array(1159 $post = self::factory()->post->create_and_get( array( 1160 1160 'post_title' => 'Will be changed', 1161 1161 'post_content' => 'Will be changed', … … 1192 1192 */ 1193 1193 public function test_wp_insert_post_author_zero() { 1194 $post_id = self:: $factory->post->create( array( 'post_author' => 0 ) );1194 $post_id = self::factory()->post->create( array( 'post_author' => 0 ) ); 1195 1195 1196 1196 $this->assertEquals( 0, get_post( $post_id )->post_author ); … … 1201 1201 */ 1202 1202 public function test_wp_insert_post_author_null() { 1203 $post_id = self:: $factory->post->create( array( 'post_author' => null ) );1203 $post_id = self::factory()->post->create( array( 'post_author' => null ) ); 1204 1204 1205 1205 $this->assertEquals( self::$editor_id, get_post( $post_id )->post_author );
Note: See TracChangeset
for help on using the changeset viewer.