Ticket #45934: 45934.diff
File 45934.diff, 38.9 KB (added by , 6 years ago) |
---|
-
phpcs.xml.dist
11 11 </properties> 12 12 </rule> 13 13 14 <rule ref="WordPress.NamingConventions.ValidVariableName"> 15 <properties> 16 <property name="customPropertiesWhitelist" type="array"> 17 <!-- From database structure queries --> 18 <element value="Collation"/> 19 <element value="Column_name"/> 20 <element value="Default"/> 21 <element value="Extra"/> 22 <element value="Field"/> 23 <element value="Index_type"/> 24 <element value="Key"/> 25 <element value="Key_name"/> 26 <element value="Msg_text"/> 27 <element value="Non_unique"/> 28 <element value="Null"/> 29 <element value="Sub_part"/> 30 <element value="Type"/> 31 <!-- From plugin/theme data --> 32 <element value="authorAndUri"/> 33 <element value="Name"/> 34 <element value="Version"/> 35 <!-- From the result of wp_xmlrpc_server::wp_getPageList() --> 36 <element value="dateCreated"/> 37 38 <!-- From DOMDocument --> 39 <element value="childNodes"/> 40 <element value="formatOutput"/> 41 <element value="nodeName"/> 42 <element value="nodeType"/> 43 <element value="parentNode"/> 44 <element value="preserveWhiteSpace"/> 45 <element value="textContent"/> 46 <!-- From PHPMailer --> 47 <element value="AltBody"/> 48 <element value="Body"/> 49 <element value="CharSet"/> 50 <element value="ContentType"/> 51 <element value="Encoding"/> 52 <element value="Hostname"/> 53 <element value="mailHeader"/> 54 <element value="MIMEBody"/> 55 <element value="MIMEHeader"/> 56 <element value="Sender"/> 57 <element value="Subject"/> 58 <!-- From PHPUnit_Util_Getopt --> 59 <element value="longOptions"/> 60 <!-- From POP3 --> 61 <element value="ERROR"/> 62 <!-- From ZipArchive --> 63 <element value="numFiles"/> 64 </property> 65 </properties> 66 </rule> 67 14 68 <arg name="extensions" value="php"/> 15 69 16 70 <!-- Strip the filepaths down to the relevant bit. --> -
src/wp-includes/class-wp-comment-query.php
555 555 preg_split( '/[,\s]/', $this->query_vars['orderby'] ); 556 556 557 557 $orderby_array = array(); 558 $found_orderby_comment_ ID= false;558 $found_orderby_comment_id = false; 559 559 foreach ( $ordersby as $_key => $_value ) { 560 560 if ( ! $_value ) { 561 561 continue; … … 569 569 $_order = $_value; 570 570 } 571 571 572 if ( ! $found_orderby_comment_ ID&& in_array( $_orderby, array( 'comment_ID', 'comment__in' ) ) ) {573 $found_orderby_comment_ ID= true;572 if ( ! $found_orderby_comment_id && in_array( $_orderby, array( 'comment_ID', 'comment__in' ) ) ) { 573 $found_orderby_comment_id = true; 574 574 } 575 575 576 576 $parsed = $this->parse_orderby( $_orderby ); … … 593 593 } 594 594 595 595 // To ensure determinate sorting, always include a comment_ID clause. 596 if ( ! $found_orderby_comment_ ID) {597 $comment_ ID_order = '';596 if ( ! $found_orderby_comment_id ) { 597 $comment_id_order = ''; 598 598 599 599 // Inherit order from comment_date or comment_date_gmt, if available. 600 600 foreach ( $orderby_array as $orderby_clause ) { 601 601 if ( preg_match( '/comment_date(?:_gmt)*\ (ASC|DESC)/', $orderby_clause, $match ) ) { 602 $comment_ ID_order = $match[1];602 $comment_id_order = $match[1]; 603 603 break; 604 604 } 605 605 } 606 606 607 607 // If no date-related order is available, use the date from the first available clause. 608 if ( ! $comment_ ID_order ) {608 if ( ! $comment_id_order ) { 609 609 foreach ( $orderby_array as $orderby_clause ) { 610 610 if ( false !== strpos( 'ASC', $orderby_clause ) ) { 611 $comment_ ID_order = 'ASC';611 $comment_id_order = 'ASC'; 612 612 } else { 613 $comment_ ID_order = 'DESC';613 $comment_id_order = 'DESC'; 614 614 } 615 615 616 616 break; … … 618 618 } 619 619 620 620 // Default to DESC. 621 if ( ! $comment_ ID_order ) {622 $comment_ ID_order = 'DESC';621 if ( ! $comment_id_order ) { 622 $comment_id_order = 'DESC'; 623 623 } 624 624 625 $orderby_array[] = "$wpdb->comments.comment_ID $comment_ ID_order";625 $orderby_array[] = "$wpdb->comments.comment_ID $comment_id_order"; 626 626 } 627 627 628 628 $orderby = implode( ', ', $orderby_array ); -
tests/phpunit/tests/avatar.php
103 103 $this->assertEquals( $url, $url2 ); 104 104 } 105 105 106 protected $fake URL;106 protected $fake_url; 107 107 /** 108 108 * @ticket 21195 109 109 */ 110 110 public function test_pre_get_avatar_url_filter() { 111 $this->fake URL= 'haha wat';111 $this->fake_url = 'haha wat'; 112 112 113 113 add_filter( 'pre_get_avatar_data', array( $this, 'pre_get_avatar_url_filter' ), 10, 1 ); 114 114 $url = get_avatar_url( 1 ); 115 115 remove_filter( 'pre_get_avatar_data', array( $this, 'pre_get_avatar_url_filter' ), 10 ); 116 116 117 $this->assertEquals( $url, $this->fake URL);117 $this->assertEquals( $url, $this->fake_url ); 118 118 } 119 119 public function pre_get_avatar_url_filter( $args ) { 120 $args['url'] = $this->fake URL;120 $args['url'] = $this->fake_url; 121 121 return $args; 122 122 } 123 123 … … 125 125 * @ticket 21195 126 126 */ 127 127 public function test_get_avatar_url_filter() { 128 $this->fake URL= 'omg lol';128 $this->fake_url = 'omg lol'; 129 129 130 130 add_filter( 'get_avatar_url', array( $this, 'get_avatar_url_filter' ), 10, 1 ); 131 131 $url = get_avatar_url( 1 ); 132 132 remove_filter( 'get_avatar_url', array( $this, 'get_avatar_url_filter' ), 10 ); 133 133 134 $this->assertEquals( $url, $this->fake URL);134 $this->assertEquals( $url, $this->fake_url ); 135 135 } 136 136 public function get_avatar_url_filter( $url ) { 137 return $this->fake URL;137 return $this->fake_url; 138 138 } 139 139 140 140 /** … … 207 207 } 208 208 209 209 210 protected $fake IMG;210 protected $fake_img; 211 211 /** 212 212 * @ticket 21195 213 213 */ 214 214 public function test_pre_get_avatar_filter() { 215 $this->fake IMG= 'YOU TOO?!';215 $this->fake_img = 'YOU TOO?!'; 216 216 217 217 add_filter( 'pre_get_avatar', array( $this, 'pre_get_avatar_filter' ), 10, 1 ); 218 218 $img = get_avatar( 1 ); 219 219 remove_filter( 'pre_get_avatar', array( $this, 'pre_get_avatar_filter' ), 10 ); 220 220 221 $this->assertEquals( $img, $this->fake IMG);221 $this->assertEquals( $img, $this->fake_img ); 222 222 } 223 223 public function pre_get_avatar_filter( $img ) { 224 return $this->fake IMG;224 return $this->fake_img; 225 225 } 226 226 227 227 /** 228 228 * @ticket 21195 229 229 */ 230 230 public function test_get_avatar_filter() { 231 $this->fake URL= 'YA RLY';231 $this->fake_url = 'YA RLY'; 232 232 233 233 add_filter( 'get_avatar', array( $this, 'get_avatar_filter' ), 10, 1 ); 234 234 $img = get_avatar( 1 ); 235 235 remove_filter( 'get_avatar', array( $this, 'get_avatar_filter' ), 10 ); 236 236 237 $this->assertEquals( $img, $this->fake URL);237 $this->assertEquals( $img, $this->fake_url ); 238 238 } 239 239 public function get_avatar_filter( $img ) { 240 return $this->fake URL;240 return $this->fake_url; 241 241 } 242 242 243 243 /** -
tests/phpunit/tests/functions.php
7 7 function test_wp_parse_args_object() { 8 8 $x = new MockClass; 9 9 $x->_baba = 5; 10 $x->yZ = 'baba'; 10 $x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar 11 11 $x->a = array( 5, 111, 'x' ); 12 12 $this->assertEquals( 13 13 array( … … 43 43 function test_wp_parse_args_defaults() { 44 44 $x = new MockClass; 45 45 $x->_baba = 5; 46 $x->yZ = 'baba'; 46 $x->yZ = 'baba'; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar 47 47 $x->a = array( 5, 111, 'x' ); 48 48 $d = array( 'pu' => 'bu' ); 49 49 $this->assertEquals( -
tests/phpunit/tests/general/wpError.php
14 14 * 15 15 * @var WP_Error 16 16 */ 17 public $ WP_Error;17 public $wp_error; 18 18 19 19 /** 20 20 * Set up. … … 22 22 public function setUp() { 23 23 parent::setUp(); 24 24 25 $this-> WP_Error = new WP_Error();25 $this->wp_error = new WP_Error(); 26 26 } 27 27 28 28 public function test_WP_Error_should_be_of_type_WP_Error() { 29 $this->assertWPError( $this-> WP_Error );29 $this->assertWPError( $this->wp_error ); 30 30 } 31 31 32 32 public function test_WP_Error_with_default_empty_parameters_should_add_no_errors() { 33 $this->assertEmpty( $this-> WP_Error->errors );33 $this->assertEmpty( $this->wp_error->errors ); 34 34 } 35 35 36 36 public function test_WP_Error_with_empty_code_should_add_no_code() { 37 $this->assertSame( '', $this-> WP_Error->get_error_code() );37 $this->assertSame( '', $this->wp_error->get_error_code() ); 38 38 } 39 39 40 40 public function test_WP_Error_with_empty_code_should_add_no_message() { 41 $this->assertSame( '', $this-> WP_Error->get_error_message() );41 $this->assertSame( '', $this->wp_error->get_error_message() ); 42 42 } 43 43 44 44 public function test_WP_Error_with_empty_code_should_add_no_error_data() { 45 $this->assertEmpty( $this-> WP_Error->error_data );45 $this->assertEmpty( $this->wp_error->error_data ); 46 46 } 47 47 48 48 public function test_WP_Error_with_code_and_empty_message_should_add_error_with_that_code() { … … 103 103 * @covers ::get_error_codes() 104 104 */ 105 105 public function test_get_error_codes_with_no_errors_should_return_empty_array() { 106 $this->assertEmpty( $this-> WP_Error->get_error_codes() );106 $this->assertEmpty( $this->wp_error->get_error_codes() ); 107 107 } 108 108 109 109 /** 110 110 * @covers ::get_error_codes() 111 111 */ 112 112 public function test_get_error_codes_with_one_error_should_return_an_array_with_only_that_code() { 113 $this-> WP_Error->add( 'code', 'message' );113 $this->wp_error->add( 'code', 'message' ); 114 114 115 $this->assertEqualSets( array( 'code' ), $this-> WP_Error->get_error_codes() );115 $this->assertEqualSets( array( 'code' ), $this->wp_error->get_error_codes() ); 116 116 } 117 117 118 118 /** 119 119 * @covers ::get_error_codes() 120 120 */ 121 121 public function test_get_error_codes_with_multiple_errors_should_return_an_array_of_those_codes() { 122 $this-> WP_Error->add( 'code', 'message' );123 $this-> WP_Error->add( 'code2', 'message2' );122 $this->wp_error->add( 'code', 'message' ); 123 $this->wp_error->add( 'code2', 'message2' ); 124 124 125 125 $expected = array( 'code', 'code2' ); 126 126 127 $this->assertEqualSets( $expected, $this-> WP_Error->get_error_codes() );127 $this->assertEqualSets( $expected, $this->wp_error->get_error_codes() ); 128 128 } 129 129 130 130 /** 131 131 * @covers ::get_error_code() 132 132 */ 133 133 public function test_get_error_code_with_no_errors_should_return_an_empty_string() { 134 $this->assertSame( '', $this-> WP_Error->get_error_code() );134 $this->assertSame( '', $this->wp_error->get_error_code() ); 135 135 } 136 136 137 137 /** 138 138 * @covers ::get_error_code() 139 139 */ 140 140 public function test_get_error_code_with_one_error_should_return_that_error_code() { 141 $this-> WP_Error->add( 'code', 'message' );141 $this->wp_error->add( 'code', 'message' ); 142 142 143 $this->assertSame( 'code', $this-> WP_Error->get_error_code() );143 $this->assertSame( 'code', $this->wp_error->get_error_code() ); 144 144 } 145 145 146 146 /** 147 147 * @covers ::get_error_code() 148 148 */ 149 149 public function test_get_error_code_with_multiple_errors_should_return_only_the_first_error_code() { 150 $this-> WP_Error->add( 'code', 'message' );151 $this-> WP_Error->add( 'code2', 'message2' );150 $this->wp_error->add( 'code', 'message' ); 151 $this->wp_error->add( 'code2', 'message2' ); 152 152 153 $this->assertSame( 'code', $this-> WP_Error->get_error_code() );153 $this->assertSame( 'code', $this->wp_error->get_error_code() ); 154 154 } 155 155 156 156 /** 157 157 * @covers ::get_error_messages() 158 158 */ 159 159 public function test_get_error_messages_with_empty_code_and_no_errors_should_return_an_empty_array() { 160 $this->assertEmpty( $this-> WP_Error->get_error_messages() );160 $this->assertEmpty( $this->wp_error->get_error_messages() ); 161 161 } 162 162 163 163 /** 164 164 * @covers ::get_error_messages() 165 165 */ 166 166 public function test_get_error_messages_with_empty_code_one_error_should_return_an_array_with_that_message() { 167 $this-> WP_Error->add( 'code', 'message' );167 $this->wp_error->add( 'code', 'message' ); 168 168 169 $this->assertEqualSets( array( 'message' ), $this-> WP_Error->get_error_messages() );169 $this->assertEqualSets( array( 'message' ), $this->wp_error->get_error_messages() ); 170 170 } 171 171 172 172 /** 173 173 * @covers ::get_error_messages() 174 174 */ 175 175 public function test_get_error_messages_with_empty_code_multiple_errors_should_return_an_array_of_messages() { 176 $this-> WP_Error->add( 'code', 'message' );177 $this-> WP_Error->add( 'code2', 'message2' );176 $this->wp_error->add( 'code', 'message' ); 177 $this->wp_error->add( 'code2', 'message2' ); 178 178 179 $this->assertEqualSets( array( 'message', 'message2' ), $this-> WP_Error->get_error_messages() );179 $this->assertEqualSets( array( 'message', 'message2' ), $this->wp_error->get_error_messages() ); 180 180 } 181 181 182 182 /** 183 183 * @covers ::get_error_messages() 184 184 */ 185 185 public function test_get_error_messages_with_an_invalid_code_should_return_an_empty_array() { 186 $this->assertEmpty( $this-> WP_Error->get_error_messages( 'code' ) );186 $this->assertEmpty( $this->wp_error->get_error_messages( 'code' ) ); 187 187 } 188 188 189 189 /** 190 190 * @covers ::get_error_messages() 191 191 */ 192 192 public function test_get_error_messages_with_one_error_should_return_an_array_with_that_message() { 193 $this-> WP_Error->add( 'code', 'message' );193 $this->wp_error->add( 'code', 'message' ); 194 194 195 $this->assertEqualSets( array( 'message' ), $this-> WP_Error->get_error_messages( 'code' ) );195 $this->assertEqualSets( array( 'message' ), $this->wp_error->get_error_messages( 'code' ) ); 196 196 } 197 197 198 198 /** 199 199 * @covers ::get_error_messages() 200 200 */ 201 201 public function test_get_error_messages_with_multiple_errors_same_code_should_return_an_array_with_all_messages() { 202 $this-> WP_Error->add( 'code', 'message' );203 $this-> WP_Error->add( 'code', 'message2' );202 $this->wp_error->add( 'code', 'message' ); 203 $this->wp_error->add( 'code', 'message2' ); 204 204 205 $this->assertequalSets( array( 'message', 'message2' ), $this-> WP_Error->get_error_messages( 'code' ) );205 $this->assertequalSets( array( 'message', 'message2' ), $this->wp_error->get_error_messages( 'code' ) ); 206 206 } 207 207 208 208 /** 209 209 * @covers ::get_error_message() 210 210 */ 211 211 public function test_get_error_message_with_empty_code_and_no_errors_should_return_an_empty_string() { 212 $this->assertSame( '', $this-> WP_Error->get_error_message() );212 $this->assertSame( '', $this->wp_error->get_error_message() ); 213 213 } 214 214 215 215 /** 216 216 * @covers ::get_error_message() 217 217 */ 218 218 public function test_get_error_message_with_empty_code_and_one_error_should_return_that_message() { 219 $this-> WP_Error->add( 'code', 'message' );219 $this->wp_error->add( 'code', 'message' ); 220 220 221 $this->assertSame( 'message', $this-> WP_Error->get_error_message() );221 $this->assertSame( 'message', $this->wp_error->get_error_message() ); 222 222 } 223 223 224 224 /** 225 225 * @covers ::get_error_message() 226 226 */ 227 227 public function test_get_error_message_with_empty_code_and_multiple_errors_should_return_the_first_message() { 228 $this-> WP_Error->add( 'code', 'message' );229 $this-> WP_Error->add( 'code2', 'message2' );228 $this->wp_error->add( 'code', 'message' ); 229 $this->wp_error->add( 'code2', 'message2' ); 230 230 231 $this->assertSame( 'message', $this-> WP_Error->get_error_message() );231 $this->assertSame( 'message', $this->wp_error->get_error_message() ); 232 232 } 233 233 234 234 /** 235 235 * @covers ::get_error_message() 236 236 */ 237 237 public function test_get_error_message_with_empty_code_and_multiple_errors_multiple_codes_should_return_the_first_message() { 238 $this-> WP_Error->add( 'code', 'message' );239 $this-> WP_Error->add( 'code2', 'message2' );240 $this-> WP_Error->add( 'code', 'message2' );238 $this->wp_error->add( 'code', 'message' ); 239 $this->wp_error->add( 'code2', 'message2' ); 240 $this->wp_error->add( 'code', 'message2' ); 241 241 242 $this->assertSame( 'message', $this-> WP_Error->get_error_message() );242 $this->assertSame( 'message', $this->wp_error->get_error_message() ); 243 243 } 244 244 245 245 /** 246 246 * @covers ::get_error_message() 247 247 */ 248 248 public function test_get_error_message_with_invalid_code_and_no_errors_should_return_empty_string() { 249 $this->assertSame( '', $this-> WP_Error->get_error_message( 'invalid' ) );249 $this->assertSame( '', $this->wp_error->get_error_message( 'invalid' ) ); 250 250 } 251 251 252 252 /** 253 253 * @covers ::get_error_message() 254 254 */ 255 255 public function test_get_error_message_with_invalid_code_and_one_error_should_return_an_empty_string() { 256 $this-> WP_Error->add( 'code', 'message' );256 $this->wp_error->add( 'code', 'message' ); 257 257 258 $this->assertSame( '', $this-> WP_Error->get_error_message( 'invalid' ) );258 $this->assertSame( '', $this->wp_error->get_error_message( 'invalid' ) ); 259 259 } 260 260 261 261 /** 262 262 * @covers ::get_error_message() 263 263 */ 264 264 public function test_get_error_message_with_invalid_code_and_multiple_errors_should_return_an_empty_string() { 265 $this-> WP_Error->add( 'code', 'message' );266 $this-> WP_Error->add( 'code2', 'message2' );265 $this->wp_error->add( 'code', 'message' ); 266 $this->wp_error->add( 'code2', 'message2' ); 267 267 268 $this->assertSame( '', $this-> WP_Error->get_error_message( 'invalid' ) );268 $this->assertSame( '', $this->wp_error->get_error_message( 'invalid' ) ); 269 269 } 270 270 271 271 /** 272 272 * @covers ::get_error_data() 273 273 */ 274 274 public function test_get_error_data_with_empty_code_and_no_errors_should_evaluate_as_null() { 275 $this->assertSame( null, $this-> WP_Error->get_error_data() );275 $this->assertSame( null, $this->wp_error->get_error_data() ); 276 276 } 277 277 278 278 /** 279 279 * @covers ::get_error_data() 280 280 */ 281 281 public function test_get_error_data_with_empty_code_one_error_no_data_should_evaluate_as_null() { 282 $this-> WP_Error->add( 'code', 'message' );282 $this->wp_error->add( 'code', 'message' ); 283 283 284 $this->assertSame( null, $this-> WP_Error->get_error_data() );284 $this->assertSame( null, $this->wp_error->get_error_data() ); 285 285 } 286 286 287 287 /** 288 288 * @covers ::get_error_data() 289 289 */ 290 290 public function test_get_error_data_with_empty_code_multiple_errors_no_data_should_evaluate_as_null() { 291 $this-> WP_Error->add( 'code', 'message' );292 $this-> WP_Error->add( 'code2', 'message2' );291 $this->wp_error->add( 'code', 'message' ); 292 $this->wp_error->add( 'code2', 'message2' ); 293 293 294 $this->assertSame( null, $this-> WP_Error->get_error_data() );294 $this->assertSame( null, $this->wp_error->get_error_data() ); 295 295 } 296 296 297 297 /** … … 299 299 */ 300 300 public function test_get_error_data_with_empty_code_and_one_error_with_data_should_return_that_data() { 301 301 $expected = array( 'data-key' => 'data-value' ); 302 $this-> WP_Error->add( 'code', 'message', $expected );302 $this->wp_error->add( 'code', 'message', $expected ); 303 303 304 $this->assertEqualSetsWithIndex( $expected, $this-> WP_Error->get_error_data() );304 $this->assertEqualSetsWithIndex( $expected, $this->wp_error->get_error_data() ); 305 305 } 306 306 307 307 /** … … 309 309 */ 310 310 public function test_get_error_data_with_empty_code_and_multiple_errors_different_codes_should_return_the_last_data_of_the_first_code() { 311 311 $expected = array( 'data-key' => 'data-value' ); 312 $this-> WP_Error->add( 'code', 'message', $expected );313 $this-> WP_Error->add( 'code2', 'message2', 'data2' );312 $this->wp_error->add( 'code', 'message', $expected ); 313 $this->wp_error->add( 'code2', 'message2', 'data2' ); 314 314 315 $this->assertEqualSetsWithIndex( $expected, $this-> WP_Error->get_error_data() );315 $this->assertEqualSetsWithIndex( $expected, $this->wp_error->get_error_data() ); 316 316 } 317 317 318 318 /** 319 319 * @covers ::get_error_data() 320 320 */ 321 321 public function test_get_error_data_with_empty_code_and_multiple_errors_same_code_should_return_the_last_data_of_the_first_code() { 322 $this-> WP_Error->add( 'code', 'message', 'data' );323 $this-> WP_Error->add( 'code', 'message2', 'data2' );324 $this-> WP_Error->add( 'code2', 'message2', 'data3' );322 $this->wp_error->add( 'code', 'message', 'data' ); 323 $this->wp_error->add( 'code', 'message2', 'data2' ); 324 $this->wp_error->add( 'code2', 'message2', 'data3' ); 325 325 326 $this->assertSame( 'data2', $this-> WP_Error->get_error_data() );326 $this->assertSame( 'data2', $this->wp_error->get_error_data() ); 327 327 } 328 328 329 329 /** 330 330 * @covers ::get_error_data() 331 331 */ 332 332 public function test_get_error_data_with_code_and_no_errors_should_evaluate_as_null() { 333 $this->assertSame( null, $this-> WP_Error->get_error_data( 'code' ) );333 $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) ); 334 334 } 335 335 336 336 /** 337 337 * @covers ::get_error_data() 338 338 */ 339 339 public function test_get_error_data_with_code_and_one_error_with_no_data_should_evaluate_as_null() { 340 $this-> WP_Error->add( 'code', 'message' );340 $this->wp_error->add( 'code', 'message' ); 341 341 342 $this->assertSame( null, $this-> WP_Error->get_error_data( 'code' ) );342 $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) ); 343 343 } 344 344 345 345 /** … … 347 347 */ 348 348 public function test_get_error_data_with_code_and_one_error_with_data_should_return_that_data() { 349 349 $expected = array( 'data-key' => 'data-value' ); 350 $this-> WP_Error->add( 'code', 'message', $expected );350 $this->wp_error->add( 'code', 'message', $expected ); 351 351 352 $this->assertEqualSetsWithIndex( $expected, $this-> WP_Error->get_error_data( 'code' ) );352 $this->assertEqualSetsWithIndex( $expected, $this->wp_error->get_error_data( 'code' ) ); 353 353 } 354 354 355 355 /** … … 357 357 */ 358 358 public function test_get_error_data_with_code_and_multiple_errors_different_codes_should_return_the_last_stored_data_of_the_code() { 359 359 $expected = array( 'data3' ); 360 $this-> WP_Error->add( 'code', 'message', 'data' );361 $this-> WP_Error->add( 'code2', 'message2', 'data2' );362 $this-> WP_Error->add( 'code', 'message3', $expected );360 $this->wp_error->add( 'code', 'message', 'data' ); 361 $this->wp_error->add( 'code2', 'message2', 'data2' ); 362 $this->wp_error->add( 'code', 'message3', $expected ); 363 363 364 $this->assertEqualSetsWithIndex( $expected, $this-> WP_Error->get_error_data( 'code' ) );364 $this->assertEqualSetsWithIndex( $expected, $this->wp_error->get_error_data( 'code' ) ); 365 365 } 366 366 367 367 /** 368 368 * @covers ::get_error_data() 369 369 */ 370 370 public function test_get_error_data_with_code_and_multiple_errors_same_code_should_return_the_last_stored_data() { 371 $this-> WP_Error->add( 'code', 'message', 'data' );372 $this-> WP_Error->add( 'code', 'message2', 'data2' );373 $this-> WP_Error->add( 'code2', 'message3', 'data3' );371 $this->wp_error->add( 'code', 'message', 'data' ); 372 $this->wp_error->add( 'code', 'message2', 'data2' ); 373 $this->wp_error->add( 'code2', 'message3', 'data3' ); 374 374 375 $this->assertSame( 'data2', $this-> WP_Error->get_error_data( 'code' ) );375 $this->assertSame( 'data2', $this->wp_error->get_error_data( 'code' ) ); 376 376 } 377 377 378 378 /** 379 379 * @covers ::has_errors() 380 380 */ 381 381 public function test_has_errors_with_no_errors_returns_false() { 382 $this->assertFalse( $this-> WP_Error->has_errors() );382 $this->assertFalse( $this->wp_error->has_errors() ); 383 383 } 384 384 385 385 /** 386 386 * @covers ::has_errors() 387 387 */ 388 388 public function test_has_errors_with_errors_returns_true() { 389 $this-> WP_Error->add( 'code', 'message', 'data' );390 $this->assertTrue( $this-> WP_Error->has_errors() );389 $this->wp_error->add( 'code', 'message', 'data' ); 390 $this->assertTrue( $this->wp_error->has_errors() ); 391 391 } 392 392 393 393 /** 394 394 * @covers ::add() 395 395 */ 396 396 public function test_add_with_empty_code_empty_message_empty_data_should_add_empty_key_to_errors_array() { 397 $this-> WP_Error->add( '', '', 'data' );397 $this->wp_error->add( '', '', 'data' ); 398 398 399 $this->assertArrayHasKey( '', $this-> WP_Error->errors );399 $this->assertArrayHasKey( '', $this->wp_error->errors ); 400 400 } 401 401 402 402 /** 403 403 * @covers ::add() 404 404 */ 405 405 public function test_add_with_empty_code_empty_message_empty_data_should_add_empty_message_to_errors_array_under_empty_key() { 406 $this-> WP_Error->add( '', '', 'data' );406 $this->wp_error->add( '', '', 'data' ); 407 407 408 $this->assertEqualSetsWithIndex( array( '' => array( '' ) ), $this-> WP_Error->errors );408 $this->assertEqualSetsWithIndex( array( '' => array( '' ) ), $this->wp_error->errors ); 409 409 } 410 410 411 411 /** 412 412 * @covers ::add() 413 413 */ 414 414 public function test_add_with_empty_code_empty_message_empty_data_should_not_alter_data() { 415 $this-> WP_Error->add( '', '', '' );415 $this->wp_error->add( '', '', '' ); 416 416 417 $this->assertEmpty( $this-> WP_Error->error_data );417 $this->assertEmpty( $this->wp_error->error_data ); 418 418 } 419 419 420 420 /** 421 421 * @covers ::add() 422 422 */ 423 423 public function test_add_with_empty_code_empty_message_non_empty_data_should_store_data_under_an_empty_code_key() { 424 $this-> WP_Error->add( '', '', 'data' );424 $this->wp_error->add( '', '', 'data' ); 425 425 426 $this->assertEqualSetsWithIndex( array( '' => 'data' ), $this-> WP_Error->error_data );426 $this->assertEqualSetsWithIndex( array( '' => 'data' ), $this->wp_error->error_data ); 427 427 } 428 428 429 429 /** 430 430 * @covers ::add() 431 431 */ 432 432 public function test_add_with_code_empty_message_empty_data_should_add_error_with_code() { 433 $this-> WP_Error->add( 'code', '' );433 $this->wp_error->add( 'code', '' ); 434 434 435 $this->assertSame( 'code', $this-> WP_Error->get_error_code() );435 $this->assertSame( 'code', $this->wp_error->get_error_code() ); 436 436 } 437 437 438 438 /** 439 439 * @covers ::add() 440 440 */ 441 441 public function test_add_with_code_empty_message_empty_data_should_add_error_with_empty_message() { 442 $this-> WP_Error->add( 'code', '' );442 $this->wp_error->add( 'code', '' ); 443 443 444 $this->assertSame( '', $this-> WP_Error->get_error_message( 'code' ) );444 $this->assertSame( '', $this->wp_error->get_error_message( 'code' ) ); 445 445 } 446 446 447 447 /** 448 448 * @covers ::add() 449 449 */ 450 450 public function test_add_with_code_empty_message_empty_data_should_not_add_error_data() { 451 $this-> WP_Error->add( 'code', '' );451 $this->wp_error->add( 'code', '' ); 452 452 453 $this->assertSame( null, $this-> WP_Error->get_error_data( 'code' ) );453 $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) ); 454 454 } 455 455 456 456 /** 457 457 * @covers ::add() 458 458 */ 459 459 public function test_add_with_code_and_message_and_empty_data_should_should_add_error_with_that_message() { 460 $this-> WP_Error->add( 'code', 'message' );460 $this->wp_error->add( 'code', 'message' ); 461 461 462 $this->assertSame( 'message', $this-> WP_Error->get_error_message( 'code' ) );462 $this->assertSame( 'message', $this->wp_error->get_error_message( 'code' ) ); 463 463 } 464 464 465 465 /** 466 466 * @covers ::add() 467 467 */ 468 468 public function test_add_with_code_and_message_and_empty_data_should_not_alter_stored_data() { 469 $this-> WP_Error->add( 'code', 'message' );469 $this->wp_error->add( 'code', 'message' ); 470 470 471 $this->assertSame( null, $this-> WP_Error->get_error_data( 'code' ) );471 $this->assertSame( null, $this->wp_error->get_error_data( 'code' ) ); 472 472 } 473 473 474 474 /** 475 475 * @covers ::add() 476 476 */ 477 477 public function test_add_with_code_and_empty_message_and_data_should_add_error_with_that_code() { 478 $this-> WP_Error->add( 'code', '', 'data' );478 $this->wp_error->add( 'code', '', 'data' ); 479 479 480 $this->assertSame( 'code', $this-> WP_Error->get_error_code() );480 $this->assertSame( 'code', $this->wp_error->get_error_code() ); 481 481 } 482 482 483 483 /** 484 484 * @covers ::add() 485 485 */ 486 486 public function test_add_with_code_and_empty_message_and_data_should_store_that_data() { 487 $this-> WP_Error->add( 'code', '', 'data' );487 $this->wp_error->add( 'code', '', 'data' ); 488 488 489 $this->assertSame( 'data', $this-> WP_Error->get_error_data( 'code' ) );489 $this->assertSame( 'data', $this->wp_error->get_error_data( 'code' ) ); 490 490 } 491 491 492 492 /** 493 493 * @covers ::add() 494 494 */ 495 495 public function test_add_with_code_and_message_and_data_should_add_an_error_with_that_code() { 496 $this-> WP_Error->add( 'code', 'message', 'data' );496 $this->wp_error->add( 'code', 'message', 'data' ); 497 497 498 $this->assertSame( 'code', $this-> WP_Error->get_error_code() );498 $this->assertSame( 'code', $this->wp_error->get_error_code() ); 499 499 } 500 500 501 501 /** 502 502 * @covers ::add() 503 503 */ 504 504 public function test_add_with_code_and_message_and_data_should_add_an_error_with_that_message() { 505 $this-> WP_Error->add( 'code', 'message', 'data' );505 $this->wp_error->add( 'code', 'message', 'data' ); 506 506 507 $this->assertSame( 'message', $this-> WP_Error->get_error_message( 'code' ) );507 $this->assertSame( 'message', $this->wp_error->get_error_message( 'code' ) ); 508 508 } 509 509 510 510 /** 511 511 * @covers ::add() 512 512 */ 513 513 public function test_add_with_code_and_message_and_data_should_store_that_data() { 514 $this-> WP_Error->add( 'code', 'message', 'data' );514 $this->wp_error->add( 'code', 'message', 'data' ); 515 515 516 $this->assertSame( 'data', $this-> WP_Error->get_error_data( 'code' ) );516 $this->assertSame( 'data', $this->wp_error->get_error_data( 'code' ) ); 517 517 } 518 518 519 519 /** 520 520 * @covers ::add() 521 521 */ 522 522 public function test_add_multiple_times_with_the_same_code_should_add_additional_messages_for_that_code() { 523 $this-> WP_Error->add( 'code', 'message' );524 $this-> WP_Error->add( 'code', 'message2' );523 $this->wp_error->add( 'code', 'message' ); 524 $this->wp_error->add( 'code', 'message2' ); 525 525 526 526 $expected = array( 'message', 'message2' ); 527 527 528 $this->assertEqualSets( $expected, $this-> WP_Error->get_error_messages( 'code' ) );528 $this->assertEqualSets( $expected, $this->wp_error->get_error_messages( 'code' ) ); 529 529 } 530 530 531 531 /** 532 532 * @covers ::add() 533 533 */ 534 534 public function test_add_multiple_times_with_the_same_code_and_different_data_should_store_only_the_last_added_data() { 535 $this-> WP_Error->add( 'code', 'message', 'data-bar' );536 $this-> WP_Error->add( 'code', 'message2', 'data-baz' );535 $this->wp_error->add( 'code', 'message', 'data-bar' ); 536 $this->wp_error->add( 'code', 'message2', 'data-baz' ); 537 537 538 $this->assertSame( 'data-baz', $this-> WP_Error->get_error_data( 'code' ) );538 $this->assertSame( 'data-baz', $this->wp_error->get_error_data( 'code' ) ); 539 539 } 540 540 541 541 /** 542 542 * @covers ::add_data() 543 543 */ 544 544 public function test_add_data_with_empty_data_empty_code_should_create_orphaned_data_with_no_error() { 545 $this-> WP_Error->add_data( '' );545 $this->wp_error->add_data( '' ); 546 546 547 $this->assertEmpty( $this-> WP_Error->errors );547 $this->assertEmpty( $this->wp_error->errors ); 548 548 } 549 549 550 550 /** 551 551 * @covers ::add_data() 552 552 */ 553 553 public function test_add_data_with_empty_data_empty_code_no_errors_should_create_data_under_an_empty_code_key() { 554 $this-> WP_Error->add_data( '' );554 $this->wp_error->add_data( '' ); 555 555 556 $this->assertEqualSets( array( '' => '' ), $this-> WP_Error->error_data );556 $this->assertEqualSets( array( '' => '' ), $this->wp_error->error_data ); 557 557 } 558 558 559 559 /** 560 560 * @covers ::add_data() 561 561 */ 562 562 public function test_add_data_with_data_empty_code_and_one_error_should_store_the_data_under_that_code() { 563 $this-> WP_Error->add( 'code', 'message' );564 $this-> WP_Error->add_data( 'data' );563 $this->wp_error->add( 'code', 'message' ); 564 $this->wp_error->add_data( 'data' ); 565 565 566 $this->assertSame( 'data', $this-> WP_Error->get_error_data( 'code' ) );566 $this->assertSame( 'data', $this->wp_error->get_error_data( 'code' ) ); 567 567 } 568 568 569 569 /** 570 570 * @covers ::add_data() 571 571 */ 572 572 public function test_add_data_with_data_empty_code_and_multiple_errors_with_different_codes_should_store_it_under_the_first_code() { 573 $this-> WP_Error->add( 'code', 'message' );574 $this-> WP_Error->add( 'code2', 'message2' );573 $this->wp_error->add( 'code', 'message' ); 574 $this->wp_error->add( 'code2', 'message2' ); 575 575 576 $this-> WP_Error->add_data( 'data' );576 $this->wp_error->add_data( 'data' ); 577 577 578 $this->assertSame( 'data', $this-> WP_Error->get_error_data( 'code' ) );578 $this->assertSame( 'data', $this->wp_error->get_error_data( 'code' ) ); 579 579 } 580 580 581 581 /** 582 582 * @covers ::add_data() 583 583 */ 584 584 public function test_add_data_with_data_empty_code_and_multiple_errors_with_same_code_should_store_it_under_the_first_code() { 585 $this-> WP_Error->add( 'code', 'message' );586 $this-> WP_Error->add( 'code2', 'message2' );587 $this-> WP_Error->add( 'code', 'message3' );585 $this->wp_error->add( 'code', 'message' ); 586 $this->wp_error->add( 'code2', 'message2' ); 587 $this->wp_error->add( 'code', 'message3' ); 588 588 589 $this-> WP_Error->add_data( 'data' );589 $this->wp_error->add_data( 'data' ); 590 590 591 $this->assertSame( 'data', $this-> WP_Error->get_error_data( 'code' ) );591 $this->assertSame( 'data', $this->wp_error->get_error_data( 'code' ) ); 592 592 } 593 593 594 594 /** 595 595 * @covers ::add_data() 596 596 */ 597 597 public function test_add_data_with_data_and_code_and_no_errors_should_create_orphaned_data_with_no_error() { 598 $this-> WP_Error->add_data( 'data', 'code' );598 $this->wp_error->add_data( 'data', 'code' ); 599 599 600 $this->assertEmpty( $this-> WP_Error->errors );600 $this->assertEmpty( $this->wp_error->errors ); 601 601 } 602 602 603 603 /** 604 604 * @covers ::add_data() 605 605 */ 606 606 public function test_add_data_with_data_and_code_no_errors_should_create_data_under_that_code_key() { 607 $this-> WP_Error->add_data( 'data', 'code' );607 $this->wp_error->add_data( 'data', 'code' ); 608 608 609 $this->assertEqualSets( array( 'code' => 'data' ), $this-> WP_Error->error_data );609 $this->assertEqualSets( array( 'code' => 'data' ), $this->wp_error->error_data ); 610 610 } 611 611 612 612 /** 613 613 * @covers ::add_data() 614 614 */ 615 615 public function test_add_data_with_data_and_code_one_error_different_code_should_create_orphaned_data_with_no_error() { 616 $this-> WP_Error->add( 'code', 'message' );616 $this->wp_error->add( 'code', 'message' ); 617 617 618 $this-> WP_Error->add_data( 'data', 'code2' );618 $this->wp_error->add_data( 'data', 'code2' ); 619 619 620 $this->assertEqualSetsWithIndex( array( 'code' => array( 'message' ) ), $this-> WP_Error->errors );620 $this->assertEqualSetsWithIndex( array( 'code' => array( 'message' ) ), $this->wp_error->errors ); 621 621 } 622 622 623 623 /** 624 624 * @covers ::add_data() 625 625 */ 626 626 public function test_add_data_with_data_and_code_one_error_different_code_should_create_data_under_that_code_key() { 627 $this-> WP_Error->add( 'code', 'message' );627 $this->wp_error->add( 'code', 'message' ); 628 628 629 $this-> WP_Error->add_data( 'data', 'code2' );629 $this->wp_error->add_data( 'data', 'code2' ); 630 630 631 $this->assertEqualSetsWithIndex( array( 'code2' => 'data' ), $this-> WP_Error->error_data );631 $this->assertEqualSetsWithIndex( array( 'code2' => 'data' ), $this->wp_error->error_data ); 632 632 } 633 633 634 634 /** 635 635 * @covers ::add_data() 636 636 */ 637 637 public function test_add_data_with_data_and_code_should_add_data() { 638 $this-> WP_Error->add( 'code', 'message' );638 $this->wp_error->add( 'code', 'message' ); 639 639 640 $this-> WP_Error->add_data( 'data', 'code' );640 $this->wp_error->add_data( 'data', 'code' ); 641 641 642 $this->assertSame( 'data', $this-> WP_Error->get_error_data( 'code' ) );642 $this->assertSame( 'data', $this->wp_error->get_error_data( 'code' ) ); 643 643 } 644 644 645 645 /** 646 646 * @covers ::remove() 647 647 */ 648 648 public function test_remove_with_no_errors_should_affect_nothing() { 649 $before = $this-> WP_Error->errors;649 $before = $this->wp_error->errors; 650 650 651 $this-> WP_Error->remove( 'code' );651 $this->wp_error->remove( 'code' ); 652 652 653 $after = $this-> WP_Error->errors;653 $after = $this->wp_error->errors; 654 654 655 655 $this->assertEqualSetsWithIndex( $before, $after ); 656 656 } … … 659 659 * @covers ::remove() 660 660 */ 661 661 public function test_remove_empty_code_no_errors_should_affect_nothing() { 662 $before = $this-> WP_Error->errors;662 $before = $this->wp_error->errors; 663 663 664 $this-> WP_Error->remove( '' );664 $this->wp_error->remove( '' ); 665 665 666 $after = $this-> WP_Error->errors;666 $after = $this->wp_error->errors; 667 667 668 668 $this->assertEqualSetsWithIndex( $before, $after ); 669 669 } … … 672 672 * @covers ::remove() 673 673 */ 674 674 public function test_remove_empty_code_and_one_error_with_empty_string_code_should_remove_error() { 675 $before = $this-> WP_Error->errors;675 $before = $this->wp_error->errors; 676 676 677 $this-> WP_Error->add( '', 'message' );677 $this->wp_error->add( '', 'message' ); 678 678 679 $this-> WP_Error->remove( '' );679 $this->wp_error->remove( '' ); 680 680 681 $after = $this-> WP_Error->errors;681 $after = $this->wp_error->errors; 682 682 683 683 $this->assertEqualSetsWithIndex( $before, $after ); 684 684 } … … 687 687 * @covers ::remove() 688 688 */ 689 689 public function test_remove_empty_code_and_one_error_with_empty_string_code_should_remove_error_data() { 690 $this-> WP_Error->add( '', 'message', 'data' );690 $this->wp_error->add( '', 'message', 'data' ); 691 691 692 $this-> WP_Error->remove( '' );692 $this->wp_error->remove( '' ); 693 693 694 $after = $this-> WP_Error->error_data;694 $after = $this->wp_error->error_data; 695 695 696 $this->assertEmpty( $this-> WP_Error->error_data );696 $this->assertEmpty( $this->wp_error->error_data ); 697 697 } 698 698 699 699 /** 700 700 * @covers ::remove() 701 701 */ 702 702 public function test_remove_should_remove_the_error_with_the_given_code() { 703 $this-> WP_Error->add( 'code', 'message' );703 $this->wp_error->add( 'code', 'message' ); 704 704 705 $this-> WP_Error->remove( 'code' );705 $this->wp_error->remove( 'code' ); 706 706 707 $this->assertEmpty( $this-> WP_Error->errors );707 $this->assertEmpty( $this->wp_error->errors ); 708 708 } 709 709 710 710 /** 711 711 * @covers ::remove() 712 712 */ 713 713 public function test_remove_should_remove_the_error_data_associated_with_the_given_code() { 714 $this-> WP_Error->add( 'code', 'message', 'data' );714 $this->wp_error->add( 'code', 'message', 'data' ); 715 715 716 $this-> WP_Error->remove( 'code' );716 $this->wp_error->remove( 'code' ); 717 717 718 $this->assertEmpty( $this-> WP_Error->error_data );718 $this->assertEmpty( $this->wp_error->error_data ); 719 719 } 720 720 721 721 } -
tests/phpunit/tests/http/base.php
13 13 abstract class WP_HTTP_UnitTestCase extends WP_UnitTestCase { 14 14 // You can use your own version of data/WPHTTP-testcase-redirection-script.php here. 15 15 var $redirection_script = 'http://api.wordpress.org/core/tests/1.0/redirection.php'; 16 var $file StreamUrl= 'http://s.w.org/screenshots/3.9/dashboard.png';16 var $file_stream_url = 'http://s.w.org/screenshots/3.9/dashboard.png'; 17 17 18 18 protected $http_request_args; 19 19 … … 254 254 } 255 255 256 256 function test_file_stream() { 257 $url = $this->file StreamUrl;257 $url = $this->file_stream_url; 258 258 $size = 153204; 259 259 $res = wp_remote_request( 260 260 $url, … … 282 282 * @ticket 26726 283 283 */ 284 284 function test_file_stream_limited_size() { 285 $url = $this->file StreamUrl;285 $url = $this->file_stream_url; 286 286 $size = 10000; 287 287 $res = wp_remote_request( 288 288 $url, … … 311 311 * @ticket 31172 312 312 */ 313 313 function test_request_limited_size() { 314 $url = $this->file StreamUrl;314 $url = $this->file_stream_url; 315 315 $size = 10000; 316 316 317 317 $res = wp_remote_request( -
tests/phpunit/tests/http/curl.php
15 15 public function test_http_api_curl_stream_parameter_is_a_reference() { 16 16 add_action( 'http_api_curl', array( $this, '_action_test_http_api_curl_stream_parameter_is_a_reference' ), 10, 3 ); 17 17 wp_remote_request( 18 $this->file StreamUrl,18 $this->file_stream_url, 19 19 array( 20 20 'stream' => true, 21 21 'timeout' => 30, -
tests/phpunit/tests/user.php
199 199 * @ticket 20043 200 200 */ 201 201 public function test_user_unset() { 202 // phpcs:disable WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar 202 203 $user = new WP_User( self::$author_id ); 203 204 204 205 // Test custom fields … … 207 208 unset( $user->customField ); 208 209 $this->assertFalse( isset( $user->customField ) ); 209 210 return $user; 211 // phpcs:enable 210 212 } 211 213 212 214 /**