Skip to content

Commit 617a1db

Browse files
committed
Comment connector test updated.
1 parent ab29de5 commit 617a1db

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/tests/connectors/test-class-connector-comments.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ public function test_callback_comment_duplicate_trigger() {
457457
'comment_content' => 'Lorem ipsum dolor...',
458458
'comment_author' => 'Jim Bean',
459459
'comment_author_email' => 'jim_bean@example.com',
460+
'comment_author_url' => '',
460461
'comment_author_IP' => '::1',
461462
'comment_post_ID' => $post_id,
462463
]
@@ -498,6 +499,22 @@ public function test_callback_comment_duplicate_trigger() {
498499
],
499500
true
500501
);
502+
$comment_id = wp_new_comment( $commentdata );
503+
504+
// Manually execute SQL query for duplicate comment ID. "$wpdb->last_result[0]" Undefined index error.
505+
$dupe = $wpdb->prepare(
506+
"SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_parent = %s AND comment_approved != 'trash' AND ( comment_author = %s AND comment_author_email = %s ) AND comment_content = %s LIMIT 1",
507+
wp_unslash( $commentdata['comment_post_ID'] ),
508+
wp_unslash( $commentdata['comment_parent'] ),
509+
wp_unslash( $commentdata['comment_author'] ),
510+
wp_unslash( $commentdata['comment_author_email'] ),
511+
wp_unslash( $commentdata['comment_content'] )
512+
);
513+
$dupe_id = $wpdb->get_var( $dupe );
514+
$this->assertSame( $comment_id, absint( $dupe_id ) );
515+
516+
// Run trigger action.
517+
do_action( 'comment_duplicate_trigger', $commentdata );
501518

502519
$this->assertFalse( 0 === did_action( 'wp_stream_test_callback_comment_duplicate_trigger' ) );
503520
}

0 commit comments

Comments
 (0)