Codeception\Module\WPDb::haveCommentInDatabase PHP Method

haveCommentInDatabase() public method

Inserts a comment in the database.
public haveCommentInDatabase ( integer $comment_post_ID, array $data = [] ) : integer
$comment_post_ID integer The id of the post the comment refers to.
$data array The comment data overriding default and random generated values.
return integer The inserted comment `comment_id`
    public function haveCommentInDatabase($comment_post_ID, array $data = array())
    {
        if (!is_int($comment_post_ID)) {
            throw new \BadMethodCallException('Comment post ID must be int');
        }
        $has_meta = !empty($data['meta']);
        $meta = [];
        if ($has_meta) {
            $meta = $data['meta'];
            unset($data['meta']);
        }
        $comment = Comment::makeComment($comment_post_ID, $data);
        $tableName = $this->grabPrefixedTableNameFor('comments');
        $commentId = $this->haveInDatabase($tableName, $comment);
        if ($has_meta) {
            foreach ($meta as $key => $value) {
                $this->haveCommentMetaInDatabase($commentId, $key, $value);
            }
        }
        return $commentId;
    }
WPDb