• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress develop tests

WordPress develop tests

WordPress develop tests a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / WP_Test_REST_Comments_Controller::test_create_comment_no_post_id() –

You appear to be a bot. Output may be restricted

Description

Usage

WP_Test_REST_Comments_Controller::test_create_comment_no_post_id();

Parameters

Returns

void

Source

File name: wordpress-develop-tests/phpunit/tests/rest-api/rest-comments-controller.php


Lines:

1 to 19 of 19
  public function test_create_comment_no_post_id() {
    wp_set_current_user( self::$admin_id );

    $params  = array(
      'author_name'  => 'Comic Book Guy',
      'author_email' => 'cbg@androidsdungeon.com',
      'author_url'   => 'http://androidsdungeon.com',
      'content'      => 'Worst Comment Ever!',
      'status'       => 'approved',
    );
    $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
    $request->add_header( 'content-type', 'application/json' );
    $request->set_body( wp_json_encode( $params ) );

    $response = rest_get_server()->dispatch( $request );

    $this->assertErrorResponse( 'rest_comment_invalid_post_id', $response, 403 );
  }
 

 View on GitHub

Published: 26th November 2019 | Last updated: 27th November 2019

Primary Sidebar

Information

Function name: WP_Test_REST_Comments_Controller::test_create_comment_no_post_id
Class ref: WP_Test_REST_Comments_Controller
Plugin ref: WordPress develop tests
Version: 5.3
Sourcefile: phpunit/tests/rest-api/rest-comments-controller.php
File ref: phpunit/tests/rest-api/rest-comments-controller.php
Deprecated?: No
API Letters: C,R,T,W

Footer

WordPress develop tests
WordPress develop tests
WordPress develop tests a2z
WordPress 5.6
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  develop.wp-a2z.org
© Copyright WordPress develop tests 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites