diff --git a/tests/phpunit/tests/formatting/wpRelCallback.php b/tests/phpunit/tests/formatting/wpRelCallback.php
new file mode 100644
index 0000000000000..64034161ef4c0
--- /dev/null
+++ b/tests/phpunit/tests/formatting/wpRelCallback.php
@@ -0,0 +1,86 @@
+', 'href="https://example.com"' );
+ $actual = wp_rel_callback( $matches, 'nofollow' );
+
+ $this->assertSame( '', $actual );
+ }
+
+ /**
+ * Tests merging a new rel value with an existing rel attribute.
+ *
+ * @ticket 66610
+ */
+ public function test_wp_rel_callback_merges_with_existing_rel() {
+ $matches = array( '', 'href="https://example.com" rel="external"' );
+ $actual = wp_rel_callback( $matches, 'nofollow' );
+
+ $this->assertSame( '', $actual );
+ }
+
+ /**
+ * Tests that existing rel values are not duplicated.
+ *
+ * @ticket 66610
+ */
+ public function test_wp_rel_callback_does_not_duplicate_existing_rel() {
+ $matches = array( '', 'href="https://example.com" rel="nofollow ugc"' );
+ $actual = wp_rel_callback( $matches, 'nofollow' );
+
+ $this->assertSame( '', $actual );
+ }
+
+ /**
+ * Tests that nofollow is stripped when the link is internal.
+ *
+ * @ticket 66610
+ */
+ public function test_wp_rel_callback_removes_nofollow_for_internal_links() {
+ $home_url = home_url( '/test-page/' );
+ $matches = array( '', 'href="' . $home_url . '"' );
+ $actual = wp_rel_callback( $matches, 'nofollow' );
+
+ $this->assertSame( '', $actual );
+ }
+
+ /**
+ * Tests that internal links keep existing rel and can add other rel values like ugc.
+ *
+ * @ticket 66610
+ */
+ public function test_wp_rel_callback_preserves_other_rel_for_internal_links() {
+ $home_url = home_url( '/internal/' );
+ $matches = array( '', 'href="' . $home_url . '" rel="author"' );
+ $actual = wp_rel_callback( $matches, 'ugc' );
+
+ $this->assertSame( '', $actual );
+ }
+
+ /**
+ * Tests handling of valueless attributes on the anchor.
+ *
+ * @ticket 66610
+ */
+ public function test_wp_rel_callback_handles_valueless_attributes() {
+ $matches = array( '', 'href="https://example.com" download rel="opener"' );
+ $actual = wp_rel_callback( $matches, 'noreferrer' );
+
+ $this->assertStringContainsString( 'download', $actual );
+ $this->assertStringContainsString( 'rel="opener noreferrer"', $actual );
+ }
+}