Make WordPress Core

Changeset 296 in tests


Ignore:
Timestamp:
05/06/2010 08:41:36 PM (15 years ago)
Author:
westi
Message:

Beginings of cross DST future post publishing tests.
See WP#9285. Needs more work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_post.php

    r256 r296  
    7979    }
    8080   
    81     function test_vb_insert_future_edit_bug() {
     81    function test_vb_insert_future_over_dst() {
     82        // insert a post with a future date, and make sure the status and cron schedule are correct
     83        $old_option = get_option('timezone_string');
     84        update_option('timezone_string', 'Europe/London');
     85       
     86        // Some magic days - one dst one not
     87        $future_date_1 = strtotime('June 21st +1 year');
     88        $future_date_2 = strtotime('Jan 11th +1 year');
     89               
     90
     91        $post = array(
     92            'post_author' => $this->author->ID,
     93            'post_status' => 'publish',
     94            'post_content' => rand_str(),
     95            'post_title' => rand_str(),
     96            'post_date'  => strftime("%Y-%m-%d %H:%M:%S", $future_date_1),
     97        );
     98
     99        // insert a post and make sure the ID is ok
     100        $id = $this->post_ids[] = wp_insert_post($post);
     101        var_dump(get_option('cron'));
     102        // fetch the post and make sure has the correct date and status
     103        $out = wp_get_single_post($id);
     104        $this->assertEquals('future', $out->post_status);
     105        $this->assertEquals($post['post_date'], $out->post_date);
     106
     107        // check that there's a publish_future_post job scheduled at the right time
     108        $this->assertEquals($future_date_1, $this->_next_schedule_for_post('publish_future_post', $id));
     109
     110        // now save it again with a date further in the future
     111
     112        $post['ID'] = $id;
     113        $post['post_date'] = strftime("%Y-%m-%d %H:%M:%S", $future_date_2);
     114        $post['post_date_gmt'] = NULL;
     115        wp_update_post($post);
     116
     117        // fetch the post again and make sure it has the new post_date
     118        $out = wp_get_single_post($id);
     119        $this->assertEquals('future', $out->post_status);
     120        $this->assertEquals($post['post_date'], $out->post_date);
     121
     122        // and the correct date on the cron job
     123        $this->assertEquals($future_date_2, $this->_next_schedule_for_post('publish_future_post', $id));
     124        update_option('timezone_string', $old_option);
     125       
     126    }   
     127
     128function test_vb_insert_future_edit_bug() {
    82129        // future post bug: posts get published at the wrong time if you edit the timestamp
    83130        // http://trac.wordpress.org/ticket/4710
Note: See TracChangeset for help on using the changeset viewer.