diff --git a/tests/phpunit/tests/link/permalinkAnchor.php b/tests/phpunit/tests/link/permalinkAnchor.php
new file mode 100644
index 0000000000000..5d9d05091804d
--- /dev/null
+++ b/tests/phpunit/tests/link/permalinkAnchor.php
@@ -0,0 +1,152 @@
+post->create(
+ array(
+ 'post_title' => 'Test Post Title',
+ )
+ );
+ }
+
+ /**
+ * Sets up the global $post object before each test method.
+ */
+ public function set_up() {
+ parent::set_up();
+ $GLOBALS['post'] = get_post( self::$post_id );
+ }
+
+ /**
+ * Tears down the global $post object after each test method.
+ */
+ public function tear_down() {
+ unset( $GLOBALS['post'] );
+ parent::tear_down();
+ }
+
+ /**
+ * Tests that permalink_anchor() outputs the post ID anchor by default when no argument is passed.
+ *
+ * @ticket 65819
+ */
+ public function test_permalink_anchor_default_mode_id() {
+ $expected = '';
+
+ $this->assertSame( $expected, get_echo( 'permalink_anchor' ) );
+ }
+
+ /**
+ * Tests that permalink_anchor() outputs the post ID anchor when explicitly passing 'id'.
+ *
+ * @ticket 65819
+ */
+ public function test_permalink_anchor_explicit_mode_id() {
+ $expected = '';
+
+ $this->assertSame( $expected, get_echo( 'permalink_anchor', array( 'id' ) ) );
+ }
+
+ /**
+ * Tests that permalink_anchor() handles mode case-insensitively for 'id'.
+ *
+ * @ticket 65819
+ */
+ public function test_permalink_anchor_mode_id_case_insensitive() {
+ $expected = '';
+
+ $this->assertSame( $expected, get_echo( 'permalink_anchor', array( 'ID' ) ) );
+ $this->assertSame( $expected, get_echo( 'permalink_anchor', array( 'Id' ) ) );
+ }
+
+ /**
+ * Tests that permalink_anchor() outputs the sanitized title anchor when passing 'title'.
+ *
+ * @ticket 65819
+ */
+ public function test_permalink_anchor_mode_title() {
+ $expected = '';
+
+ $this->assertSame( $expected, get_echo( 'permalink_anchor', array( 'title' ) ) );
+ }
+
+ /**
+ * Tests that permalink_anchor() handles mode case-insensitively for 'title'.
+ *
+ * @ticket 65819
+ */
+ public function test_permalink_anchor_mode_title_case_insensitive() {
+ $expected = '';
+
+ $this->assertSame( $expected, get_echo( 'permalink_anchor', array( 'TITLE' ) ) );
+ $this->assertSame( $expected, get_echo( 'permalink_anchor', array( 'Title' ) ) );
+ }
+
+ /**
+ * Tests that permalink_anchor() properly sanitizes titles containing special characters.
+ *
+ * @ticket 65819
+ */
+ public function test_permalink_anchor_mode_title_with_special_characters() {
+ $special_post_id = self::factory()->post->create(
+ array(
+ 'post_title' => 'Special Characters & Symbols: 100% Valid!',
+ )
+ );
+
+ $GLOBALS['post'] = get_post( $special_post_id );
+
+ $expected = '';
+
+ $this->assertSame( $expected, get_echo( 'permalink_anchor', array( 'title' ) ) );
+ }
+
+ /**
+ * Tests that permalink_anchor() falls back to id mode for unrecognized mode arguments.
+ *
+ * @ticket 65819
+ *
+ * @dataProvider data_unrecognized_modes
+ *
+ * @param string $mode Mode to pass.
+ */
+ public function test_permalink_anchor_unrecognized_mode_falls_back_to_id( $mode ) {
+ $expected = '';
+
+ $this->assertSame( $expected, get_echo( 'permalink_anchor', array( $mode ) ) );
+ }
+
+ /**
+ * Data provider for test_permalink_anchor_unrecognized_mode_falls_back_to_id().
+ *
+ * @return array[]
+ */
+ public static function data_unrecognized_modes() {
+ return array(
+ 'empty string' => array( '' ),
+ 'arbitrary string' => array( 'custom' ),
+ 'invalid mode slug' => array( 'slug' ),
+ 'numeric string mode' => array( '123' ),
+ );
+ }
+}