Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve inline comments per the documentation standards.

Includes minor code layout fixes for better readability.

See #48303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ajax/GetComments.php

    r46586 r47122  
    22
    33/**
    4  * Admin ajax functions to be tested
     4 * Admin Ajax functions to be tested.
    55 */
    66require_once( ABSPATH . 'wp-admin/includes/ajax-actions.php' );
    77
    88/**
    9  * Testing ajax comment functionality
     9 * Testing Ajax comment functionality.
    1010 *
    1111 * @package    WordPress
     
    4646    public function test_as_admin() {
    4747
    48         // Become an administrator
     48        // Become an administrator.
    4949        $this->_setRole( 'administrator' );
    5050
    51         // Set up a default request
     51        // Set up a default request.
    5252        $_POST['_ajax_nonce'] = wp_create_nonce( 'get-comments' );
    5353        $_POST['action']      = 'get-comments';
    5454        $_POST['p']           = self::$comment_post->ID;
    5555
    56         // Make the request
     56        // Make the request.
    5757        try {
    5858            $this->_handleAjax( 'get-comments' );
     
    6161        }
    6262
    63         // Get the response
     63        // Get the response.
    6464        $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA );
    6565
    66         // Check the meta data
     66        // Check the meta data.
    6767        $this->assertEquals( 1, (string) $xml->response[0]->comments['position'] );
    6868        $this->assertEquals( 0, (string) $xml->response[0]->comments['id'] );
    6969        $this->assertEquals( 'get-comments_0', (string) $xml->response['action'] );
    7070
    71         // Check the payload
     71        // Check the payload.
    7272        $this->assertNotEmpty( (string) $xml->response[0]->comments[0]->response_data );
    7373
    74         // And supplemental is empty
     74        // And supplemental is empty.
    7575        $this->assertEmpty( (string) $xml->response[0]->comments[0]->supplemental );
    7676    }
     
    8484    public function test_as_subscriber() {
    8585
    86         // Become a subscriber
     86        // Become a subscriber.
    8787        $this->_setRole( 'subscriber' );
    8888
    89         // Set up a default request
     89        // Set up a default request.
    9090        $_POST['_ajax_nonce'] = wp_create_nonce( 'get-comments' );
    9191        $_POST['action']      = 'get-comments';
    9292        $_POST['p']           = self::$comment_post->ID;
    9393
    94         // Make the request
     94        // Make the request.
    9595        $this->setExpectedException( 'WPAjaxDieStopException', '-1' );
    9696        $this->_handleAjax( 'get-comments' );
     
    105105    public function test_bad_nonce() {
    106106
    107         // Become an administrator
     107        // Become an administrator.
    108108        $this->_setRole( 'administrator' );
    109109
    110         // Set up a default request
     110        // Set up a default request.
    111111        $_POST['_ajax_nonce'] = wp_create_nonce( uniqid() );
    112112        $_POST['action']      = 'get-comments';
    113113        $_POST['p']           = self::$comment_post->ID;
    114114
    115         // Make the request
     115        // Make the request.
    116116        $this->setExpectedException( 'WPAjaxDieStopException', '-1' );
    117117        $this->_handleAjax( 'get-comments' );
     
    126126    public function test_invalid_post() {
    127127
    128         // Become an administrator
     128        // Become an administrator.
    129129        $this->_setRole( 'administrator' );
    130130
    131         // Set up a default request
     131        // Set up a default request.
    132132        $_POST['_ajax_nonce'] = wp_create_nonce( 'get-comments' );
    133133        $_POST['action']      = 'get-comments';
    134134        $_POST['p']           = 'b0rk';
    135135
    136         // Make the request
     136        // Make the request.
    137137        $this->setExpectedException( 'WPAjaxDieStopException', '-1' );
    138138        $this->_handleAjax( 'get-comments' );
     
    147147    public function test_post_with_no_comments() {
    148148
    149         // Become an administrator
     149        // Become an administrator.
    150150        $this->_setRole( 'administrator' );
    151151
    152         // Set up a default request
     152        // Set up a default request.
    153153        $_POST['_ajax_nonce'] = wp_create_nonce( 'get-comments' );
    154154        $_POST['action']      = 'get-comments';
    155155        $_POST['p']           = self::$no_comment_post->ID;
    156156
    157         // Make the request
     157        // Make the request.
    158158        $this->setExpectedException( 'WPAjaxDieStopException', '1' );
    159159        $this->_handleAjax( 'get-comments' );
Note: See TracChangeset for help on using the changeset viewer.