@@ -59,12 +59,10 @@ public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
5959 /**
6060 * Tear down after class.
6161 */
62- public static function tear_down_after_class () {
62+ public static function wpTearDownAfterClass () {
6363 $ role = get_role ( 'administrator ' );
6464 $ role ->remove_cap ( 'publish_mapped_meta_caps ' );
6565 $ role ->remove_cap ( 'publish_unmapped_meta_caps ' );
66-
67- parent ::tear_down_after_class ();
6866 }
6967
7068 /**
@@ -194,17 +192,19 @@ public function test_wp_update_post_with_content_filtering() {
194192 *
195193 * @dataProvider data_update_post_preserves_date_for_future_posts
196194 *
197- * @param string $initial_status Initial post status.
195+ * @param string $initial_status Initial post status.
196+ * @param string $time_offset Time offset.
197+ * @param string $expected_status Expected post status.
198198 */
199- public function test_update_post_preserves_date_for_future_posts ( $ initial_status ) {
199+ public function test_update_post_preserves_date_for_future_posts ( $ initial_status, $ time_offset , $ expected_status ) {
200200
201201 $ post_id = self ::factory ()->post ->create (
202202 array (
203203 'post_status ' => $ initial_status ,
204204 )
205205 );
206206
207- $ future_date = gmdate ( 'Y-m-d H:i:s ' , strtotime ( ' +1 day ' ) );
207+ $ future_date = gmdate ( 'Y-m-d H:i:s ' , strtotime ( $ time_offset ) );
208208 $ update_data = array (
209209 'ID ' => $ post_id ,
210210 'post_status ' => 'future ' ,
@@ -215,6 +215,7 @@ public function test_update_post_preserves_date_for_future_posts( $initial_statu
215215 $ updated_post = get_post ( $ post_id );
216216
217217 $ this ->assertSame ( $ future_date , $ updated_post ->post_date );
218+ $ this ->assertSame ( $ expected_status , $ updated_post ->post_status );
218219 }
219220
220221 /**
@@ -224,11 +225,35 @@ public function test_update_post_preserves_date_for_future_posts( $initial_statu
224225 */
225226 public function data_update_post_preserves_date_for_future_posts () {
226227 return array (
227- 'pending to future ' => array (
228- 'initial_status ' => 'pending ' ,
228+ 'pending to future with 1 day more ' => array (
229+ 'initial_status ' => 'pending ' ,
230+ 'time_offset ' => '+1 day ' ,
231+ 'expected_status ' => 'future ' ,
232+ ),
233+ 'draft to future with 1 day more ' => array (
234+ 'initial_status ' => 'draft ' ,
235+ 'time_offset ' => '+1 day ' ,
236+ 'expected_status ' => 'future ' ,
237+ ),
238+ 'publish to future with 1 day more ' => array (
239+ 'initial_status ' => 'publish ' ,
240+ 'time_offset ' => '+1 day ' ,
241+ 'expected_status ' => 'publish ' ,
242+ ),
243+ 'draft to future with 1 day less ' => array (
244+ 'initial_status ' => 'draft ' ,
245+ 'time_offset ' => '-1 day ' ,
246+ 'expected_status ' => 'publish ' ,
247+ ),
248+ 'pending to future with 1 day less ' => array (
249+ 'initial_status ' => 'pending ' ,
250+ 'time_offset ' => '-1 day ' ,
251+ 'expected_status ' => 'publish ' ,
229252 ),
230- 'draft to future ' => array (
231- 'initial_status ' => 'draft ' ,
253+ 'publish to future with 1 day less ' => array (
254+ 'initial_status ' => 'publish ' ,
255+ 'time_offset ' => '-1 day ' ,
256+ 'expected_status ' => 'publish ' ,
232257 ),
233258 );
234259 }
0 commit comments