Skip to content

Commit 1ffe0b8

Browse files
committed
Ensure URL list is de-deplicated.
1 parent 2661eb7 commit 1ffe0b8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/class-test-indexnow-pings.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,4 +388,27 @@ public function test_update_post_ping_urls_appends_correctly() {
388388
$last_ping_url = SimpleSearchSubmission\get_last_post_ping_url( $post_id );
389389
$this->assertSame( home_url( '/2025/first-update-test-post-publish/' ), $last_ping_url, 'Last ping URL should be the restored first updated URL.' );
390390
}
391+
392+
/**
393+
* Ensure URL list never contains duplicates.
394+
*/
395+
public function test_update_post_ping_urls_no_duplicates() {
396+
$post_id = self::$post_ids['publish'];
397+
398+
// Update the ping list (no need to actually ping).
399+
SimpleSearchSubmission\add_post_ping_urls( $post_id, array( home_url( '/2025/test-post-publish/' ) ) );
400+
SimpleSearchSubmission\add_post_ping_urls( $post_id, array( home_url( '/2025/test-post-publish-two/' ) ) );
401+
SimpleSearchSubmission\add_post_ping_urls( $post_id, array( home_url( '/2025/test-post-publish-two/' ) ) );
402+
SimpleSearchSubmission\add_post_ping_urls( $post_id, array( home_url( '/2025/test-post-publish/' ) ) );
403+
404+
// Ensure there are no duplicates.
405+
$ping_urls = SimpleSearchSubmission\get_post_ping_urls( $post_id );
406+
$this->assertCount( 2, $ping_urls, 'Ping URL list should not contain both URLs.' );
407+
408+
$expected = array(
409+
home_url( '/2025/test-post-publish-two/' ),
410+
home_url( '/2025/test-post-publish/' ),
411+
);
412+
$this->assertSame( $expected, $ping_urls, 'Ping URL list should not contain duplicates.' );
413+
}
391414
}

0 commit comments

Comments
 (0)