Ticket #42742: 42742.diff
| File 42742.diff, 1.6 KB (added by , 8 years ago) |
|---|
-
src/wp-includes/class-wp-error.php
31 31 * 32 32 * @since 2.1.0 33 33 * @var array 34 */34 */ 35 35 public $error_data = array(); 36 36 37 37 /** … … 71 71 * @return array List of error codes, if available. 72 72 */ 73 73 public function get_error_codes() { 74 if ( empty( $this->errors) ) {74 if ( ! $this->has_errors() ) { 75 75 return array(); 76 76 } 77 77 … … 162 162 } 163 163 164 164 /** 165 * Verify if instance contains errors. 166 * 167 * @since 5.0.0 168 * 169 * @return bool 170 */ 171 public function has_errors() { 172 if ( ! empty( $this->errors ) ) { 173 return true; 174 } 175 return false; 176 } 177 178 /** 165 179 * Add an error or append additional message to an existing error. 166 180 * 167 181 * @since 2.1.0 -
tests/phpunit/tests/general/wpError.php
412 412 } 413 413 414 414 /** 415 * @covers ::has_errors() 416 */ 417 public function test_has_errors_with_no_errors_returns_false() { 418 $this->assertFalse( $this->WP_Error->has_errors() ); 419 } 420 421 /** 422 * @covers ::has_errors() 423 */ 424 public function test_has_errors_with_errors_returns_true() { 425 $this->WP_Error->add( 'code', 'message', 'data' ); 426 $this->assertTrue( $this->WP_Error->has_errors() ); 427 } 428 429 /** 415 430 * @covers ::add() 416 431 */ 417 432 public function test_add_with_code_empty_message_empty_data_should_add_error_with_code() {