WordPress.org

Make WordPress Core

Changeset 1026 in tests


Ignore:
Timestamp:
09/19/2012 08:26:42 PM (6 years ago)
Author:
westi
Message:

Posts: Add a simple test case for wp_insert_post rejecting invalid dates. See #WP17180 props jkudish

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/post.php

    r1021 r1026  
    344344    }
    345345
     346    /**
     347     * @ticket 17180
     348     */
     349    function test_vb_insert_invalid_date() {
     350        // insert a post with an invalid date, make sure it fails
     351
     352        $post = array(
     353            'post_author' => $this->author_id,
     354            'post_status' => 'public',
     355            'post_content' => rand_str(),
     356            'post_title' => rand_str(),
     357            'post_date'  => '2012-02-30 00:00:00',
     358        );
     359
     360        $insert_post = wp_insert_post( $post );
     361        $this->assertTrue( is_wp_error( $insert_post ), 'Did not get a WP_Error back from wp_insert_post' );
     362        $this->assertEquals( 'invalid_date', $insert_post->get_error_code() );
     363
     364    }
     365
    346366    function test_vb_insert_future_change_to_private() {
    347367        // insert a future post, then edit and change it to private, and make sure cron gets it right
Note: See TracChangeset for help on using the changeset viewer.