Changeset 25168 for trunk/tests/phpunit/tests/post.php
- Timestamp:
- 08/29/2013 06:48:29 PM (12 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/post.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post.php
r25002 r25168 20 20 parent::tearDown(); 21 21 } 22 22 23 23 // helper function: return the timestamp(s) of cron jobs for the specified hook and post 24 24 function _next_schedule_for_post($hook, $id) { 25 25 return wp_next_scheduled('publish_future_post', array(0=>intval($id))); 26 26 } 27 27 28 28 // helper function, unsets current user globally 29 29 function _unset_current_user() { 30 30 global $current_user, $user_ID; 31 31 32 32 $current_user = $user_ID = null; 33 33 } 34 34 35 35 // test simple valid behavior: insert and get a post 36 36 function test_vb_insert_get_delete() { … … 708 708 function test_insert_programmatic_sanitized() { 709 709 $this->_unset_current_user(); 710 710 711 711 register_taxonomy( 'test_tax', 'post' ); 712 712 713 713 $title = rand_str(); 714 714 $post_data = array( … … 723 723 $insert_post_id = wp_insert_post( $post_data, true, true ); 724 724 $this->assertTrue( ( is_int($insert_post_id) && $insert_post_id > 0 ) ); 725 725 726 726 $post = get_post( $insert_post_id ); 727 727 $this->assertEquals( $post->post_author, $this->author_id ); … … 734 734 function test_insert_programmatic_without_current_user_success() { 735 735 $this->_unset_current_user(); 736 736 737 737 register_taxonomy( 'test_tax', 'post' ); 738 738 739 739 $title = rand_str(); 740 740 $post_data = array( … … 749 749 // with sanitize set to false 750 750 $insert_post_id = wp_insert_post( $post_data, true, false ); 751 751 752 752 $post = get_post( $insert_post_id ); 753 753 $this->assertEquals( $post->post_author, $this->author_id ); 754 754 $this->assertEquals( $post->post_title, $title ); 755 755 756 756 $terms = wp_get_object_terms( $insert_post_id, 'test_tax' ); 757 757 $this->assertTrue( ( is_array( $terms ) && count( $terms ) == 3 ) ); … … 763 763 function test_insert_programmatic_without_current_user_fail() { 764 764 $this->_unset_current_user(); 765 765 766 766 register_taxonomy( 'test_tax', 'post' ); 767 767 768 768 $title = rand_str(); 769 769 $post_data = array( … … 799 799 $this->assertEquals( new stdClass, wp_count_posts( $post_type, 'readable' ) ); 800 800 } 801 802 /** 803 * @ticket 22074 804 */ 805 function test_get_pages_include_exclude() { 806 $page_ids = array(); 807 808 foreach ( range( 1, 20 ) as $i ) 809 $page_ids[] = $this->factory->post->create( array( 'post_type' => 'page' ) ); 810 811 $inc = array_slice( $page_ids, 0, 10 ); 812 sort( $inc ); 813 $exc = array_slice( $page_ids, 10 ); 814 sort( $exc ); 815 816 $include = get_pages( array( 'include' => $inc ) ); 817 $inc_result = wp_list_pluck( $include, 'ID' ); 818 sort( $inc_result ); 819 $this->assertEquals( $inc, $inc_result ); 820 821 $exclude = get_pages( array( 'exclude' => $exc ) ); 822 $exc_result = wp_list_pluck( $exclude, 'ID' ); 823 sort( $exc_result ); 824 $this->assertEquals( $inc, $exc_result ); 825 } 801 826 }
Note: See TracChangeset
for help on using the changeset viewer.