Make WordPress Core


Ignore:
Timestamp:
02/03/2018 05:37:51 PM (9 years ago)
Author:
DrewAPicture
Message:

Tests: Simplify @covers annotations for WP_Error test coverage. Also fix a typo in a test method name.

See #42742.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/general/wpError.php

    r42636 r42646  
    55 * @group general
    66 * @group errors
     7 *
     8 * @coversDefaultClass WP_Error
    79 */
    810class Tests_WP_Error extends WP_UnitTestCase {
     
    2426        }
    2527
    26         /**
    27          * @covers WP_Error
    28          */
    2928        public function test_WP_Error_should_be_of_type_WP_Error() {
    3029                $this->assertWPError( $this->WP_Error );
    3130        }
    3231
    33         /**
    34          * @covers WP_Error
    35          */
    3632        public function test_WP_Error_with_default_empty_parameters_should_add_no_errors() {
    3733                $this->assertEmpty( $this->WP_Error->errors );
    3834        }
    3935
    40         /**
    41          * @covers WP_Error
    42          */
    4336        public function test_WP_Error_with_empty_code_should_add_no_code() {
    4437                $this->assertSame( '', $this->WP_Error->get_error_code() );
    4538        }
    4639
    47         /**
    48          * @covers WP_Error
    49          */
    5040        public function test_WP_Error_with_empty_code_should_add_no_message() {
    5141                $this->assertSame( '', $this->WP_Error->get_error_message() );
    5242        }
    5343
    54         /**
    55          * @covers WP_Error
    56          */
    5744        public function test_WP_Error_with_empty_code_should_add_no_error_data() {
    5845                $this->assertEmpty( $this->WP_Error->error_data );
    5946        }
    6047
    61         /**
    62          * @covers WP_Error
    63          */
    6448        public function test_WP_Error_with_code_and_empty_message_should_add_error_with_that_code() {
    6549                $wp_error = new WP_Error( 'code' );
     
    6852        }
    6953
    70         /**
    71          * @covers WP_Error
    72          */
    7354        public function test_WP_Error_with_code_and_empty_message_should_add_error_with_that_code_and_empty_message() {
    7455                $wp_error = new WP_Error( 'code' );
     
    7758        }
    7859
    79         /**
    80          * @covers WP_Error
    81          */
    8260        public function test_WP_Error_with_code_and_empty_message_and_empty_data_should_add_error_but_not_associated_data() {
    8361                $wp_error = new WP_Error( 'code' );
     
    8664        }
    8765
    88         /**
    89          * @covers WP_Error
    90          */
    9166        public function test_WP_Error_with_code_and_empty_message_and_non_empty_data_should_add_error_with_empty_message_and_that_stored_data() {
    9267                $wp_error = new WP_Error( 'code', '', 'data' );
     
    9570        }
    9671
    97         /**
    98          * @covers WP_Error
    99          */
    10072        public function test_WP_Error_with_code_and_message_should_add_error_with_that_code() {
    10173                $wp_error = new WP_Error( 'code', 'message' );
     
    10476        }
    10577
    106         /**
    107          * @covers WP_Error
    108          */
    10978        public function test_WP_Error_with_code_and_message_should_add_error_with_that_message() {
    11079                $wp_error = new WP_Error( 'code', 'message' );
     
    11382        }
    11483
    115         /**
    116          * @covers WP_Error
    117          */
    11884        public function test_WP_Error_with_code_and_message_and_data_should_add_error_with_that_code() {
    11985                $wp_error = new WP_Error( 'code', 'message', 'data' );
     
    12288        }
    12389
    124         /**
    125          * @covers WP_Error
    126          */
    12790        public function test_WP_Error_with_code_and_message_and_data_should_add_error_with_that_message() {
    12891                $wp_error = new WP_Error( 'code', 'message', 'data' );
     
    13194        }
    13295
    133         /**
    134          * @covers WP_Error
    135          */
    13696        public function test_WP_Error_with_code_and_message_and_data_should_add_error_with_that_data() {
    13797                $wp_error = new WP_Error( 'code', 'message', 'data' );
     
    141101
    142102        /**
    143          * @covers WP_Error::get_error_codes()
     103         * @covers ::get_error_codes()
    144104         */
    145105        public function test_get_error_codes_with_no_errors_should_return_empty_array() {
     
    148108
    149109        /**
    150          * @covers WP_Error::get_error_codes()
     110         * @covers ::get_error_codes()
    151111         */
    152112        public function test_get_error_codes_with_one_error_should_return_an_array_with_only_that_code() {
     
    157117
    158118        /**
    159          * @covers WP_Error::get_error_codes()
    160          */
    161         public function test_get_error_codes_with_nultiple_errors_should_return_an_array_of_those_codes() {
     119         * @covers ::get_error_codes()
     120         */
     121        public function test_get_error_codes_with_multiple_errors_should_return_an_array_of_those_codes() {
    162122                $this->WP_Error->add( 'code', 'message' );
    163123                $this->WP_Error->add( 'code2', 'message2' );
     
    169129
    170130        /**
    171          * @covers WP_Error::get_error_code()
     131         * @covers ::get_error_code()
    172132         */
    173133        public function test_get_error_code_with_no_errors_should_return_an_empty_string() {
     
    176136
    177137        /**
    178          * @covers WP_Error::get_error_code()
     138         * @covers ::get_error_code()
    179139         */
    180140        public function test_get_error_code_with_one_error_should_return_that_error_code() {
     
    185145
    186146        /**
    187          * @covers WP_Error::get_error_code()
     147         * @covers ::get_error_code()
    188148         */
    189149        public function test_get_error_code_with_multiple_errors_should_return_only_the_first_error_code() {
     
    195155
    196156        /**
    197          * @covers WP_Error::get_error_messages()
     157         * @covers ::get_error_messages()
    198158         */
    199159        public function test_get_error_messages_with_empty_code_and_no_errors_should_return_an_empty_array() {
     
    202162
    203163        /**
    204          * @covers WP_Error::get_error_messages()
     164         * @covers ::get_error_messages()
    205165         */
    206166        public function test_get_error_messages_with_empty_code_one_error_should_return_an_array_with_that_message() {
     
    211171
    212172        /**
    213          * @covers WP_Error::get_error_messages()
     173         * @covers ::get_error_messages()
    214174         */
    215175        public function test_get_error_messages_with_empty_code_multiple_errors_should_return_an_array_of_messages() {
     
    221181
    222182        /**
    223          * @covers WP_Error::get_error_messages()
     183         * @covers ::get_error_messages()
    224184         */
    225185        public function test_get_error_messages_with_an_invalid_code_should_return_an_empty_array() {
     
    228188
    229189        /**
    230          * @covers WP_Error::get_error_messages()
     190         * @covers ::get_error_messages()
    231191         */
    232192        public function test_get_error_messages_with_one_error_should_return_an_array_with_that_message() {
     
    237197
    238198        /**
    239          * @covers WP_Error::get_error_messages()
     199         * @covers ::get_error_messages()
    240200         */
    241201        public function test_get_error_messages_with_multiple_errors_same_code_should_return_an_array_with_all_messages() {
     
    247207
    248208        /**
    249          * @covers WP_Error::get_error_message()
     209         * @covers ::get_error_message()
    250210         */
    251211        public function test_get_error_message_with_empty_code_and_no_errors_should_return_an_empty_string() {
     
    254214
    255215        /**
    256          * @covers WP_Error::get_error_message()
     216         * @covers ::get_error_message()
    257217         */
    258218        public function test_get_error_message_with_empty_code_and_one_error_should_return_that_message() {
     
    263223
    264224        /**
    265          * @covers WP_Error::get_error_message()
     225         * @covers ::get_error_message()
    266226         */
    267227        public function test_get_error_message_with_empty_code_and_multiple_errors_should_return_the_first_message() {
     
    273233
    274234        /**
    275          * @covers WP_Error::get_error_message()
     235         * @covers ::get_error_message()
    276236         */
    277237        public function test_get_error_message_with_empty_code_and_multiple_errors_multiple_codes_should_return_the_first_message() {
     
    284244
    285245        /**
    286          * @covers WP_Error::get_error_message()
     246         * @covers ::get_error_message()
    287247         */
    288248        public function test_get_error_message_with_invalid_code_and_no_errors_should_return_empty_string() {
     
    291251
    292252        /**
    293          * @covers WP_Error::get_error_message()
     253         * @covers ::get_error_message()
    294254         */
    295255        public function test_get_error_message_with_invalid_code_and_one_error_should_return_an_empty_string() {
     
    300260
    301261        /**
    302          * @covers WP_Error::get_error_message()
     262         * @covers ::get_error_message()
    303263         */
    304264        public function test_get_error_message_with_invalid_code_and_multiple_errors_should_return_an_empty_string() {
     
    310270
    311271        /**
    312          * @covers WP_Error::get_error_data()
     272         * @covers ::get_error_data()
    313273         */
    314274        public function test_get_error_data_with_empty_code_and_no_errors_should_evaluate_as_null() {
     
    317277
    318278        /**
    319          * @covers WP_Error::get_error_data()
     279         * @covers ::get_error_data()
    320280         */
    321281        public function test_get_error_data_with_empty_code_one_error_no_data_should_evaluate_as_null() {
     
    326286
    327287        /**
    328          * @covers WP_Error::get_error_data()
     288         * @covers ::get_error_data()
    329289         */
    330290        public function test_get_error_data_with_empty_code_multiple_errors_no_data_should_evaluate_as_null() {
     
    336296
    337297        /**
    338          * @covers WP_Error::get_error_data()
     298         * @covers ::get_error_data()
    339299         */
    340300        public function test_get_error_data_with_empty_code_and_one_error_with_data_should_return_that_data() {
     
    346306
    347307        /**
    348          * @covers WP_Error::get_error_data()
     308         * @covers ::get_error_data()
    349309         */
    350310        public function test_get_error_data_with_empty_code_and_multiple_errors_different_codes_should_return_the_last_data_of_the_first_code() {
     
    357317
    358318        /**
    359          * @covers WP_Error::get_error_data()
     319         * @covers ::get_error_data()
    360320         */
    361321        public function test_get_error_data_with_empty_code_and_multiple_errors_same_code_should_return_the_last_data_of_the_first_code() {
     
    368328
    369329        /**
    370          * @covers WP_Error::get_error_data()
     330         * @covers ::get_error_data()
    371331         */
    372332        public function test_get_error_data_with_code_and_no_errors_should_evaluate_as_null() {
     
    375335
    376336        /**
    377          * @covers WP_Error::get_error_data()
     337         * @covers ::get_error_data()
    378338         */
    379339        public function test_get_error_data_with_code_and_one_error_with_no_data_should_evaluate_as_null() {
     
    384344
    385345        /**
    386          * @covers WP_Error::get_error_data()
     346         * @covers ::get_error_data()
    387347         */
    388348        public function test_get_error_data_with_code_and_one_error_with_data_should_return_that_data() {
     
    394354
    395355        /**
    396          * @covers WP_Error::get_error_data()
     356         * @covers ::get_error_data()
    397357         */
    398358        public function test_get_error_data_with_code_and_multiple_errors_different_codes_should_return_the_last_stored_data_of_the_code() {
     
    406366
    407367        /**
    408          * @covers WP_Error::get_error_data()
     368         * @covers ::get_error_data()
    409369         */
    410370        public function test_get_error_data_with_code_and_multiple_errors_same_code_should_return_the_last_stored_data() {
     
    417377
    418378        /**
    419          * @covers WP_Error::add()
     379         * @covers ::add()
    420380         */
    421381        public function test_add_with_empty_code_empty_message_empty_data_should_add_empty_key_to_errors_array() {
     
    426386
    427387        /**
    428          * @covers WP_Error::add()
     388         * @covers ::add()
    429389         */
    430390        public function test_add_with_empty_code_empty_message_empty_data_should_add_empty_message_to_errors_array_under_empty_key() {
     
    435395
    436396        /**
    437          * @covers WP_Error::add()
     397         * @covers ::add()
    438398         */
    439399        public function test_add_with_empty_code_empty_message_empty_data_should_not_alter_data() {
     
    444404
    445405        /**
    446          * @covers WP_Error::add()
     406         * @covers ::add()
    447407         */
    448408        public function test_add_with_empty_code_empty_message_non_empty_data_should_store_data_under_an_empty_code_key() {
     
    453413
    454414        /**
    455          * @covers WP_Error::add()
     415         * @covers ::add()
    456416         */
    457417        public function test_add_with_code_empty_message_empty_data_should_add_error_with_code() {
     
    462422
    463423        /**
    464          * @covers WP_Error::add()
     424         * @covers ::add()
    465425         */
    466426        public function test_add_with_code_empty_message_empty_data_should_add_error_with_empty_message() {
     
    471431
    472432        /**
    473          * @covers WP_Error::add()
     433         * @covers ::add()
    474434         */
    475435        public function test_add_with_code_empty_message_empty_data_should_not_add_error_data() {
     
    480440
    481441        /**
    482          * @covers WP_Error::add()
     442         * @covers ::add()
    483443         */
    484444        public function test_add_with_code_and_message_and_empty_data_should_should_add_error_with_that_message() {
     
    489449
    490450        /**
    491          * @covers WP_Error::add()
     451         * @covers ::add()
    492452         */
    493453        public function test_add_with_code_and_message_and_empty_data_should_not_alter_stored_data() {
     
    498458
    499459        /**
    500          * @covers WP_Error::add()
     460         * @covers ::add()
    501461         */
    502462        public function test_add_with_code_and_empty_message_and_data_should_add_error_with_that_code() {
     
    507467
    508468        /**
    509          * @covers WP_Error::add()
     469         * @covers ::add()
    510470         */
    511471        public function test_add_with_code_and_empty_message_and_data_should_store_that_data() {
     
    516476
    517477        /**
    518          * @covers WP_Error::add()
     478         * @covers ::add()
    519479         */
    520480        public function test_add_with_code_and_message_and_data_should_add_an_error_with_that_code() {
     
    525485
    526486        /**
    527          * @covers WP_Error::add()
     487         * @covers ::add()
    528488         */
    529489        public function test_add_with_code_and_message_and_data_should_add_an_error_with_that_message() {
     
    534494
    535495        /**
    536          * @covers WP_Error::add()
     496         * @covers ::add()
    537497         */
    538498        public function test_add_with_code_and_message_and_data_should_store_that_data() {
     
    543503
    544504        /**
    545          * @covers WP_Error::add()
     505         * @covers ::add()
    546506         */
    547507        public function test_add_multiple_times_with_the_same_code_should_add_additional_messages_for_that_code() {
     
    555515
    556516        /**
    557          * @covers WP_Error::add()
     517         * @covers ::add()
    558518         */
    559519        public function test_add_multiple_times_with_the_same_code_and_different_data_should_store_only_the_last_added_data() {
     
    565525
    566526        /**
    567          * @covers WP_Error::add_data()
     527         * @covers ::add_data()
    568528         */
    569529        public function test_add_data_with_empty_data_empty_code_should_create_orphaned_data_with_no_error() {
     
    574534
    575535        /**
    576          * @covers WP_Error::add_data()
     536         * @covers ::add_data()
    577537         */
    578538        public function test_add_data_with_empty_data_empty_code_no_errors_should_create_data_under_an_empty_code_key() {
     
    583543
    584544        /**
    585          * @covers WP_Error::add_data()
     545         * @covers ::add_data()
    586546         */
    587547        public function test_add_data_with_data_empty_code_and_one_error_should_store_the_data_under_that_code() {
     
    593553
    594554        /**
    595          * @covers WP_Error::add_data()
     555         * @covers ::add_data()
    596556         */
    597557        public function test_add_data_with_data_empty_code_and_multiple_errors_with_different_codes_should_store_it_under_the_first_code() {
     
    605565
    606566        /**
    607          * @covers WP_Error::add_data()
     567         * @covers ::add_data()
    608568         */
    609569        public function test_add_data_with_data_empty_code_and_multiple_errors_with_same_code_should_store_it_under_the_first_code() {
     
    618578
    619579        /**
    620          * @covers WP_Error::add_data()
     580         * @covers ::add_data()
    621581         */
    622582        public function test_add_data_with_data_and_code_and_no_errors_should_create_orphaned_data_with_no_error() {
     
    627587
    628588        /**
    629          * @covers WP_Error::add_data()
     589         * @covers ::add_data()
    630590         */
    631591        public function test_add_data_with_data_and_code_no_errors_should_create_data_under_that_code_key() {
     
    636596
    637597        /**
    638          * @covers WP_Error::add_data()
     598         * @covers ::add_data()
    639599         */
    640600        public function test_add_data_with_data_and_code_one_error_different_code_should_create_orphaned_data_with_no_error() {
     
    647607
    648608        /**
    649          * @covers WP_Error::add_data()
     609         * @covers ::add_data()
    650610         */
    651611        public function test_add_data_with_data_and_code_one_error_different_code_should_create_data_under_that_code_key() {
     
    658618
    659619        /**
    660          * @covers WP_Error::add_data()
     620         * @covers ::add_data()
    661621         */
    662622        public function test_add_data_with_data_and_code_should_add_data() {
     
    669629
    670630        /**
    671          * @covers WP_Error::remove()
     631         * @covers ::remove()
    672632         */
    673633        public function test_remove_with_no_errors_should_affect_nothing() {
     
    682642
    683643        /**
    684          * @covers WP_Error::remove()
     644         * @covers ::remove()
    685645         */
    686646        public function test_remove_empty_code_no_errors_should_affect_nothing() {
     
    695655
    696656        /**
    697          * @covers WP_Error::remove()
     657         * @covers ::remove()
    698658         */
    699659        public function test_remove_empty_code_and_one_error_with_empty_string_code_should_remove_error() {
     
    710670
    711671        /**
    712          * @covers WP_Error::remove()
     672         * @covers ::remove()
    713673         */
    714674        public function test_remove_empty_code_and_one_error_with_empty_string_code_should_remove_error_data() {
     
    723683
    724684        /**
    725          * @covers WP_Error::remove()
     685         * @covers ::remove()
    726686         */
    727687        public function test_remove_should_remove_the_error_with_the_given_code() {
     
    734694
    735695        /**
    736          * @covers WP_Error::remove()
     696         * @covers ::remove()
    737697         */
    738698        public function test_remove_should_remove_the_error_data_associated_with_the_given_code() {
Note: See TracChangeset for help on using the changeset viewer.