Code Duplication    Length = 8-9 lines in 3 locations

tests/phpunit/tests/comment.php 3 locations

@@ 633-641 (lines=9) @@
630
        wp_new_comment($data);
631
632
        // Check to see if a notification email was sent to the moderator `[email protected]`.
633
        if (isset($GLOBALS['phpmailer']->mock_sent)
634
            && ! empty($GLOBALS['phpmailer']->mock_sent)
635
            && WP_TESTS_EMAIL == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]
636
        ) {
637
            $email_sent_when_comment_added = true;
638
            reset_phpmailer_instance();
639
        } else {
640
            $email_sent_when_comment_added = false;
641
        }
642
643
        return $email_sent_when_comment_added;
644
    }
@@ 662-669 (lines=8) @@
659
        wp_set_comment_status($comment, 'approve');
660
661
        // Check to see if a notification email was sent to the post author `[email protected]`.
662
        if (isset($GLOBALS['phpmailer']->mock_sent)
663
            && ! empty($GLOBALS['phpmailer']->mock_sent)
664
            && '[email protected]' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0]
665
        ) {
666
            $email_sent_when_comment_approved = true;
667
        } else {
668
            $email_sent_when_comment_approved = false;
669
        }
670
        reset_phpmailer_instance();
671
672
        // Post authors are notified when a new comment is added to their post.
@@ 684-691 (lines=8) @@
681
        wp_new_comment($data);
682
683
        // Check to see if a notification email was sent to the post author `[email protected]`.
684
        if (isset($GLOBALS['phpmailer']->mock_sent) 
685
            && ! empty($GLOBALS['phpmailer']->mock_sent) 
686
            && '[email protected]' == $GLOBALS['phpmailer']->mock_sent[0]['to'][0][0] 
687
        ) {
688
            $email_sent_when_comment_added = true;
689
            reset_phpmailer_instance();
690
        } else {
691
            $email_sent_when_comment_added = false;
692
        }
693
694
        return $email_sent_when_comment_approved || $email_sent_when_comment_added;