Changeset 48154 for trunk/tests/phpunit/tests/ajax/EditComment.php
- Timestamp:
- 06/24/2020 12:03:33 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ajax/EditComment.php
r47198 r48154 33 33 } 34 34 35 public function tearDown() { 36 remove_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); 37 parent::tearDown(); 38 } 39 35 40 /** 36 41 * Get comments as a privilged user (administrator) … … 128 133 129 134 /** 135 * @ticket 39732 136 */ 137 public function test_wp_update_comment_data_is_wp_error() { 138 // Become an administrator 139 $this->_setRole( 'administrator' ); 140 141 // Get a comment 142 $comments = get_comments( 143 array( 144 'post_id' => $this->_comment_post->ID, 145 ) 146 ); 147 $comment = array_pop( $comments ); 148 149 // Set up a default request 150 $_POST['_ajax_nonce-replyto-comment'] = wp_create_nonce( 'replyto-comment' ); 151 $_POST['comment_ID'] = $comment->comment_ID; 152 $_POST['content'] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'; 153 154 // Simulate filter check error 155 add_filter( 'wp_update_comment_data', array( $this, '_wp_update_comment_data_filter' ), 10, 3 ); 156 157 // Make the request 158 $this->setExpectedException( 'WPAjaxDieStopException', 'wp_update_comment_data filter fails for this comment.' ); 159 $this->_handleAjax( 'edit-comment' ); 160 } 161 162 /** 163 * Block comments from being updated by returning WP_Error 164 */ 165 public function _wp_update_comment_data_filter( $data, $comment, $commentarr ) { 166 return new WP_Error( 'comment_wrong', __( 'wp_update_comment_data filter fails for this comment.' ), 500 ); 167 } 168 169 /** 130 170 * Get comments as a non-privileged user (subscriber) 131 171 * Expects test to fail
Note: See TracChangeset
for help on using the changeset viewer.