From 6f7b31a4fe6b4e5867967f4c8fab26bfd46f2e51 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Mon, 23 Oct 2023 15:27:27 -0400 Subject: [PATCH 01/11] test for wp_privacy_exports_url --- .../tests/functions/wpPrivacyExportsDir.php | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/phpunit/tests/functions/wpPrivacyExportsDir.php diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php new file mode 100644 index 0000000000000..e0b994eae6009 --- /dev/null +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -0,0 +1,43 @@ +assertEquals( 'http://example.org/wp-content/uploads/wp-personal-data-exports/', wp_privacy_exports_url() ); + } + + /** + * @ticket 59709 + */ + public function test_wp_privacy_exports_url_filtered() { + + add_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); + + $expected_url = 'https://filtered.com/wp-personal-data-exports/'; + $actual_url = wp_privacy_exports_url(); + $this->assertEquals( $expected_url, $actual_url ); + + remove_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); + } + + /** + * Filter for test + * + * @param string $url + */ + public function filter_wp_privacy_exports_url( $url ) { + + return 'https://filtered.com/wp-personal-data-exports/'; + } +} + From 348746b85cd227578df1cc64e7bcf28ac85d7f78 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Mon, 23 Oct 2023 15:36:04 -0400 Subject: [PATCH 02/11] test for wp_privacy_exports_dir --- .../tests/functions/wpPrivacyExportsDir.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index e0b994eae6009..e5ad4e8ed92be 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -4,40 +4,40 @@ * * @group functions.php * - * @covers ::wp_privacy_exports_url + * @covers ::wp_privacy_exports_dir */# -class Tests_functions_test_wp_privacy_exports_url extends WP_UnitTestCase { +class Tests_functions_wp_privacy_exports_dir extends WP_UnitTestCase { /** - * @ticket 59709 + * @ticket 59710 */ - public function test_wp_privacy_exports_url() { + public function test_wp_privacy_exports_dir() { - $this->assertEquals( 'http://example.org/wp-content/uploads/wp-personal-data-exports/', wp_privacy_exports_url() ); + $this->assertEquals( '/var/www/src/wp-content/uploads/wp-personal-data-exports/', wp_privacy_exports_dir() ); } /** - * @ticket 59709 + * @ticket 59710 */ - public function test_wp_privacy_exports_url_filtered() { + public function test_wp_privacy_exports_dir_filtered() { - add_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); + add_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) ); - $expected_url = 'https://filtered.com/wp-personal-data-exports/'; - $actual_url = wp_privacy_exports_url(); + $expected_url = '/wp-personal-data-exports-url/'; + $actual_url = wp_privacy_exports_dir(); $this->assertEquals( $expected_url, $actual_url ); - remove_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); + remove_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) ); } /** * Filter for test * - * @param string $url + * @param string $dir */ - public function filter_wp_privacy_exports_url( $url ) { + public function filter_wp_privacy_exports_dir( $dir ) { - return 'https://filtered.com/wp-personal-data-exports/'; + return '/wp-personal-data-exports-url/'; } } From bcf8d6e9478b6725b69d7328bb886c1be68051ae Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Thu, 26 Oct 2023 18:14:42 -0400 Subject: [PATCH 03/11] Update wpPrivacyExportsDir.php --- tests/phpunit/tests/functions/wpPrivacyExportsDir.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index e5ad4e8ed92be..27e0aec996662 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -40,4 +40,3 @@ public function filter_wp_privacy_exports_dir( $dir ) { return '/wp-personal-data-exports-url/'; } } - From eab491cb73e523585360a2834bbbc57e2b9ce4ad Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 14:01:56 -0400 Subject: [PATCH 04/11] Update tests/phpunit/tests/functions/wpPrivacyExportsDir.php Co-authored-by: John Parris --- tests/phpunit/tests/functions/wpPrivacyExportsDir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index 27e0aec996662..b2f1feef7e88f 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -6,7 +6,7 @@ * * @covers ::wp_privacy_exports_dir */# -class Tests_functions_wp_privacy_exports_dir extends WP_UnitTestCase { +class Tests_Functions_wpPrivacyExportsDir extends WP_UnitTestCase { /** * @ticket 59710 From c5d25c2cfbaf7d4d7bf3c94638ad36393422e327 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 14:02:02 -0400 Subject: [PATCH 05/11] Update tests/phpunit/tests/functions/wpPrivacyExportsDir.php Co-authored-by: John Parris --- tests/phpunit/tests/functions/wpPrivacyExportsDir.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index b2f1feef7e88f..ddd1132c854b9 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -23,9 +23,9 @@ public function test_wp_privacy_exports_dir_filtered() { add_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) ); - $expected_url = '/wp-personal-data-exports-url/'; - $actual_url = wp_privacy_exports_dir(); - $this->assertEquals( $expected_url, $actual_url ); + $expected_dir = '/wp-personal-data-exports-dir/'; + $actual_dir = wp_privacy_exports_dir(); + $this->assertEquals( $expected_dir, $actual_dir ); remove_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) ); } From d91ec17a82df8f0263b99b432c0efc57c7a184c9 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 14:02:11 -0400 Subject: [PATCH 06/11] Update tests/phpunit/tests/functions/wpPrivacyExportsDir.php Co-authored-by: John Parris --- tests/phpunit/tests/functions/wpPrivacyExportsDir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index ddd1132c854b9..46860696d31df 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -5,7 +5,7 @@ * @group functions.php * * @covers ::wp_privacy_exports_dir - */# + */ class Tests_Functions_wpPrivacyExportsDir extends WP_UnitTestCase { /** From 29d8c54f8d188eaf45ebc36eaa110143131dc67d Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 14:02:19 -0400 Subject: [PATCH 07/11] Update tests/phpunit/tests/functions/wpPrivacyExportsDir.php Co-authored-by: John Parris --- tests/phpunit/tests/functions/wpPrivacyExportsDir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index 46860696d31df..14f61433fd768 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -37,6 +37,6 @@ public function test_wp_privacy_exports_dir_filtered() { */ public function filter_wp_privacy_exports_dir( $dir ) { - return '/wp-personal-data-exports-url/'; + return '/wp-personal-data-exports-dir/'; } } From 6f3d0e0c8c520989f9e2b10920586f7df209057f Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Wed, 29 Jul 2026 16:00:50 -0400 Subject: [PATCH 08/11] Apply suggestions from code review Co-authored-by: John Parris Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../tests/functions/wpPrivacyExportsDir.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index 14f61433fd768..826ef430cbc24 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -12,8 +12,9 @@ class Tests_Functions_wpPrivacyExportsDir extends WP_UnitTestCase { * @ticket 59710 */ public function test_wp_privacy_exports_dir() { - - $this->assertEquals( '/var/www/src/wp-content/uploads/wp-personal-data-exports/', wp_privacy_exports_dir() ); + $upload_dir = wp_upload_dir(); + $expected = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/'; + $this->assertSame( $expected, wp_privacy_exports_dir() ); } /** @@ -25,18 +26,18 @@ public function test_wp_privacy_exports_dir_filtered() { $expected_dir = '/wp-personal-data-exports-dir/'; $actual_dir = wp_privacy_exports_dir(); - $this->assertEquals( $expected_dir, $actual_dir ); + $this->assertSame( $expected_dir, $actual_dir ); remove_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) ); } /** - * Filter for test + * Filters the personal data exports directory for tests. * - * @param string $dir + * @param string $exports_dir Default exports directory. + * @return string Filtered exports directory. */ - public function filter_wp_privacy_exports_dir( $dir ) { - + public function filter_wp_privacy_exports_dir( $exports_dir ) { return '/wp-personal-data-exports-dir/'; } } From d233ec0bdd2d1452a3856b3e6ee0a94ba308fb0b Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Tue, 4 Aug 2026 13:27:57 -0400 Subject: [PATCH 09/11] Apply suggestions from code review Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com> --- tests/phpunit/tests/functions/wpPrivacyExportsDir.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index 826ef430cbc24..109c65e2d4b53 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -2,7 +2,7 @@ /** * Tests for the wp_privacy_exports_dir function. * - * @group functions.php + * @group functions * * @covers ::wp_privacy_exports_dir */ @@ -21,7 +21,6 @@ public function test_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' ) ); $expected_dir = '/wp-personal-data-exports-dir/'; From 84bfe3d00998e2f5e1fa43b1dc2c2a3c4f2beaf4 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Tue, 4 Aug 2026 13:28:25 -0400 Subject: [PATCH 10/11] Change exports directory path in filter function --- tests/phpunit/tests/functions/wpPrivacyExportsDir.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index 109c65e2d4b53..b349b35a39346 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -37,6 +37,6 @@ public function test_wp_privacy_exports_dir_filtered() { * @return string Filtered exports directory. */ public function filter_wp_privacy_exports_dir( $exports_dir ) { - return '/wp-personal-data-exports-dir/'; + return str_replace( 'wp-personal-data-exports/', 'filtered-exports/', $exports_dir ); } } From acfc63b079d73d6b33ad1c77f2288341d5b6b7fd Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 5 Aug 2026 16:56:48 +0900 Subject: [PATCH 11/11] Tests: Fix expected value in wp_privacy_exports_dir() filter test. The filter callback was changed to derive the directory from the value passed in via str_replace(), but the expected value was left as the old hardcoded path, causing the assertion to fail. Build the expected path from the uploads basedir so it matches what the callback returns. Co-Authored-By: Claude --- tests/phpunit/tests/functions/wpPrivacyExportsDir.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php index b349b35a39346..ddf068e4d8475 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsDir.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsDir.php @@ -23,7 +23,8 @@ public function test_wp_privacy_exports_dir() { public function test_wp_privacy_exports_dir_filtered() { add_filter( 'wp_privacy_exports_dir', array( $this, 'filter_wp_privacy_exports_dir' ) ); - $expected_dir = '/wp-personal-data-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 );