From 25f8dc81c77fb702594a00bfa768be563d0e87d9 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Mon, 23 Oct 2023 14:26:21 -0400 Subject: [PATCH 01/14] test for wp_privacy_exports_url --- .../tests/functions/wpPrivacyExportsUrl.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/phpunit/tests/functions/wpPrivacyExportsUrl.php diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php new file mode 100644 index 0000000000000..23c2c19a12910 --- /dev/null +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -0,0 +1,42 @@ +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 136b3e237120315f732b239560bb7ba4663591f4 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Mon, 23 Oct 2023 15:27:59 -0400 Subject: [PATCH 02/14] test for wp_privacy_exports_url --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index 23c2c19a12910..b495a5a3a93b9 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -1,6 +1,6 @@ Date: Fri, 26 Jun 2026 14:02:55 -0400 Subject: [PATCH 03/14] Update tests/phpunit/tests/functions/wpPrivacyExportsUrl.php Co-authored-by: John Parris --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index b495a5a3a93b9..c7563bac75b80 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -6,7 +6,7 @@ * * @covers ::wp_privacy_exports_url */# -class Tests_functions_test_wp_privacy_exports_url extends WP_UnitTestCase { +class Tests_functions_test_wpPrivacyExportsUrl extends WP_UnitTestCase { /** * @ticket 59709 From daae6ae14c289f9c65d03a694679dc3d0d125ff2 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 14:03:02 -0400 Subject: [PATCH 04/14] Update tests/phpunit/tests/functions/wpPrivacyExportsUrl.php Co-authored-by: John Parris --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index c7563bac75b80..f0eb45dcc38bb 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -5,7 +5,7 @@ * @group functions.php * * @covers ::wp_privacy_exports_url - */# + */ class Tests_functions_test_wpPrivacyExportsUrl extends WP_UnitTestCase { /** From aebe057477250d0844166438bf1152ba04b6770a Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 14:03:10 -0400 Subject: [PATCH 05/14] Update tests/phpunit/tests/functions/wpPrivacyExportsUrl.php Co-authored-by: John Parris --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index f0eb45dcc38bb..f109b51527be6 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -25,7 +25,7 @@ public function test_wp_privacy_exports_url_filtered() { $expected_url = 'https://filtered.com/wp-personal-data-exports/'; $actual_url = wp_privacy_exports_url(); - $this->assertEquals( $expected_url, $actual_url ); + $this->assertSame( $expected_url, $actual_url ); remove_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); } From 982176516432333ec1315a8fc2543363e01e9da7 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 15:19:24 -0400 Subject: [PATCH 06/14] Update `test_wp_privacy_exports_url` to use `wp_upload_dir` for dynamic URL generation --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index b495a5a3a93b9..72f589bbc65b7 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -12,8 +12,8 @@ class Tests_functions_test_wp_privacy_exports_url extends WP_UnitTestCase { * @ticket 59709 */ public function test_wp_privacy_exports_url() { - - $this->assertEquals( 'http://example.org/wp-content/uploads/wp-personal-data-exports/', wp_privacy_exports_url() ); + $upload_dir = wp_upload_dir(); + $this->assertEquals( $upload_dir['baseurl'] . '/wp-personal-data-exports/', wp_privacy_exports_url() ); } /** From 340cf81a422779b449fa7253cf277d3eaec40963 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 16:37:10 -0400 Subject: [PATCH 07/14] Update wpPrivacyExportsUrl.php --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index 070c1907b36b7..ee3e9e7092df8 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -8,6 +8,11 @@ */ class Tests_functions_test_wpPrivacyExportsUrl extends WP_UnitTestCase { + public function tear_down(){ + + remove_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); + } + /** * @ticket 59709 */ @@ -26,8 +31,6 @@ public function test_wp_privacy_exports_url_filtered() { $expected_url = 'https://filtered.com/wp-personal-data-exports/'; $actual_url = wp_privacy_exports_url(); $this->assertSame( $expected_url, $actual_url ); - - remove_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); } /** From a2ab74e8480ee40ee4f1371a8f9262795699bb92 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 16:38:33 -0400 Subject: [PATCH 08/14] Change assertEquals to assertSame in test --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index ee3e9e7092df8..5a7284bacb48e 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -18,7 +18,7 @@ public function tear_down(){ */ public function test_wp_privacy_exports_url() { $upload_dir = wp_upload_dir(); - $this->assertEquals( $upload_dir['baseurl'] . '/wp-personal-data-exports/', wp_privacy_exports_url() ); + $this->assertSame( $upload_dir['baseurl'] . '/wp-personal-data-exports/', wp_privacy_exports_url() ); } /** From 0799382ea156a0da109553bfaa5fced59be9f60f Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Fri, 26 Jun 2026 16:40:17 -0400 Subject: [PATCH 09/14] Fix formatting of tear_down method --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index 5a7284bacb48e..85fe0575f6434 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -8,11 +8,11 @@ */ class Tests_functions_test_wpPrivacyExportsUrl extends WP_UnitTestCase { - public function tear_down(){ + public function tear_down() { remove_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); } - + /** * @ticket 59709 */ From c0eb98bf8ee68d76dbfed3493e505012412829cd Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Tue, 4 Aug 2026 13:43:39 -0400 Subject: [PATCH 10/14] Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../phpunit/tests/functions/wpPrivacyExportsUrl.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index 85fe0575f6434..fe42a6a9f5af0 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -6,11 +6,12 @@ * * @covers ::wp_privacy_exports_url */ -class Tests_functions_test_wpPrivacyExportsUrl extends WP_UnitTestCase { +class Tests_Functions_wpPrivacyExportsUrl extends WP_UnitTestCase { public function tear_down() { - remove_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); + + parent::tear_down(); } /** @@ -18,8 +19,7 @@ public function tear_down() { */ public function test_wp_privacy_exports_url() { $upload_dir = wp_upload_dir(); - $this->assertSame( $upload_dir['baseurl'] . '/wp-personal-data-exports/', wp_privacy_exports_url() ); - } + $this->assertSame( trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/', wp_privacy_exports_url() ); /** * @ticket 59709 @@ -34,9 +34,10 @@ public function test_wp_privacy_exports_url_filtered() { } /** - * Filter for test + * Filter for test. * - * @param string $url + * @param string $url Exports directory URL. + * @return string Filtered exports directory URL. */ public function filter_wp_privacy_exports_url( $url ) { From 9fc970ef5bd2fa8de625ef686f4f705285f2a0df Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Tue, 4 Aug 2026 13:49:25 -0400 Subject: [PATCH 11/14] Update wpPrivacyExportsUrl.php --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index fe42a6a9f5af0..a2441b7dde298 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -20,6 +20,7 @@ public function tear_down() { public function test_wp_privacy_exports_url() { $upload_dir = wp_upload_dir(); $this->assertSame( trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/', wp_privacy_exports_url() ); + } /** * @ticket 59709 From 8a127b00facd77c258cb5a7740ebbb46fb6afde4 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 5 Aug 2026 21:26:24 +0900 Subject: [PATCH 12/14] Tests: Correct the group annotation to `functions`. The `@group` annotation should reference the `functions` group rather than `functions.php`. --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index a2441b7dde298..4131b4f933c2b 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -2,7 +2,7 @@ /** * Tests for the wp_privacy_exports_url function. * - * @group functions.php + * @group functions * * @covers ::wp_privacy_exports_url */ From d501f656b6a1857603c9946a020802ad1a435f84 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 5 Aug 2026 21:27:34 +0900 Subject: [PATCH 13/14] Tests: Remove the redundant `tear_down()` method. Filters added with `add_filter()` are already removed by the base test case's `tear_down()`, so the override is unnecessary. --- tests/phpunit/tests/functions/wpPrivacyExportsUrl.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index 4131b4f933c2b..af05a9c11dbdf 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -8,12 +8,6 @@ */ class Tests_Functions_wpPrivacyExportsUrl extends WP_UnitTestCase { - public function tear_down() { - remove_filter( 'wp_privacy_exports_url', array( $this, 'filter_wp_privacy_exports_url' ) ); - - parent::tear_down(); - } - /** * @ticket 59709 */ From 4428823cfe8180e10282ef7a7ad019f5807351c8 Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Wed, 5 Aug 2026 21:27:52 +0900 Subject: [PATCH 14/14] Tests: Derive the filtered URL from the filter argument. The callback previously ignored its argument, so the value passed to the `wp_privacy_exports_url` filter was never verified. Deriving the return value from `$exports_url` closes that gap. --- .../phpunit/tests/functions/wpPrivacyExportsUrl.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php index af05a9c11dbdf..6891640d172b0 100644 --- a/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php +++ b/tests/phpunit/tests/functions/wpPrivacyExportsUrl.php @@ -20,22 +20,21 @@ public function test_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/'; + $upload_dir = wp_upload_dir(); + $expected_url = trailingslashit( $upload_dir['baseurl'] ) . 'filtered-exports/'; $actual_url = wp_privacy_exports_url(); $this->assertSame( $expected_url, $actual_url ); } /** - * Filter for test. + * Filters the personal data exports directory URL for tests. * - * @param string $url Exports directory URL. + * @param string $exports_url Default exports directory URL. * @return string Filtered exports directory URL. */ - public function filter_wp_privacy_exports_url( $url ) { - - return 'https://filtered.com/wp-personal-data-exports/'; + public function filter_wp_privacy_exports_url( $exports_url ) { + return str_replace( 'wp-personal-data-exports/', 'filtered-exports/', $exports_url ); } }