diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php new file mode 100644 index 0000000000000..ddf068e4d8475 --- /dev/null +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -0,0 +1,43 @@ +assertSame( $expected, wp_privacy_exports_dir() ); + } + + /** + * @ticket 59710 + */ + public function test_wp_privacy_exports_dir_filtered() { + add_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) ); + + $upload_dir = wp_upload_dir(); + $expected_dir = trailingslashit( $upload_dir['basedir'] ) . 'filtered-exports/'; + $actual_dir = wp_privacy_exports_dir(); + $this->assertSame( $expected_dir, $actual_dir ); + + remove_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) ); + } + + /** + * Filters the personal data exports directory for tests. + * + * @param string $exports_dir Default exports directory. + * @return string Filtered exports directory. + */ + public function filter_wp_privacy_exports_dir( $exports_dir ) { + return str_replace( 'wp-personal-data-exports/', 'filtered-exports/', $exports_dir ); + } +}