From 25f8dc81c77fb702594a00bfa768be563d0e87d9 Mon Sep 17 00:00:00 2001 From: Paul Bearne Date: Mon, 23 Oct 2023 14:26:21 -0400 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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 */