diff --git a/tests/phpunit/tests/functions/wpScheduledDelete.php b/tests/phpunit/tests/functions/wpScheduledDelete.php index 38044d44a1827..d3f4d144aa665 100644 --- a/tests/phpunit/tests/functions/wpScheduledDelete.php +++ b/tests/phpunit/tests/functions/wpScheduledDelete.php @@ -1,9 +1,9 @@ post->create( @@ -40,21 +41,21 @@ public function test_wp_scheduled_delete() { add_post_meta( self::$page_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS + 1 ) ); add_post_meta( self::$page_id, '_wp_trash_meta_status', 'published' ); - $this->assertNotEmpty( get_post( self::$page_id ) ); + $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); wp_scheduled_delete(); - $this->assertEmpty( get_post( self::$page_id ) ); + $this->assertNull( get_post( self::$page_id ) ); } /** - * Don't delete old trashed post/pages if status not trash. - * Remove the trash meta status. + * Tests that old trashed posts/pages are not deleted if status is not 'trash'. * - * @ticket 59938 + * Ensures that the trash meta status is removed. * + * @ticket 59938 */ - public function test_wp_scheduled_delete_not_trash() { + public function test_wp_scheduled_delete_status_not_trash() { self::$page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -64,23 +65,22 @@ public function test_wp_scheduled_delete_not_trash() { add_post_meta( self::$page_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS + 1 ) ); add_post_meta( self::$page_id, '_wp_trash_meta_status', 'published' ); - $this->assertNotEmpty( get_post( self::$page_id ) ); + $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); wp_scheduled_delete(); - $this->assertNotEmpty( get_post( self::$page_id ) ); - $this->assertEmpty( get_post_meta( self::$page_id, '_wp_trash_meta_time', true ) ); - $this->assertEmpty( get_post_meta( self::$page_id, '_wp_trash_meta_status', true ) ); + $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); + $this->assertSame( '', get_post_meta( self::$page_id, '_wp_trash_meta_time', true ) ); + $this->assertSame( '', get_post_meta( self::$page_id, '_wp_trash_meta_status', true ) ); } /** - * Don't delete old trashed post/pages if old enough. + * Tests that old trashed posts/pages are not deleted if not old enough. * * @ticket 59938 - * */ - public function test_wp_scheduled_delete_not_old() { + public function test_wp_scheduled_delete_page_not_old_enough() { self::$page_id = self::factory()->post->create( array( 'post_type' => 'page', @@ -90,20 +90,19 @@ public function test_wp_scheduled_delete_not_old() { add_post_meta( self::$page_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ) ); add_post_meta( self::$page_id, '_wp_trash_meta_status', 'published' ); - $this->assertNotEmpty( get_post( self::$page_id ) ); + $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); wp_scheduled_delete(); - $this->assertNotEmpty( get_post( self::$page_id ) ); - $this->assertNotEmpty( get_post_meta( self::$page_id, '_wp_trash_meta_time', true ) ); - $this->assertNotEmpty( get_post_meta( self::$page_id, '_wp_trash_meta_status', true ) ); + $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); + $this->assertIsNumeric( get_post_meta( self::$page_id, '_wp_trash_meta_time', true ) ); + $this->assertSame( 'published', get_post_meta( self::$page_id, '_wp_trash_meta_status', true ) ); } /** - * Delete old trashed comments. + * Tests that old trashed comments are deleted. * * @ticket 59938 - * */ public function test_wp_scheduled_delete_comment() { self::$comment_id = self::factory()->comment->create( @@ -114,21 +113,21 @@ public function test_wp_scheduled_delete_comment() { add_comment_meta( self::$comment_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS + 1 ) ); add_post_meta( self::$comment_id, '_wp_trash_meta_status', 'published' ); - $this->assertNotEmpty( get_comment( self::$comment_id ) ); + $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); wp_scheduled_delete(); - $this->assertEmpty( get_comment( self::$comment_id ) ); + $this->assertNull( get_comment( self::$comment_id ) ); } /** - * Don't delete old trashed comments if status not trash. - * Remove the trash meta status. + * Tests that old trashed comments are not deleted if status is not 'trash'. * - * @ticket 59938 + * Ensures that the trash meta status is removed. * + * @ticket 59938 */ - public function test_wp_scheduled_delete_not_trash_comment() { + public function test_wp_scheduled_delete_comment_status_not_trash() { self::$comment_id = self::factory()->comment->create( array( 'comment_approved' => '1', @@ -137,23 +136,22 @@ public function test_wp_scheduled_delete_not_trash_comment() { add_comment_meta( self::$comment_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS + 1 ) ); add_comment_meta( self::$comment_id, '_wp_trash_meta_status', 'published' ); - $this->assertNotEmpty( get_comment( self::$comment_id ) ); + $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); wp_scheduled_delete(); - $this->assertNotEmpty( get_comment( self::$comment_id ) ); - $this->assertEmpty( get_comment_meta( self::$comment_id, '_wp_trash_meta_time', true ) ); - $this->assertEmpty( get_comment_meta( self::$comment_id, '_wp_trash_meta_status', true ) ); + $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); + $this->assertSame( '', get_comment_meta( self::$comment_id, '_wp_trash_meta_time', true ) ); + $this->assertSame( '', get_comment_meta( self::$comment_id, '_wp_trash_meta_status', true ) ); } /** - * Don't delete old trashed comments if old enough. + * Tests that old trashed comments are not deleted if not old enough. * * @ticket 59938 - * */ - public function test_wp_scheduled_delete_not_old_comment() { + public function test_wp_scheduled_delete_comment_not_old_enough() { self::$comment_id = self::factory()->comment->create( array( 'comment_approved' => 'trash', @@ -162,12 +160,12 @@ public function test_wp_scheduled_delete_not_old_comment() { add_comment_meta( self::$comment_id, '_wp_trash_meta_time', time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ) ); add_comment_meta( self::$comment_id, '_wp_trash_meta_status', 'published' ); - $this->assertNotEmpty( get_comment( self::$comment_id ) ); + $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); wp_scheduled_delete(); - $this->assertNotEmpty( get_comment( self::$comment_id ) ); - $this->assertNotEmpty( get_comment_meta( self::$comment_id, '_wp_trash_meta_time', true ) ); - $this->assertNotEmpty( get_comment_meta( self::$comment_id, '_wp_trash_meta_status', true ) ); + $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); + $this->assertIsNumeric( get_comment_meta( self::$comment_id, '_wp_trash_meta_time', true ) ); + $this->assertSame( 'published', get_comment_meta( self::$comment_id, '_wp_trash_meta_status', true ) ); } }