Make WordPress Core


Ignore:
Timestamp:
01/29/2020 12:43:23 AM (7 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/ReplytoComment.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
    … …  
    5151        public function test_as_admin() {
    5252
    53                 // Become an administrator
    54                 $this->_setRole( 'administrator' );
    55 
    56                 // Get a comment
     53                // Become an administrator.
     54                $this->_setRole( 'administrator' );
     55
     56                // Get a comment.
    5757                $comments = get_comments(
    5858                        array(
    … …  
    6262                $comment  = array_pop( $comments );
    6363
    64                 // Set up a default request
     64                // Set up a default request.
    6565                $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
    6666                $_POST['comment_ID']                  = $comment->comment_ID;
    … …  
    6868                $_POST['comment_post_ID']             = self::$comment_post->ID;
    6969
    70                 // Make the request
     70                // Make the request.
    7171                try {
    7272                        $this->_handleAjax( 'replyto-comment' );
    … …  
    7575                }
    7676
    77                 // Get the response
     77                // Get the response.
    7878                $xml = simplexml_load_string( $this->_last_response, 'SimpleXMLElement', LIBXML_NOCDATA );
    7979
    80                 // Check the meta data
     80                // Check the meta data.
    8181                $this->assertEquals( -1, (string) $xml->response[0]->comment['position'] );
    8282                $this->assertGreaterThan( 0, (int) $xml->response[0]->comment['id'] );
    8383                $this->assertNotEmpty( (string) $xml->response['action'] );
    8484
    85                 // Check the payload
     85                // Check the payload.
    8686                $this->assertNotEmpty( (string) $xml->response[0]->comment[0]->response_data );
    8787
    88                 // And supplemental is empty
     88                // And supplemental is empty.
    8989                $this->assertEmpty( (string) $xml->response[0]->comment[0]->supplemental );
    9090        }
    … …  
    9898        public function test_as_subscriber() {
    9999
    100                 // Become an administrator
     100                // Become an administrator.
    101101                $this->_setRole( 'subscriber' );
    102102
    103                 // Get a comment
     103                // Get a comment.
    104104                $comments = get_comments(
    105105                        array(
    … …  
    109109                $comment  = array_pop( $comments );
    110110
    111                 // Set up a default request
     111                // Set up a default request.
    112112                $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
    113113                $_POST['comment_ID']                  = $comment->comment_ID;
    … …  
    115115                $_POST['comment_post_ID']             = self::$comment_post->ID;
    116116
    117                 // Make the request
     117                // Make the request.
    118118                $this->setExpectedException( 'WPAjaxDieStopException', '-1' );
    119119                $this->_handleAjax( 'replyto-comment' );
    … …  
    128128        public function test_bad_nonce() {
    129129
    130                 // Become an administrator
    131                 $this->_setRole( 'administrator' );
    132 
    133                 // Get a comment
     130                // Become an administrator.
     131                $this->_setRole( 'administrator' );
     132
     133                // Get a comment.
    134134                $comments = get_comments(
    135135                        array(
    … …  
    139139                $comment  = array_pop( $comments );
    140140
    141                 // Set up a default request
     141                // Set up a default request.
    142142                $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( uniqid() );
    143143                $_POST['comment_ID']                  = $comment->comment_ID;
    … …  
    145145                $_POST['comment_post_ID']             = self::$comment_post->ID;
    146146
    147                 // Make the request
     147                // Make the request.
    148148                $this->setExpectedException( 'WPAjaxDieStopException', '-1' );
    149149                $this->_handleAjax( 'replyto-comment' );
    … …  
    158158        public function test_invalid_post() {
    159159
    160                 // Become an administrator
    161                 $this->_setRole( 'administrator' );
    162 
    163                 // Set up a default request
     160                // Become an administrator.
     161                $this->_setRole( 'administrator' );
     162
     163                // Set up a default request.
    164164                $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
    165165                $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    166166                $_POST['comment_post_ID']             = 123456789;
    167167
    168                 // Make the request
     168                // Make the request.
    169169                $this->setExpectedException( 'WPAjaxDieStopException', '-1' );
    170170                $this->_handleAjax( 'replyto-comment' );
    … …  
    179179        public function test_with_draft_post() {
    180180
    181                 // Become an administrator
    182                 $this->_setRole( 'administrator' );
    183 
    184                 // Set up a default request
     181                // Become an administrator.
     182                $this->_setRole( 'administrator' );
     183
     184                // Set up a default request.
    185185                $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
    186186                $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    187187                $_POST['comment_post_ID']             = self::$draft_post->ID;
    188188
    189                 // Make the request
     189                // Make the request.
    190190                $this->setExpectedException( 'WPAjaxDieStopException', 'ERROR: you are replying to a comment on a draft post.' );
    191191                $this->_handleAjax( 'replyto-comment' );
    … …  
    202202                global $wpdb;
    203203
    204                 // Become an administrator
    205                 $this->_setRole( 'administrator' );
    206 
    207                 // Set up a default request
    208                 $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
    209                 $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    210                 $_POST['comment_post_ID']             = self::$comment_post->ID;
    211 
    212                 // Block comments from being saved, simulate a DB error
     204                // Become an administrator.
     205                $this->_setRole( 'administrator' );
     206
     207                // Set up a default request.
     208                $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
     209                $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
     210                $_POST['comment_post_ID']             = self::$comment_post->ID;
     211
     212                // Block comments from being saved, simulate a DB error.
    213213                add_filter( 'query', array( $this, '_block_comments' ) );
    214214
    215                 // Make the request
     215                // Make the request.
    216216                try {
    217217                        $wpdb->suppress_errors( true );
    … …  
    247247        public function test_pre_comments_approved() {
    248248
    249                 // Become an administrator
    250                 $this->_setRole( 'administrator' );
    251 
    252                 // Set up a default request
    253                 $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
    254                 $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
    255                 $_POST['comment_post_ID']             = self::$comment_post->ID;
    256 
    257                 // Simulate filter check error
     249                // Become an administrator.
     250                $this->_setRole( 'administrator' );
     251
     252                // Set up a default request.
     253                $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' );
     254                $_POST['content']                     = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
     255                $_POST['comment_post_ID']             = self::$comment_post->ID;
     256
     257                // Simulate filter check error.
    258258                add_filter( 'pre_comment_approved', array( $this, '_pre_comment_approved_filter' ), 10, 2 );
    259259
    260                 // Make the request
     260                // Make the request.
    261261                $this->setExpectedException( 'WPAjaxDieStopException', 'pre_comment_approved filter fails for new comment' );
    262262                $this->_handleAjax( 'replyto-comment' );
Note: See TracChangeset for help on using the changeset viewer.