WordPress.org

Make WordPress Core

Ticket #17180: 17180.unit-test.patch

File 17180.unit-test.patch, 989 bytes (added by jkudish, 8 years ago)

Unit test that tests the proposed patch (17180-4.diff) and confirms that a WP_Error is returned for invalid dates

  • tests/post.php

     
    343343                $this->assertEquals(false, $this->_next_schedule_for_post('publish_future_post', $id));
    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 ) );
     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
    348368                $future_date_1 = strtotime('+1 day');