Changeset 47329 for branches/3.9/tests/phpunit/tests/post.php
- Timestamp:
- 02/20/2020 05:04:42 PM (5 years ago)
- Location:
- branches/3.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.9
-
branches/3.9/tests/phpunit/tests/post.php
r32182 r47329 447 447 448 448 global $wp_rewrite; 449 $wp_rewrite->init(); 449 450 $wp_rewrite->set_permalink_structure('/%year%/%monthnum%/%day%/%postname%/'); 451 $wp_rewrite->flush_rules(); 450 452 451 453 $post = array( … … 736 738 $this->assertEquals( $post->post_author, $this->author_id ); 737 739 $this->assertEquals( $post->post_title, $title ); 738 }739 740 /**741 * @ticket 19373742 */743 function test_insert_programmatic_without_current_user_success() {744 $this->_unset_current_user();745 746 register_taxonomy( 'test_tax', 'post' );747 748 $title = rand_str();749 $post_data = array(750 'post_author' => $this->author_id,751 'post_status' => 'public',752 'post_content' => rand_str(),753 'post_title' => $title,754 'tax_input' => array(755 'test_tax' => array( 'term', 'term2', 'term3' )756 )757 );758 // with sanitize set to false759 $insert_post_id = wp_insert_post( $post_data, true, false );760 761 $post = get_post( $insert_post_id );762 $this->assertEquals( $post->post_author, $this->author_id );763 $this->assertEquals( $post->post_title, $title );764 765 $terms = wp_get_object_terms( $insert_post_id, 'test_tax' );766 $this->assertTrue( ( is_array( $terms ) && count( $terms ) == 3 ) );767 }768 769 /**770 * @ticket 19373771 */772 function test_insert_programmatic_without_current_user_fail() {773 $this->_unset_current_user();774 775 register_taxonomy( 'test_tax', 'post' );776 777 $title = rand_str();778 $post_data = array(779 // post_author not set780 'post_status' => 'public',781 'post_content' => rand_str(),782 'post_title' => $title,783 'tax_input' => array(784 'test_tax' => array( 'term', 'term2', 'term3' )785 )786 );787 // with sanitize set to false788 $insert_post_id = wp_insert_post( $post_data, true, false );789 790 // should error because no default user exists and no post author is passed in791 $this->assertInstanceOf( 'WP_Error', $insert_post_id );792 $this->assertEquals( 'empty_author', $insert_post_id->get_error_code() );793 740 } 794 741
Note: See TracChangeset
for help on using the changeset viewer.