diff --git a/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php new file mode 100644 index 0000000000000..fb64d6f81f190 --- /dev/null +++ b/tests/phpunit/tests/functions/wpScheduleDeleteOldPrivacyExportFiles.php @@ -0,0 +1,67 @@ +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 ); + } + + /** + * 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' ) ); + } +}