Changeset 57237
- Timestamp:
- 01/02/2024 03:57:20 PM (13 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/functions/wpScheduledDelete.php
r57224 r57237 2 2 3 3 /** 4 * Tests for the wp_scheduled_delete function.4 * Tests for the wp_scheduled_delete() function. 5 5 * 6 * @group Functions.php6 * @group functions 7 7 * 8 8 * @covers ::wp_scheduled_delete … … 18 18 wp_delete_comment( self::$comment_id ); 19 19 } 20 20 21 // Remove page. 21 22 if ( self::$page_id ) { 22 23 wp_delete_post( self::$page_id ); 23 24 } 25 24 26 parent::tear_down(); 25 27 } 26 28 27 29 /** 28 * Delete old trashed post/pages.30 * Tests that old trashed posts/pages are deleted. 29 31 * 30 32 * @ticket 59938 31 *32 33 */ 33 34 public function test_wp_scheduled_delete() { … … 41 42 add_post_meta( self::$page_id, '_wp_trash_meta_status', 'published' ); 42 43 43 $this->assert NotEmpty(get_post( self::$page_id ) );44 $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); 44 45 45 46 wp_scheduled_delete(); 46 47 47 $this->assert Empty( get_post( self::$page_id ) );48 $this->assertNull( get_post( self::$page_id ) ); 48 49 } 49 50 50 51 /** 51 * Don't delete old trashed post/pages if status not trash. 52 * Remove the trash meta status. 52 * Tests that old trashed posts/pages are not deleted if status is not 'trash'. 53 * 54 * Ensures that the trash meta status is removed. 53 55 * 54 56 * @ticket 59938 55 *56 57 */ 57 public function test_wp_scheduled_delete_ not_trash() {58 public function test_wp_scheduled_delete_status_not_trash() { 58 59 self::$page_id = self::factory()->post->create( 59 60 array( … … 65 66 add_post_meta( self::$page_id, '_wp_trash_meta_status', 'published' ); 66 67 67 $this->assert NotEmpty(get_post( self::$page_id ) );68 $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); 68 69 69 70 wp_scheduled_delete(); 70 71 71 $this->assert NotEmpty(get_post( self::$page_id ) );72 $this->assert Empty(get_post_meta( self::$page_id, '_wp_trash_meta_time', true ) );73 $this->assert Empty(get_post_meta( self::$page_id, '_wp_trash_meta_status', true ) );72 $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); 73 $this->assertSame( '', get_post_meta( self::$page_id, '_wp_trash_meta_time', true ) ); 74 $this->assertSame( '', get_post_meta( self::$page_id, '_wp_trash_meta_status', true ) ); 74 75 } 75 76 76 77 77 78 /** 78 * Don't delete old trashed post/pages ifold enough.79 * Tests that old trashed posts/pages are not deleted if not old enough. 79 80 * 80 81 * @ticket 59938 81 *82 82 */ 83 public function test_wp_scheduled_delete_ not_old() {83 public function test_wp_scheduled_delete_page_not_old_enough() { 84 84 self::$page_id = self::factory()->post->create( 85 85 array( … … 91 91 add_post_meta( self::$page_id, '_wp_trash_meta_status', 'published' ); 92 92 93 $this->assert NotEmpty(get_post( self::$page_id ) );93 $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); 94 94 95 95 wp_scheduled_delete(); 96 96 97 $this->assert NotEmpty(get_post( self::$page_id ) );98 $this->assert NotEmpty( get_post_meta( self::$page_id, '_wp_trash_meta_time', true ) );99 $this->assert NotEmpty(get_post_meta( self::$page_id, '_wp_trash_meta_status', true ) );97 $this->assertInstanceOf( 'WP_Post', get_post( self::$page_id ) ); 98 $this->assertIsNumeric( get_post_meta( self::$page_id, '_wp_trash_meta_time', true ) ); 99 $this->assertSame( 'published', get_post_meta( self::$page_id, '_wp_trash_meta_status', true ) ); 100 100 } 101 101 102 102 /** 103 * Delete old trashed comments.103 * Tests that old trashed comments are deleted. 104 104 * 105 105 * @ticket 59938 106 *107 106 */ 108 107 public function test_wp_scheduled_delete_comment() { … … 115 114 add_post_meta( self::$comment_id, '_wp_trash_meta_status', 'published' ); 116 115 117 $this->assert NotEmpty(get_comment( self::$comment_id ) );116 $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); 118 117 119 118 wp_scheduled_delete(); 120 119 121 $this->assert Empty( get_comment( self::$comment_id ) );120 $this->assertNull( get_comment( self::$comment_id ) ); 122 121 } 123 122 124 123 /** 125 * Don't delete old trashed comments if status not trash. 126 * Remove the trash meta status. 124 * Tests that old trashed comments are not deleted if status is not 'trash'. 125 * 126 * Ensures that the trash meta status is removed. 127 127 * 128 128 * @ticket 59938 129 *130 129 */ 131 public function test_wp_scheduled_delete_ not_trash_comment() {130 public function test_wp_scheduled_delete_comment_status_not_trash() { 132 131 self::$comment_id = self::factory()->comment->create( 133 132 array( … … 138 137 add_comment_meta( self::$comment_id, '_wp_trash_meta_status', 'published' ); 139 138 140 $this->assert NotEmpty(get_comment( self::$comment_id ) );139 $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); 141 140 142 141 wp_scheduled_delete(); 143 142 144 $this->assert NotEmpty(get_comment( self::$comment_id ) );145 $this->assert Empty(get_comment_meta( self::$comment_id, '_wp_trash_meta_time', true ) );146 $this->assert Empty(get_comment_meta( self::$comment_id, '_wp_trash_meta_status', true ) );143 $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); 144 $this->assertSame( '', get_comment_meta( self::$comment_id, '_wp_trash_meta_time', true ) ); 145 $this->assertSame( '', get_comment_meta( self::$comment_id, '_wp_trash_meta_status', true ) ); 147 146 } 148 147 149 148 150 149 /** 151 * Don't delete old trashed comments ifold enough.150 * Tests that old trashed comments are not deleted if not old enough. 152 151 * 153 152 * @ticket 59938 154 *155 153 */ 156 public function test_wp_scheduled_delete_ not_old_comment() {154 public function test_wp_scheduled_delete_comment_not_old_enough() { 157 155 self::$comment_id = self::factory()->comment->create( 158 156 array( … … 163 161 add_comment_meta( self::$comment_id, '_wp_trash_meta_status', 'published' ); 164 162 165 $this->assert NotEmpty(get_comment( self::$comment_id ) );163 $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); 166 164 167 165 wp_scheduled_delete(); 168 166 169 $this->assert NotEmpty(get_comment( self::$comment_id ) );170 $this->assert NotEmpty( get_comment_meta( self::$comment_id, '_wp_trash_meta_time', true ) );171 $this->assert NotEmpty(get_comment_meta( self::$comment_id, '_wp_trash_meta_status', true ) );167 $this->assertInstanceOf( 'WP_Comment', get_comment( self::$comment_id ) ); 168 $this->assertIsNumeric( get_comment_meta( self::$comment_id, '_wp_trash_meta_time', true ) ); 169 $this->assertSame( 'published', get_comment_meta( self::$comment_id, '_wp_trash_meta_status', true ) ); 172 170 } 173 171 }
Note: See TracChangeset
for help on using the changeset viewer.