Changeset 30510
- Timestamp:
- 11/22/2014 12:03:48 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/post.php
r30480 r30510 739 739 740 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 }794 795 /**796 741 * @ticket 24803 797 742 */
Note: See TracChangeset
for help on using the changeset viewer.