Changeset 42343 for trunk/tests/phpunit/tests/ajax/DimComment.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ajax/DimComment.php
r42342 r42343 18 18 /** 19 19 * List of comments 20 * 20 21 * @var array 21 22 */ … … 27 28 public function setUp() { 28 29 parent::setUp(); 29 $post_id = self::factory()->post->create();30 $post_id = self::factory()->post->create(); 30 31 $this->_comments = self::factory()->comment->create_post_comments( $post_id, 15 ); 31 32 $this->_comments = array_map( 'get_comment', $this->_comments ); … … 36 37 */ 37 38 protected function _clear_post_action() { 38 unset( $_POST['id']);39 unset( $_POST['new']);39 unset( $_POST['id'] ); 40 unset( $_POST['new'] ); 40 41 $this->_last_response = ''; 41 42 } … … 48 49 * Test as a privilged user (administrator) 49 50 * Expects test to pass 51 * 50 52 * @param mixed $comment Comment object 51 53 * @return void … … 68 70 69 71 // Save the comment status 70 $prev_status 72 $prev_status = wp_get_comment_status( $comment->comment_ID ); 71 73 72 74 // Make the request … … 88 90 // Check the status 89 91 $current = wp_get_comment_status( $comment->comment_ID ); 90 if ( in_array( $prev_status, array( 'unapproved', 'spam') ) ) {92 if ( in_array( $prev_status, array( 'unapproved', 'spam' ) ) ) { 91 93 $this->assertEquals( 'approved', $current ); 92 94 } else { … … 96 98 // The total is calculated based on a page break -OR- a random number. Let's look for both possible outcomes 97 99 $comment_count = wp_count_comments( 0 ); 98 $recalc_total = $comment_count->total_comments;100 $recalc_total = $comment_count->total_comments; 99 101 100 102 // Delta is not specified, it will always be 1 lower than the request … … 102 104 103 105 // Check for either possible total 104 $this->assertTrue( in_array( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0] 106 $this->assertTrue( in_array( (int) $xml->response[0]->comment[0]->supplemental[0]->total[0], array( $total, $recalc_total ) ) ); 105 107 } 106 108 … … 108 110 * Test as a non-privileged user (subscriber) 109 111 * Expects test to fail 112 * 110 113 * @param mixed $comment Comment object 111 114 * @return void … … 135 138 * Test with a bad nonce 136 139 * Expects test to fail 140 * 137 141 * @param mixed $comment Comment object 138 142 * @return void … … 162 166 * Test with a bad id 163 167 * Expects test to fail 168 * 164 169 * @return void 165 170 */ … … 201 206 /** 202 207 * Dim a comment as an administrator (expects success) 208 * 203 209 * @return void 204 210 */ … … 211 217 /** 212 218 * Dim a comment as a subscriber (expects permission denied) 219 * 213 220 * @return void 214 221 */ … … 220 227 /** 221 228 * Dim a comment with no id 229 * 222 230 * @return void 223 231 */ … … 229 237 /** 230 238 * Dim a comment with a bad nonce 239 * 231 240 * @return void 232 241 */
Note: See TracChangeset
for help on using the changeset viewer.