Skip to content
This repository has been archived by the owner on Jan 2, 2020. It is now read-only.

arguments missing in CommentElement::create() #207

Closed
websupporter opened this issue May 11, 2018 · 0 comments · Fixed by #208
Closed

arguments missing in CommentElement::create() #207

websupporter opened this issue May 11, 2018 · 0 comments · Fixed by #208
Labels
Milestone

Comments

@websupporter
Copy link
Contributor

websupporter commented May 11, 2018

The WP CLI Arguments in CommentElement::create() are missing some arguments:

  • comment_approved
  • comment_karma
  • comment_type

Related issue

For #208

Expected behaviour

As an author of behat tests, I would like to be able to create comments in the database, where I can set for example the comment_approved to spam.

Current behaviour

Every comment falls back to the default comment_approved since the argument is missing.

Possible solution

        $wpcli_args = buildCLIArgs(
            array(
                'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_date',
                'comment_date_gmt', 'comment_parent', 'comment_post_ID', 'user_id', 'comment_agent', 'comment_author_IP',
                'comment_approved', 'comment_karma', 'comment_type',
            ),
            $args
        );

Steps to reproduce (for bugs)

<?php

use Behat\Behat\Context\Context;
use PaulGibbs\WordpressBehatExtension\Context\RawWordpressContext;

class CommentContext extends RawWordpressContext implements Context {

	/**
	 * @Given a comment exists with :arg1 by :arg2 with email :arg3, URL :arg4, IP :arg5 and status :arg6
	 */
	public function aCommentExistsWithByWithEmailIpAndStatus( $text, $name, $email, $url, $ip, $status ) {

		$args = [
			'comment_content' => $text,
			'comment_author' => $name,
			'comment_author_email' => $email,
			'comment_author_url' => $url,
			'comment_author_IP' => $ip,
			'comment_approved' => $status
		];
		$result = $this->getDriver()->comment->create($args);
		if( ! isset( $result->comment_ID ) ) {
			throw new RuntimeException('Could not create the comment');
		}
	}
}
@paulgibbs paulgibbs added this to the 1.3 milestone Jun 3, 2018
paulgibbs added a commit that referenced this issue Jun 3, 2018
…comment-create

Add missing arguments to CommentElement::create()

Props @websupporter 

Fixes #207
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants