Changeset 42343 for trunk/tests/phpunit/tests/ajax/ReplytoComment.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/ajax/ReplytoComment.php
r41980 r42343 18 18 /** 19 19 * A post with at least one comment 20 * 20 21 * @var mixed 21 22 */ … … 24 25 /** 25 26 * Draft post 27 * 26 28 * @var mixed 27 29 */ … … 32 34 public static function wpSetUpBeforeClass( $factory ) { 33 35 self::$comment_post = $factory->post->create_and_get(); 34 self::$comment_ids = $factory->comment->create_post_comments( self::$comment_post->ID, 5 );35 self::$draft_post = $factory->post->create_and_get( array( 'post_status' => 'draft' ) );36 self::$comment_ids = $factory->comment->create_post_comments( self::$comment_post->ID, 5 ); 37 self::$draft_post = $factory->post->create_and_get( array( 'post_status' => 'draft' ) ); 36 38 } 37 39 … … 44 46 * Reply as a privilged user (administrator) 45 47 * Expects test to pass 48 * 46 49 * @return void 47 50 */ … … 52 55 53 56 // Get a comment 54 $comments = get_comments( array( 55 'post_id' => self::$comment_post->ID 56 ) ); 57 $comment = array_pop( $comments ); 57 $comments = get_comments( 58 array( 59 'post_id' => self::$comment_post->ID, 60 ) 61 ); 62 $comment = array_pop( $comments ); 58 63 59 64 // Set up a default request … … 88 93 * Reply as a non-privileged user (subscriber) 89 94 * Expects test to fail 95 * 90 96 * @return void 91 97 */ … … 96 102 97 103 // Get a comment 98 $comments = get_comments( array( 99 'post_id' => self::$comment_post->ID 100 ) ); 101 $comment = array_pop( $comments ); 104 $comments = get_comments( 105 array( 106 'post_id' => self::$comment_post->ID, 107 ) 108 ); 109 $comment = array_pop( $comments ); 102 110 103 111 // Set up a default request … … 115 123 * Reply using a bad nonce 116 124 * Expects test to fail 125 * 117 126 * @return void 118 127 */ … … 123 132 124 133 // Get a comment 125 $comments = get_comments( array( 126 'post_id' => self::$comment_post->ID 127 ) ); 128 $comment = array_pop( $comments ); 134 $comments = get_comments( 135 array( 136 'post_id' => self::$comment_post->ID, 137 ) 138 ); 139 $comment = array_pop( $comments ); 129 140 130 141 // Set up a default request … … 142 153 * Reply to an invalid post 143 154 * Expects test to fail 155 * 144 156 * @return void 145 157 */ … … 162 174 * Reply to a draft post 163 175 * Expects test to fail 176 * 164 177 * @return void 165 178 */ … … 182 195 * Reply to a post with a simulated database failure 183 196 * Expects test to fail 197 * 184 198 * @global $wpdb 185 199 * @return void … … 205 219 $wpdb->suppress_errors( false ); 206 220 $this->fail(); 207 } catch ( WPAjaxDieStopException $e ) {221 } catch ( WPAjaxDieStopException $e ) { 208 222 $wpdb->suppress_errors( false ); 209 223 $this->assertContains( '1', $e->getMessage() ); … … 213 227 /** 214 228 * Block comments from being saved 229 * 215 230 * @param string $sql 216 231 * @return string … … 218 233 public function _block_comments( $sql ) { 219 234 global $wpdb; 220 if ( false !== strpos( $sql, $wpdb->comments ) && 0 === stripos( trim ( $sql ), 'INSERT INTO') ) {235 if ( false !== strpos( $sql, $wpdb->comments ) && 0 === stripos( trim( $sql ), 'INSERT INTO' ) ) { 221 236 return ''; 222 237 } … … 226 241 /** 227 242 * Raises WP_Error after Posted a new pre comment 243 * 228 244 * @ticket 39730 229 245 * @return void
Note: See TracChangeset
for help on using the changeset viewer.