From 783a80afc2fed5e5c53e8a08d54a57f609962088 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Mon, 23 Oct 2023 13:54:14 -0400 Subject: [PATCH 1/8] test for wp_schedule_delete_old_privacy_export_files --- .../wpScheduleDeleteOldPrivacyExportFiles.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php new file mode 100644 index 0000000000000..0ae9b83f03d97 --- /dev/null +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -0,0 +1,43 @@ +assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); + wp_schedule_delete_old_privacy_export_files(); + $this->assertIsInt( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); + } + + /** + * check that no schedule is set when in installing mode + * + * @ticket 59707 + */ + public function test_wp_schedule_delete_old_privacy_export_files_is_installing() { + // set to installing mode + wp_installing( true ); + + $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); + wp_schedule_delete_old_privacy_export_files(); + $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); + // Remove installing mode + wp_installing( false ); + } +} From a96a99b0578f32c61f3188be5295ab9ae3f100c4 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Tue, 23 Jun 2026 10:14:33 -0400 Subject: [PATCH 2/8] Update tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php Co-authored-by: John Parris --- .../tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php index 0ae9b83f03d97..53778f51e6e4d 100644 --- a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -2,7 +2,7 @@ /** * @group functions * - * @covers ::test_wp_schedule_delete_old_privacy_export_files + * @covers ::wp_schedule_delete_old_privacy_export_files */ class Tests_Functions_wpScheduleDeleteOldPrivacyExportFiles extends WP_UnitTestCase { From fae0625708f376ce9dca27afcf5f6c6d9535ae27 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Tue, 23 Jun 2026 16:14:15 -0400 Subject: [PATCH 3/8] Add tear_down method to reset wp_installing state in wpScheduleDeleteOldPrivacyExportFiles test --- .../functions/wpScheduleDeleteOldPrivacyExportFiles.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php index 53778f51e6e4d..832aafb009a39 100644 --- a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -13,6 +13,11 @@ public function set_up() { wp_unschedule_event( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ), 'wp_privacy_delete_old_export_files' ); } + public function tear_down() { + // Remove installing mode + wp_installing( false ); + } + /** * check that a schedule is set * @@ -37,7 +42,6 @@ public function test_wp_schedule_delete_old_privacy_export_files_is_installing() $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); wp_schedule_delete_old_privacy_export_files(); $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); - // Remove installing mode - wp_installing( false ); + } } From aa41786051249cb27547343454add8f08d3b186a Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Tue, 23 Jun 2026 16:18:02 -0400 Subject: [PATCH 4/8] Fix comment wording in test for scheduling function --- .../tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php index 832aafb009a39..d6c9cbe43f6e5 100644 --- a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -31,7 +31,7 @@ public function test_wp_schedule_delete_old_privacy_export_files() { } /** - * check that no schedule is set when in installing mode + * check that no schedule is set when WP is in installing mode * * @ticket 59707 */ @@ -42,6 +42,5 @@ public function test_wp_schedule_delete_old_privacy_export_files_is_installing() $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); wp_schedule_delete_old_privacy_export_files(); $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); - } } From 2954bb1db9d3e7336bbf2eeb728ad96dd658d124 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Thu, 16 Jul 2026 14:26:52 -0400 Subject: [PATCH 5/8] Update tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php Co-authored-by: John Parris --- .../tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php index d6c9cbe43f6e5..8056533885107 100644 --- a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -10,6 +10,7 @@ class Tests_Functions_wpScheduleDeleteOldPrivacyExportFiles extends WP_UnitTestC * Setup test */ public function set_up() { + parent::set_up(); wp_unschedule_event( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ), 'wp_privacy_delete_old_export_files' ); } From fad85e69c85a827606e437740c43db15354d3a33 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Thu, 16 Jul 2026 14:27:01 -0400 Subject: [PATCH 6/8] Update tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php Co-authored-by: John Parris --- .../tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php index 8056533885107..144bee2c928ca 100644 --- a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -43,5 +43,6 @@ public function test_wp_schedule_delete_old_privacy_export_files_is_installing() $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); wp_schedule_delete_old_privacy_export_files(); $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); + parent::tear_down(); } } From cad3d641f527e34e90ec9fb0f491decbc00e4c38 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Thu, 16 Jul 2026 14:27:10 -0400 Subject: [PATCH 7/8] Update tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php Co-authored-by: John Parris --- .../wpScheduleDeleteOldPrivacyExportFiles.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php index 144bee2c928ca..7f98a13d4fb67 100644 --- a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -45,4 +45,17 @@ public function test_wp_schedule_delete_old_privacy_export_files_is_installing() $this->assertFalse( wp_next_scheduled( 'wp_privacy_delete_old_export_files' ) ); parent::tear_down(); } + + /** + * 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' ) ); + } } From 65573a08e6f06b5f5a233f1105b38be74027d717 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Thu, 16 Jul 2026 14:42:46 -0400 Subject: [PATCH 8/8] Refactor test for scheduling privacy export files --- .../wpScheduleDeleteOldPrivacyExportFiles.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php index 7f98a13d4fb67..7d66d0a79fcea 100644 --- a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -46,16 +46,16 @@ public function test_wp_schedule_delete_old_privacy_export_files_is_installing() parent::tear_down(); } - /** - * 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' ) ); - } + /** + * 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' ) ); + } }