-
Notifications
You must be signed in to change notification settings - Fork 3.6k
test for wp_schedule_delete_old_privacy_export_files #5550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
783a80a
a96a99b
8d272cf
fae0625
aa41786
2954bb1
fad85e6
cad3d64
bc4a463
65573a0
d7b8316
00a70ad
c1401c4
aab5e7b
2febc80
b6b0348
a95d4da
c01042a
83e9540
259c39c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,67 @@ | ||||||||||||||||||||||||||||||||||||||||||
| <?php | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Tests for the wp_schedule_delete_old_privacy_export_files() function. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @group functions | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @covers ::wp_schedule_delete_old_privacy_export_files | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| class Tests_Functions_wpScheduleDeleteOldPrivacyExportFiles extends WP_UnitTestCase { | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Setup test | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function set_up() { | ||||||||||||||||||||||||||||||||||||||||||
| parent::set_up(); | ||||||||||||||||||||||||||||||||||||||||||
| wp_clear_scheduled_hook( 'wp_privacy_delete_old_export_files' ); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| public function tear_down() { | ||||||||||||||||||||||||||||||||||||||||||
| wp_clear_scheduled_hook( 'wp_privacy_delete_old_export_files' ); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| parent::tear_down(); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * check that a schedule is set | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @ticket 59707 | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function test_wp_schedule_delete_old_privacy_export_files() { | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ), 'no export should be scheduled' ); | ||||||||||||||||||||||||||||||||||||||||||
| wp_schedule_delete_old_privacy_export_files(); | ||||||||||||||||||||||||||||||||||||||||||
| $this->assertIsInt( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ), 'export should be scheduled' ); | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * check that no schedule is set when WP is in installing mode | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @ticket 59707 | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function test_wp_schedule_delete_old_privacy_export_files_is_installing() { | ||||||||||||||||||||||||||||||||||||||||||
| // set to installing mode | ||||||||||||||||||||||||||||||||||||||||||
| $prior = wp_installing(); | ||||||||||||||||||||||||||||||||||||||||||
| wp_installing( true ); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ), 'no export should be scheduled' ); | ||||||||||||||||||||||||||||||||||||||||||
| wp_schedule_delete_old_privacy_export_files(); | ||||||||||||||||||||||||||||||||||||||||||
| $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ), 'export should be scheduled' ); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| wp_installing( $prior ); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+44
to
+52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Since the installing mode restoration occurs after the assertion, if the assertion fails, the installing mode is not restored, which affects subsequent tests. I believe we need to be careful about the order to ensure that the installing mode is always restored regardless of whether the assertion succeeds or fails. Also, please note that the message has been changed from |
||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * Check that calling the function when already scheduled does not create a duplicate. | ||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||
| * @ticket 59707 | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| public function test_wp_schedule_delete_old_privacy_export_files_already_scheduled() { | ||||||||||||||||||||||||||||||||||||||||||
| wp_schedule_delete_old_privacy_export_files(); | ||||||||||||||||||||||||||||||||||||||||||
| $first = wp_next_scheduled( 'wp_privacy_delete_old_export_files' ); | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| wp_schedule_delete_old_privacy_export_files(); | ||||||||||||||||||||||||||||||||||||||||||
| $this->assertSame( $first, wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+61
to
+65
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This assertion doesn't currently catch a regression — removing the
Seeding the event at a timestamp other than This follows the same pattern as test_pre_schedule_event_filter(). |
||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
|
pbearne marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.