Make WordPress Core

Ticket #39265: I_folders.patch

File I_folders.patch, 57.6 KB (added by pbearne, 3 years ago)

the L foders

  • tests/phpunit/tests/image/dimensions.php

     
    66 * @group upload
    77 */
    88class Tests_Image_Dimensions extends WP_UnitTestCase {
     9
     10        /**
     11         * @covers ::image_resize_dimensions
     12         */
    913        function test_400x400_no_crop() {
    1014                // Landscape: resize 640x480 to fit 400x400: 400x300.
    1115                $out = image_resize_dimensions( 640, 480, 400, 400, false );
     
    1822                $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    1923        }
    2024
     25        /**
     26         * @covers ::image_resize_dimensions
     27         */
    2128        function test_400x0_no_crop() {
    2229                // Landscape: resize 640x480 to fit 400w: 400x300.
    2330                $out = image_resize_dimensions( 640, 480, 400, 0, false );
     
    3037                $this->assertSame( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out );
    3138        }
    3239
     40        /**
     41         * @covers ::image_resize_dimensions
     42         */
    3343        function test_0x400_no_crop() {
    3444                // Landscape: resize 640x480 to fit 400h: 533x400.
    3545                $out = image_resize_dimensions( 640, 480, 0, 400, false );
     
    4252                $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    4353        }
    4454
     55        /**
     56         * @covers ::image_resize_dimensions
     57         */
    4558        function test_800x800_no_crop() {
    4659                // Landscape: resize 640x480 to fit 800x800.
    4760                $out = image_resize_dimensions( 640, 480, 800, 800, false );
     
    5467                $this->assertFalse( $out );
    5568        }
    5669
     70        /**
     71         * @covers ::image_resize_dimensions
     72         */
    5773        function test_800x0_no_crop() {
    5874                // Landscape: resize 640x480 to fit 800w.
    5975                $out = image_resize_dimensions( 640, 480, 800, 0, false );
     
    6682                $this->assertFalse( $out );
    6783        }
    6884
     85        /**
     86         * @covers ::image_resize_dimensions
     87         */
    6988        function test_0x800_no_crop() {
    7089                // Landscape: resize 640x480 to fit 800h.
    7190                $out = image_resize_dimensions( 640, 480, 0, 800, false );
     
    7897                $this->assertFalse( $out );
    7998        }
    8099
    81         // Cropped versions.
    82 
     100        /**
     101         *  Cropped versions.
     102         *
     103         * @covers ::image_resize_dimensions
     104         */
    83105        function test_400x400_crop() {
    84106                // Landscape: crop 640x480 to fit 400x400: 400x400 taken from a 480x480 crop at (80. 0).
    85107                $out = image_resize_dimensions( 640, 480, 400, 400, true );
     
    92114                $this->assertSame( array( 0, 0, 0, 80, 400, 400, 480, 480 ), $out );
    93115        }
    94116
     117        /**
     118         * @covers ::image_resize_dimensions
     119         */
    95120        function test_400x0_crop() {
    96121                // Landscape: resize 640x480 to fit 400w: 400x300.
    97122                $out = image_resize_dimensions( 640, 480, 400, 0, true );
     
    104129                $this->assertSame( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out );
    105130        }
    106131
     132        /**
     133         * @covers ::image_resize_dimensions
     134         */
    107135        function test_0x400_crop() {
    108136                // Landscape: resize 640x480 to fit 400h: 533x400.
    109137                $out = image_resize_dimensions( 640, 480, 0, 400, true );
     
    116144                $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out );
    117145        }
    118146
     147        /**
     148         * @covers ::image_resize_dimensions
     149         */
    119150        function test_400x500_crop() {
    120151                // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0).
    121152                $out = image_resize_dimensions( 640, 480, 400, 500, true );
     
    128159                $this->assertSame( array( 0, 0, 0, 20, 400, 500, 480, 600 ), $out );
    129160        }
    130161
     162        /**
     163         * @covers ::image_resize_dimensions
     164         */
    131165        function test_640x480() {
    132166                // Crop 640x480 to fit 640x480 (no change).
    133167                $out = image_resize_dimensions( 640, 480, 640, 480, true );
     
    155189
    156190        /**
    157191         * @ticket 19393
     192         *
     193         * @covers ::image_resize_dimensions
    158194         */
    159195        function test_crop_anchors() {
    160196                // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop.
  • tests/phpunit/tests/image/editor.php

     
    2626         * Test wp_get_image_editor() where load returns true
    2727         *
    2828         * @ticket 6821
     29         *
     30         * @covers ::wp_get_image_editor
    2931         */
    3032        public function test_get_editor_load_returns_true() {
    3133                $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
     
    3739         * Test wp_get_image_editor() where load returns false
    3840         *
    3941         * @ticket 6821
     42         *
     43         * @covers ::wp_get_image_editor
    4044         */
    4145        public function test_get_editor_load_returns_false() {
    4246                WP_Image_Editor_Mock::$load_return = new WP_Error();
     
    6670         * Test test_quality
    6771         *
    6872         * @ticket 6821
     73         *
     74         * @covers ::wp_get_image_editor
    6975         */
    7076        public function test_set_quality() {
    7177
     
    113119         * Test generate_filename
    114120         *
    115121         * @ticket 6821
     122         *
     123         * @covers ::wp_get_image_editor
    116124         */
    117125        public function test_generate_filename() {
    118126
     
    152160         * Test get_size
    153161         *
    154162         * @ticket 6821
     163         *
     164         * @covers ::wp_get_image_editor
    155165         */
    156166        public function test_get_size() {
    157167
     
    176186         * Test get_suffix
    177187         *
    178188         * @ticket 6821
     189         *
     190         * @covers ::wp_get_image_editor
    179191         */
    180192        public function test_get_suffix() {
    181193                $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' );
  • tests/phpunit/tests/image/editorGd.php

     
    3232                parent::tearDown();
    3333        }
    3434
     35        /**
     36         * @covers WP_Image_Editor_GD::supports_mime_type
     37         */
    3538        public function test_supports_mime_type_jpeg() {
    3639                $gd_image_editor = new WP_Image_Editor_GD( null );
    3740                $expected        = (bool) ( imagetypes() & IMG_JPG );
     
    3841                $this->assertSame( $expected, $gd_image_editor->supports_mime_type( 'image/jpeg' ) );
    3942        }
    4043
     44        /**
     45         * @covers WP_Image_Editor_GD::supports_mime_type
     46         */
    4147        public function test_supports_mime_type_png() {
    4248                $gd_image_editor = new WP_Image_Editor_GD( null );
    4349                $expected        = (bool) ( imagetypes() & IMG_PNG );
     
    4450                $this->assertSame( $expected, $gd_image_editor->supports_mime_type( 'image/png' ) );
    4551        }
    4652
     53        /**
     54         * @covers WP_Image_Editor_GD::supports_mime_type
     55         */
    4756        public function test_supports_mime_type_gif() {
    4857                $gd_image_editor = new WP_Image_Editor_GD( null );
    4958                $expected        = (bool) ( imagetypes() & IMG_GIF );
     
    5261
    5362        /**
    5463         * Test resizing an image, not using crop
     64         *
     65         * @covers WP_Image_Editor_GD::resize
    5566         */
    5667        public function test_resize() {
    5768                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    7283
    7384        /**
    7485         * Test multi_resize with single image resize and no crop
     86         *
     87         * @covers WP_Image_Editor_GD::multi_resize
    7588         */
    7689        public function test_single_multi_resize() {
    7790                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    114127         * both height and weight are missing, null, or 0.
    115128         *
    116129         * ticket 26823
     130         *
     131         * @covers WP_Image_Editor_GD::multi_resize
    117132         */
    118133        public function test_multi_resize_does_not_create() {
    119134                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    182197         * Test multi_resize with multiple sizes
    183198         *
    184199         * ticket 26823
     200         *
     201         * @covers WP_Image_Editor_GD::multi_resize
    185202         */
    186203        public function test_multi_resize() {
    187204                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    386403
    387404        /**
    388405         * Test resizing an image with cropping
     406         *
     407         * @covers WP_Image_Editor_GD::resize
    389408         */
    390409        public function test_resize_and_crop() {
    391410                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    406425
    407426        /**
    408427         * Test cropping an image
     428         *
     429         * @covers WP_Image_Editor_GD::crop
    409430         */
    410431        public function test_crop() {
    411432                $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     
    426447
    427448        /**
    428449         * Test rotating an image 180 deg
     450         *
     451         * @covers WP_Image_Editor_GD::rotate
    429452         */
    430453        public function test_rotate() {
    431454                $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     
    445468
    446469        /**
    447470         * Test flipping an image
     471         *
     472         * @covers WP_Image_Editor_GD::flip
    448473         */
    449474        public function test_flip() {
    450475                $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     
    466491         * Test the image created with WP_Image_Editor_GD preserves alpha when resizing
    467492         *
    468493         * @ticket 23039
     494         *
     495         * @covers WP_Image_Editor_GD::resize
    469496         */
    470497        public function test_image_preserves_alpha_on_resize() {
    471498                if ( ! ( imagetypes() & IMG_PNG ) ) {
     
    493520         * Test the image created with WP_Image_Editor_GD preserves alpha with no resizing etc
    494521         *
    495522         * @ticket 23039
     523         *
     524         * @covers WP_Image_Editor_GD::load
    496525         */
    497526        public function test_image_preserves_alpha() {
    498527                if ( ! ( imagetypes() & IMG_PNG ) ) {
     
    518547
    519548        /**
    520549         * @ticket 30596
     550         *
     551         * @covers WP_Image_Editor_GD::rotate
    521552         */
    522553        public function test_image_preserves_alpha_on_rotate() {
    523554                if ( ! ( imagetypes() & IMG_PNG ) ) {
     
    546577         * Test WP_Image_Editor_GD handles extension-less images
    547578         *
    548579         * @ticket 39195
     580         *
     581         * @covers WP_Image_Editor_GD::load
    549582         */
    550583        public function test_image_non_existent_extension() {
    551584                $image_editor = new WP_Image_Editor_GD( DIR_TESTDATA . '/images/test-image-no-extension' );
  • tests/phpunit/tests/image/editorImagick.php

     
    4646
    4747        /**
    4848         * Test resizing an image, not using crop
     49         *
     50         * @covers WP_Image_Editor_GD::resize
    4951         */
    5052        public function test_resize() {
    5153                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    6668
    6769        /**
    6870         * Test multi_resize with single image resize and no crop
     71         *
     72         * @covers WP_Image_Editor_GD::multi_resize
    6973         */
    7074        public function test_single_multi_resize() {
    7175                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    108112         * both height and weight are missing, null, or 0.
    109113         *
    110114         * ticket 26823
     115         *
     116         * @covers WP_Image_Editor_GD::multi_resize
    111117         */
    112118        public function test_multi_resize_does_not_create() {
    113119                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    176182         * Test multi_resize with multiple sizes
    177183         *
    178184         * ticket 26823
     185         *
     186         * @covers WP_Image_Editor_GD::multi_resize
    179187         */
    180188        public function test_multi_resize() {
    181189                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    380388
    381389        /**
    382390         * Test resizing an image with cropping
     391         *
     392         * @covers WP_Image_Editor_GD::resize
    383393         */
    384394        public function test_resize_and_crop() {
    385395                $file = DIR_TESTDATA . '/images/waffles.jpg';
     
    400410
    401411        /**
    402412         * Test cropping an image
     413         *
     414         * @covers WP_Image_Editor_GD::crop
    403415         */
    404416        public function test_crop() {
    405417                $file = DIR_TESTDATA . '/images/gradient-square.jpg';
     
    420432
    421433        /**
    422434         * Test rotating an image 180 deg
     435         *
     436         * @covers WP_Image_Editor_GD::rotate
    423437         */
    424438        public function test_rotate() {
    425439                $file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
     
    439453
    440454        /**
    441455         * Test flipping an image
     456         *
     457         * @covers WP_Image_Editor_GD::flip
    442458         */
    443459        public function test_flip() {
    444460                $file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png';
     
    460476         * Test the image created with WP_Image_Editor_Imagick preserves alpha when resizing
    461477         *
    462478         * @ticket 24871
     479         *
     480         * @covers WP_Image_Editor_GD::resize
    463481         */
    464482        public function test_image_preserves_alpha_on_resize() {
    465483                $file = DIR_TESTDATA . '/images/transparent.png';
     
    484502         * Test the image created with WP_Image_Editor_Imagick preserves alpha with no resizing etc
    485503         *
    486504         * @ticket 24871
     505         *
     506         * @covers WP_Image_Editor_GD::load
    487507         */
    488508        public function test_image_preserves_alpha() {
    489509                $file = DIR_TESTDATA . '/images/transparent.png';
     
    506526
    507527        /**
    508528         * @ticket 30596
     529         *
     530         * @covers WP_Image_Editor_GD::rotate
    509531         */
    510532        public function test_image_preserves_alpha_on_rotate() {
    511533                $file = DIR_TESTDATA . '/images/transparent.png';
     
    530552         * Test WP_Image_Editor_Imagick handles extension-less images
    531553         *
    532554         * @ticket 39195
     555         *
     556         * @covers WP_Image_Editor_GD::load
    533557         */
    534558        public function test_image_non_existent_extension() {
    535559                $image_editor = new WP_Image_Editor_Imagick( DIR_TESTDATA . '/images/test-image-no-extension' );
     
    543567         *
    544568         * @ticket 37140
    545569         * @requires function exif_read_data
     570         *
     571         * @covers WP_Image_Editor_GD::rotate
    546572         */
    547573        public function test_remove_orientation_data_on_rotate() {
    548574                $file = DIR_TESTDATA . '/images/test-image-upside-down.jpg';
     
    570596
    571597        /**
    572598         * Test that images can be loaded and written over streams
     599         *
     600         * @covers WP_Image_Editor_GD::load
    573601         */
    574602        public function test_streams() {
    575603                stream_wrapper_register( 'wptest', 'WP_Test_Stream' );
     
    600628
    601629        /**
    602630         * @ticket 51665
     631         *
     632         * @covers WP_Image_Editor_GD::save
    603633         */
    604634        public function test_directory_creation() {
    605635                $file      = realpath( DIR_TESTDATA ) . '/images/a2-small.jpg';
  • tests/phpunit/tests/image/functions.php

     
    4545                return $mime_type;
    4646        }
    4747
     48        /**
     49         * @covers ::file_is_valid_image
     50         */
    4851        function test_is_image_positive() {
    4952                // These are all image files recognized by PHP.
    5053                $files = array(
     
    7174                }
    7275        }
    7376
     77        /**
     78         * @covers ::file_is_valid_image
     79         */
    7480        function test_is_image_negative() {
    7581                // These are actually image files but aren't recognized or usable by PHP.
    7682                $files = array(
     
    8490                }
    8591        }
    8692
     93        /**
     94         * @covers ::file_is_displayable_image
     95         */
    8796        function test_is_displayable_image_positive() {
    8897                // These are all usable in typical web browsers.
    8998                $files = array(
     
    102111                }
    103112        }
    104113
     114        /**
     115         * @covers ::file_is_displayable_image
     116         */
    105117        function test_is_displayable_image_negative() {
    106118                // These are image files but aren't suitable for web pages because of compatibility or size issues.
    107119                $files = array(
     
    126138
    127139        /**
    128140         * @ticket 50833
     141         *
     142         * @covers ::is_gd_image
    129143         */
    130144        function test_is_gd_image_invalid_types() {
    131145                $this->assertFalse( is_gd_image( new stdClass() ) );
     
    140154        /**
    141155         * @ticket 50833
    142156         * @requires extension gd
     157         *
     158         * @covers ::is_gd_image
    143159         */
    144160        function test_is_gd_image_valid_types() {
    145161                $this->assertTrue( is_gd_image( imagecreate( 5, 5 ) ) );
     
    150166         *
    151167         * @ticket 6821
    152168         * @requires extension fileinfo
     169         *
     170         * @covers ::wp_save_image_file
    153171         */
    154172        public function test_wp_save_image_file() {
    155173                $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
     
    206224         *
    207225         * @ticket 6821
    208226         * @requires extension fileinfo
     227         *
     228         * @covers WP_Image_Editor_GD::save
     229         * @covers WP_Image_Editor_Imagick::save
    209230         */
    210231        public function test_mime_overrides_filename() {
    211232                $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
     
    248269         *
    249270         * @ticket 6821
    250271         * @requires extension fileinfo
     272         *
     273         * @covers WP_Image_Editor_GD::save
     274         * @covers WP_Image_Editor_Imagick::save
    251275         */
    252276        public function test_inferred_mime_types() {
    253277                $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' );
     
    306330         *
    307331         * @ticket 17814
    308332         * @expectedDeprecated wp_load_image
     333         *
     334         * @covers WP_Image_Editor_GD::load
     335         * @covers WP_Image_Editor_Imagick::load
    309336         */
    310337        public function test_load_directory() {
    311338
     
    341368
    342369        /**
    343370         * @requires function imagejpeg
     371         *
     372         * @covers ::wp_crop_image
    344373         */
    345374        public function test_wp_crop_image_file() {
    346375                $file = wp_crop_image(
     
    365394        /**
    366395         * @requires function imagejpeg
    367396         * @requires extension openssl
     397         *
     398         * @covers ::wp_crop_image
    368399         */
    369400        public function test_wp_crop_image_url() {
    370401                $file = wp_crop_image(
     
    393424                unlink( $file );
    394425        }
    395426
     427        /**
     428         * @covers ::wp_crop_image
     429         */
    396430        public function test_wp_crop_image_file_not_exist() {
    397431                $file = wp_crop_image(
    398432                        DIR_TESTDATA . '/images/canoladoesnotexist.jpg',
     
    408442
    409443        /**
    410444         * @requires extension openssl
     445         *
     446         * @covers ::wp_crop_image
    411447         */
    412448        public function test_wp_crop_image_url_not_exist() {
    413449                $file = wp_crop_image(
     
    428464
    429465        /**
    430466         * @ticket 23325
     467         *
     468         * @covers ::wp_crop_image
    431469         */
    432470        public function test_wp_crop_image_error_on_saving() {
    433471                WP_Image_Editor_Mock::$save_return = new WP_Error();
     
    450488
    451489        /**
    452490         * @ticket 31050
     491         *
     492         * @covers ::wp_generate_attachment_metadata
    453493         */
    454494        public function test_wp_generate_attachment_metadata_pdf() {
    455495                if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) {
     
    518558         * Crop setting for PDF.
    519559         *
    520560         * @ticket 43226
     561         *
     562         * @covers ::wp_generate_attachment_metadata
    521563         */
    522564        public function test_crop_setting_for_pdf() {
    523565                if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) {
     
    585627
    586628        /**
    587629         * @ticket 39231
     630         *
     631         * @covers ::wp_generate_attachment_metadata
    588632         */
    589633        public function test_fallback_intermediate_image_sizes() {
    590634                if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) {
     
    645689         * Test PDF preview doesn't overwrite existing JPEG.
    646690         *
    647691         * @ticket 39875
     692         *
     693         * @covers ::wp_generate_attachment_metadata
    648694         */
    649695        public function test_pdf_preview_doesnt_overwrite_existing_jpeg() {
    650696                if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) {
  • tests/phpunit/tests/image/header.php

     
    1313                $this->custom_image_header = new Custom_Image_Header( '__return_null' );
    1414        }
    1515
     16        /**
     17         * @covers Custom_Image_Header::get_header_dimensions
     18         */
    1619        function test_header_image_has_correct_dimensions_with_max_width() {
    1720                global $_wp_theme_features;
    1821
     
    3336
    3437        }
    3538
     39        /**
     40         * @covers Custom_Image_Header::get_header_dimensions
     41         */
    3642        function test_header_image_has_correct_dimensions_with_fixed() {
    3743                global $_wp_theme_features;
    3844
     
    5359
    5460        }
    5561
     62        /**
     63         * @covers Custom_Image_Header::get_header_dimensions
     64         */
    5665        function test_header_image_has_correct_dimensions_with_flex_height() {
    5766                global $_wp_theme_features;
    5867
     
    7382
    7483        }
    7584
     85        /**
     86         * @covers Custom_Image_Header::get_header_dimensions
     87         */
    7688        function test_header_image_has_correct_dimensions_with_flex_width() {
    7789                global $_wp_theme_features;
    7890
     
    93105
    94106        }
    95107
     108        /**
     109         * @covers Custom_Image_Header::get_header_dimensions
     110         */
    96111        function test_header_image_has_correct_dimensions_with_flex_width_and_height() {
    97112                global $_wp_theme_features;
    98113
     
    113128
    114129        }
    115130
     131        /**
     132         * @covers Custom_Image_Header::create_attachment_object
     133         */
    116134        function test_create_attachment_object() {
    117135                $id = wp_insert_attachment(
    118136                        array(
     
    132150                $this->assertSame( 'image/jpeg', $object['post_mime_type'] );
    133151        }
    134152
     153        /**
     154         * @covers Custom_Image_Header::create_attachment_object
     155         * @covers Custom_Image_Header::insert_attachment
     156         */
    135157        function test_insert_cropped_attachment() {
    136158                $id = wp_insert_attachment(
    137159                        array(
     
    153175
    154176        /**
    155177         * @ticket 21819
     178         *
     179         * @covers Custom_Image_Header::create_attachment_object
     180         * @covers Custom_Image_Header::get_previous_crop
     181         * @covers Custom_Image_Header::insert_attachment
    156182         */
    157183        function test_check_get_previous_crop() {
    158184                $id = wp_insert_attachment(
  • tests/phpunit/tests/image/intermediateSize.php

     
    2222                return parent::_make_attachment( $upload, $parent_post_id );
    2323        }
    2424
     25        /**
     26         * @covers ::image_make_intermediate_size
     27         */
    2528        function test_make_intermediate_size_no_size() {
    2629                $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 0, false );
    2730
     
    3033
    3134        /**
    3235         * @requires function imagejpeg
     36         *
     37         * @covers ::image_make_intermediate_size
    3338         */
    3439        function test_make_intermediate_size_width() {
    3540                $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false );
     
    3944
    4045        /**
    4146         * @requires function imagejpeg
     47         *
     48         * @covers ::image_make_intermediate_size
    4249         */
    4350        function test_make_intermediate_size_height() {
    4451                $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false );
     
    4855
    4956        /**
    5057         * @requires function imagejpeg
     58         *
     59         * @covers ::image_make_intermediate_size
    5160         */
    5261        function test_make_intermediate_size_successful() {
    5362                $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true );
     
    6574        /**
    6675         * @ticket 17626
    6776         * @requires function imagejpeg
     77         *
     78         * @covers ::image_make_intermediate_size
    6879         */
    6980        function test_get_intermediate_sizes_by_name() {
    7081                add_image_size( 'test-size', 330, 220, true );
     
    8697        /**
    8798         * @ticket 17626
    8899         * @requires function imagejpeg
     100         *
     101         * @covers ::image_make_intermediate_size
    89102         */
    90103        function test_get_intermediate_sizes_by_array_exact() {
    91104                // Only one dimention match shouldn't return false positive (see: #17626).
     
    108121        /**
    109122         * @ticket 17626
    110123         * @requires function imagejpeg
     124         *
     125         * @covers ::image_make_intermediate_size
    111126         */
    112127        function test_get_intermediate_sizes_by_array_nearest() {
    113128                // If an exact size is not found, it should be returned.
     
    130145
    131146        /**
    132147         * @ticket 17626
     148         *
     149         * @covers ::image_make_intermediate_size
    133150         */
    134151        function test_get_intermediate_sizes_by_array_nearest_false() {
    135152                // If an exact size is not found, it should be returned.
     
    152169        /**
    153170         * @ticket 17626
    154171         * @requires function imagejpeg
     172         *
     173         * @covers ::image_make_intermediate_size
    155174         */
    156175        function test_get_intermediate_sizes_by_array_zero_height() {
    157176                // Generate random width.
     
    181200         * @ticket 17626
    182201         * @ticket 34087
    183202         * @requires function imagejpeg
     203         *
     204         * @covers ::image_make_intermediate_size
    184205         */
    185206        function test_get_intermediate_sizes_by_array_zero_width() {
    186207                // 202 is the smallest height that will trigger a miss for 'false-height'.
     
    210231         * @ticket 17626
    211232         * @ticket 34087
    212233         * @requires function imagejpeg
     234         *
     235         * @covers ::image_make_intermediate_size
    213236         */
    214237        public function test_get_intermediate_sizes_should_match_size_with_off_by_one_aspect_ratio() {
    215238                // Original is 600x400. 300x201 is close enough to match.
     
    234257        /**
    235258         * @ticket 34384
    236259         * @requires function imagejpeg
     260         *
     261         * @covers ::image_make_intermediate_size
    237262         */
    238263        public function test_get_intermediate_size_with_small_size_array() {
    239264                // Add a hard cropped size that matches the aspect ratio we're going to test.
     
    252277        /**
    253278         * @ticket 34384
    254279         * @requires function imagejpeg
     280         *
     281         * @covers ::image_make_intermediate_size
    255282         */
    256283        public function test_get_intermediate_size_with_small_size_array_fallback() {
    257284                $file = DIR_TESTDATA . '/images/waffles.jpg';
  • tests/phpunit/tests/image/meta.php

     
    99 */
    1010class Tests_Image_Meta extends WP_UnitTestCase {
    1111
     12        /**
     13         * @covers ::wp_read_image_metadata
     14         */
    1215        function test_exif_d70() {
    1316                // Exif from a Nikon D70.
    1417                $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0008.jpg' );
     
    2528                $this->assertSame( '', $out['title'] );
    2629        }
    2730
     31        /**
     32         * @covers ::wp_read_image_metadata
     33         */
    2834        function test_exif_d70_mf() {
    2935                // Exif from a Nikon D70 - manual focus lens, so some data is unavailable.
    3036                $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG' );
     
    4248                // $this->assertSame( array( 'Flowers' ), $out['keywords'] );
    4349        }
    4450
     51        /**
     52         * @covers ::wp_read_image_metadata
     53         */
    4554        function test_exif_d70_iptc() {
    4655                // Exif from a Nikon D70 with IPTC data added later.
    4756                $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0007.jpg' );
     
    5867                $this->assertSame( 'IPTC Headline', $out['title'] );
    5968        }
    6069
     70        /**
     71         * @covers ::wp_read_image_metadata
     72         */
    6173        function test_exif_fuji() {
    6274                // Exif from a Fuji FinePix S5600 (thanks Mark).
    6375                $out = wp_read_image_metadata( DIR_TESTDATA . '/images/a2-small.jpg' );
     
    7789
    7890        /**
    7991         * @ticket 6571
     92         *
     93         * @covers ::wp_read_image_metadata
    8094         */
    8195        function test_exif_error() {
    8296                // https://core.trac.wordpress.org/ticket/6571
     
    95109                $this->assertSame( '', $out['title'] );
    96110        }
    97111
     112        /**
     113         * @covers ::wp_read_image_metadata
     114         */
    98115        function test_exif_no_data() {
    99116                // No Exif data in this image (from burningwell.org).
    100117                $out = wp_read_image_metadata( DIR_TESTDATA . '/images/canola.jpg' );
     
    113130
    114131        /**
    115132         * @ticket 9417
     133         *
     134         * @covers ::wp_read_image_metadata
    116135         */
    117136        function test_utf8_iptc_tags() {
    118137                // Trilingual UTF-8 text in the ITPC caption-abstract field.
     
    123142
    124143        /**
    125144         * wp_read_image_metadata() should return false if the image file doesn't exist.
     145         *
     146         * @covers ::wp_read_image_metadata
    126147         */
    127148        public function test_missing_image_file() {
    128149                $out = wp_read_image_metadata( DIR_TESTDATA . '/images/404_image.png' );
     
    132153
    133154        /**
    134155         * @ticket 33772
     156         *
     157         * @covers ::wp_read_image_metadata
    135158         */
    136159        public function test_exif_keywords() {
    137160                $out = wp_read_image_metadata( DIR_TESTDATA . '/images/33772.jpg' );
  • tests/phpunit/tests/image/resize.php

     
    2626                return array( $this->editor_engine );
    2727        }
    2828
     29        /**
     30         * @covers WP_Image_Editor::resize
     31         */
    2932        function test_resize_jpg() {
    3033                $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 );
    3134
     
    3841                unlink( $image );
    3942        }
    4043
     44        /**
     45         * @covers WP_Image_Editor::resize
     46         */
    4147        function test_resize_png() {
    4248                $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.png', 25, 25 );
    4349
     
    5460                unlink( $image );
    5561        }
    5662
     63        /**
     64         * @covers WP_Image_Editor::resize
     65         */
    5766        function test_resize_gif() {
    5867                $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.gif', 25, 25 );
    5968
     
    7079                unlink( $image );
    7180        }
    7281
     82        /**
     83         * @covers WP_Image_Editor::resize
     84         */
    7385        function test_resize_larger() {
    7486                // image_resize() should refuse to make an image larger.
    7587                $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 100, 100 );
     
    7890                $this->assertSame( 'error_getting_dimensions', $image->get_error_code() );
    7991        }
    8092
     93        /**
     94         * @covers WP_Image_Editor::resize
     95         */
    8196        function test_resize_thumb_128x96() {
    8297                $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 );
    8398
     
    90105                unlink( $image );
    91106        }
    92107
     108        /**
     109         * @covers WP_Image_Editor::resize
     110         */
    93111        function test_resize_thumb_128x0() {
    94112                $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 );
    95113
     
    102120                unlink( $image );
    103121        }
    104122
     123        /**
     124         * @covers WP_Image_Editor::resize
     125         */
    105126        function test_resize_thumb_0x96() {
    106127                $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 );
    107128
     
    114135                unlink( $image );
    115136        }
    116137
     138        /**
     139         * @covers WP_Image_Editor::resize
     140         */
    117141        function test_resize_thumb_150x150_crop() {
    118142                $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true );
    119143
     
    126150                unlink( $image );
    127151        }
    128152
     153        /**
     154         * @covers WP_Image_Editor::resize
     155         */
    129156        function test_resize_thumb_150x100_crop() {
    130157                $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 100, true );
    131158
     
    138165                unlink( $image );
    139166        }
    140167
     168        /**
     169         * @covers WP_Image_Editor::resize
     170         */
    141171        function test_resize_thumb_50x150_crop() {
    142172                $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true );
    143173
     
    154184         * Try resizing a non-existent image
    155185         *
    156186         * @ticket 6821
     187         *
     188         * @covers WP_Image_Editor::resize
    157189         */
    158190        public function test_resize_non_existent_image() {
    159191                $image = $this->resize_helper( DIR_TESTDATA . '/images/test-non-existent-image.jpg', 25, 25 );
  • tests/phpunit/tests/image/resizeGd.php

     
    2828         * Try resizing a php file (bad image)
    2929         *
    3030         * @ticket 6821
     31         *
     32         * @covers WP_Image_Editor::resize
    3133         */
    3234        public function test_resize_bad_image() {
    3335
  • tests/phpunit/tests/image/resizeImagick.php

     
    1414         * Use the Imagick image editor engine
    1515         *
    1616         * @var string
     17         *
     18         * @covers WP_Image_Editor::resize
    1719         */
    1820        public $editor_engine = 'WP_Image_Editor_Imagick';
    1921
  • tests/phpunit/tests/image/siteIcon.php

     
    2828                remove_theme_mod( 'custom_logo' );
    2929        }
    3030
     31        /**
     32         * @covers WP_Site_Icon::intermediate_image_sizes
     33         */
    3134        function test_intermediate_image_sizes() {
    3235                $image_sizes = $this->wp_site_icon->intermediate_image_sizes( array() );
    3336
     
    3942                $this->assertSame( $sizes, $image_sizes );
    4043        }
    4144
     45        /**
     46         * @covers WP_Site_Icon::intermediate_image_sizes
     47         */
    4248        function test_intermediate_image_sizes_with_filter() {
    4349                add_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) );
    4450                $image_sizes = $this->wp_site_icon->intermediate_image_sizes( array() );
     
    6066                remove_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) );
    6167        }
    6268
     69        /**
     70         * @covers WP_Site_Icon::additional_sizes
     71         */
    6372        function test_additional_sizes() {
    6473                $image_sizes = $this->wp_site_icon->additional_sizes( array() );
    6574
     
    7584                $this->assertSame( $sizes, $image_sizes );
    7685        }
    7786
     87        /**
     88         * @covers WP_Site_Icon::additional_sizes
     89         */
    7890        function test_additional_sizes_with_filter() {
    7991                add_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) );
    8092                $image_sizes = $this->wp_site_icon->additional_sizes( array() );
     
    98110                unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] );
    99111        }
    100112
     113        /**
     114         * @covers WP_Site_Icon::create_attachment_object
     115         */
    101116        function test_create_attachment_object() {
    102117                $attachment_id = $this->_insert_attachment();
    103118                $parent_url    = get_post( $attachment_id )->guid;
     
    112127                $this->assertSame( $object['guid'], $cropped );
    113128        }
    114129
     130        /**
     131         * @covers WP_Site_Icon::create_attachment_object
     132         * @covers WP_Site_Icon::insert_attachment
     133         */
    115134        function test_insert_cropped_attachment() {
    116135                $attachment_id = $this->_insert_attachment();
    117136                $parent_url    = get_post( $attachment_id )->guid;
     
    124143                $this->assertGreaterThan( 0, $cropped_id );
    125144        }
    126145
     146        /**
     147         * @covers ::wp_delete_attachment
     148         */
    127149        function test_delete_attachment_data() {
    128150                $attachment_id = $this->_insert_attachment();
    129151                update_option( 'site_icon', $attachment_id );
     
    135157
    136158        /**
    137159         * @ticket 34368
     160         *
     161         * @covers WP_Site_Icon::get_post_metadata
    138162         */
    139163        function test_get_post_metadata() {
    140164                $attachment_id = $this->_insert_attachment();
  • tests/phpunit/tests/image/size.php

     
    77 */
    88class Tests_Image_Size extends WP_UnitTestCase {
    99
     10        /**
     11         * @covers ::wp_constrain_dimensions
     12         */
    1013        function test_constrain_dims_zero() {
    1114                // No constraint - should have no effect.
    1215                $out = wp_constrain_dimensions( 640, 480, 0, 0 );
     
    2225                $this->assertSame( array( 118, 177 ), $out );
    2326        }
    2427
     28        /**
     29         * @covers ::wp_constrain_dimensions
     30         */
    2531        function test_constrain_dims_smaller() {
    2632                // Image size is smaller than the constraint - no effect.
    2733                $out = wp_constrain_dimensions( 500, 600, 1024, 768 );
     
    3440                $this->assertSame( array( 500, 600 ), $out );
    3541        }
    3642
     43        /**
     44         * @covers ::wp_constrain_dimensions
     45         */
    3746        function test_constrain_dims_equal() {
    3847                // Image size is equal to the constraint - no effect.
    3948                $out = wp_constrain_dimensions( 1024, 768, 1024, 768 );
     
    4655                $this->assertSame( array( 1024, 768 ), $out );
    4756        }
    4857
     58        /**
     59         * @covers ::wp_constrain_dimensions
     60         */
    4961        function test_constrain_dims_larger() {
    5062                // Image size is larger than the constraint - result should be constrained.
    5163                $out = wp_constrain_dimensions( 1024, 768, 500, 600 );
     
    6880                $this->assertSame( array( 200, 533 ), $out );
    6981        }
    7082
     83        /**
     84         * @covers ::wp_constrain_dimensions
     85         */
    7186        function test_constrain_dims_boundary() {
    7287                // One dimension is larger than the constraint, one smaller - result should be constrained.
    7388                $out = wp_constrain_dimensions( 1024, 768, 500, 800 );
     
    86101
    87102        /**
    88103         * @expectedDeprecated wp_shrink_dimensions
     104         *
     105         * @covers ::wp_shrink_dimensions
    89106         */
    90107        function test_shrink_dimensions_default() {
    91108                $out = wp_shrink_dimensions( 640, 480 );
     
    97114
    98115        /**
    99116         * @expectedDeprecated wp_shrink_dimensions
     117         *
     118         * @covers ::wp_shrink_dimensions
    100119         */
    101120        function test_shrink_dimensions_smaller() {
    102121                // Image size is smaller than the constraint - no effect.
     
    109128
    110129        /**
    111130         * @expectedDeprecated wp_shrink_dimensions
     131         *
     132         * @covers ::wp_shrink_dimensions
    112133         */
    113134        function test_shrink_dimensions_equal() {
    114135                // Image size is equal to the constraint - no effect.
     
    121142
    122143        /**
    123144         * @expectedDeprecated wp_shrink_dimensions
     145         *
     146         * @covers ::wp_shrink_dimensions
    124147         */
    125148        function test_shrink_dimensions_larger() {
    126149                // Image size is larger than the constraint - result should be constrained.
     
    133156
    134157        /**
    135158         * @expectedDeprecated wp_shrink_dimensions
     159         *
     160         * @covers ::wp_shrink_dimensions
    136161         */
    137162        function test_shrink_dimensions_boundary() {
    138163                // One dimension is larger than the constraint, one smaller - result should be constrained.
     
    150175                $this->assertSame( array( 525, 700 ), $out );
    151176        }
    152177
     178        /**
     179         * @covers ::image_constrain_size_for_editor
     180         */
    153181        function test_constrain_size_for_editor_thumb() {
    154182                $out = image_constrain_size_for_editor( 600, 400, 'thumb' );
    155183                $this->assertSame( array( 150, 100 ), $out );
     
    158186                $this->assertSame( array( 64, 64 ), $out );
    159187        }
    160188
     189        /**
     190         * @covers ::image_constrain_size_for_editor
     191         */
    161192        function test_constrain_size_for_editor_medium() {
    162193                // Default max width is 500, no constraint on height.
    163194                global $content_width;
     
    185216                $content_width = $_content_width;
    186217        }
    187218
     219        /**
     220         * @covers ::image_constrain_size_for_editor
     221         */
    188222        function test_constrain_size_for_editor_full() {
    189223                global $content_width;
    190224
  • tests/phpunit/tests/import/import.php

     
    3939                parent::tearDown();
    4040        }
    4141
     42        /**
     43         * @covers WP_Import::import
     44         */
    4245        function test_small_import() {
    4346                global $wpdb;
    4447
     
    207210                $this->assertSame( 1, count( $cats ) );
    208211        }
    209212
     213        /**
     214         * @covers WP_Import::import
     215         */
    210216        function test_double_import() {
    211217                $authors = array(
    212218                        'admin'  => false,
     
    273279
    274280        /**
    275281         * @ticket 21007
     282         *
     283         * @covers WP_Import::import
    276284         */
    277285        public function test_slashes_should_not_be_stripped() {
    278286                global $wpdb;
  • tests/phpunit/tests/import/parser.php

     
    2424                require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
    2525        }
    2626
     27        /**
     28         * @covers WXR_Parser_SimpleXML::parse
     29         * @covers WXR_Parser_XML::parse
     30         */
    2731        function test_malformed_wxr() {
    2832                $file = DIR_TESTDATA . '/export/malformed.xml';
    2933
     
    3640                }
    3741        }
    3842
     43        /**
     44         * @covers WXR_Parser_SimpleXML::parse
     45         * @covers WXR_Parser_XML::parse
     46         * @covers WXR_Parser_Regex::parse
     47         */
    3948        function test_invalid_wxr() {
    4049                $f1 = DIR_TESTDATA . '/export/missing-version-tag.xml';
    4150                $f2 = DIR_TESTDATA . '/export/invalid-version-tag.xml';
     
    5059                }
    5160        }
    5261
     62        /**
     63         * @covers WXR_Parser_SimpleXML::parse
     64         * @covers WXR_Parser_XML::parse
     65         * @covers WXR_Parser_Regex::parse
     66         */
    5367        function test_wxr_version_1_1() {
    5468                $file = DIR_TESTDATA . '/export/valid-wxr-1.1.xml';
    5569
     
    143157                }
    144158        }
    145159
     160        /**
     161         * @covers WXR_Parser_SimpleXML::parse
     162         * @covers WXR_Parser_XML::parse
     163         * @covers WXR_Parser_Regex::parse
     164         */
    146165        function test_wxr_version_1_0() {
    147166                $file = DIR_TESTDATA . '/export/valid-wxr-1.0.xml';
    148167
     
    236255         * sections that contain escaped closing tags ("]]>" -> "]]]]><![CDATA[>").
    237256         *
    238257         * @link https://core.trac.wordpress.org/ticket/15203
     258         *
     259         * @covers WXR_Parser_SimpleXML::parse
     260         * @covers WXR_Parser_XML::parse
     261         * @covers WXR_Parser_Regex::parse
    239262         */
    240263        function test_escaped_cdata_closing_sequence() {
    241264                $file = DIR_TESTDATA . '/export/crazy-cdata-escaped.xml';
     
    269292        /**
    270293         * Ensure that the regex parser can still parse invalid CDATA blocks (i.e. those
    271294         * with "]]>" unescaped within a CDATA section).
     295         *
     296         * @covers WXR_Parser_Regex::parse
    272297         */
    273298        function test_unescaped_cdata_closing_sequence() {
    274299                $file = DIR_TESTDATA . '/export/crazy-cdata.xml';
  • tests/phpunit/tests/import/postmeta.php

     
    2424                require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php';
    2525        }
    2626
     27        /**
     28         * @covers WP_Import::import
     29         */
    2730        function test_serialized_postmeta_no_cdata() {
    2831                $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-no-cdata.xml', array( 'johncoswell' => 'john' ) );
    2932                $expected['special_post_title'] = 'A special title';
     
    3134                $this->assertSame( $expected, get_post_meta( 122, 'post-options', true ) );
    3235        }
    3336
     37        /**
     38         * @covers WP_Import::import
     39         */
    3440        function test_utw_postmeta() {
    3541                $this->_import_wp( DIR_TESTDATA . '/export/test-utw-post-meta-import.xml', array( 'johncoswell' => 'john' ) );
    3642
     
    7985
    8086        /**
    8187         * @ticket 9633
     88         *
     89         * @covers WP_Import::import
    8290         */
    8391        function test_serialized_postmeta_with_cdata() {
    8492                $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) );
     
    93101
    94102        /**
    95103         * @ticket 11574
     104         *
     105         * @covers WP_Import::import
    96106         */
    97107        function test_serialized_postmeta_with_evil_stuff_in_cdata() {
    98108                $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) );
  • tests/phpunit/tests/l10n/getLocale.php

     
    1919
    2020        /**
    2121         * @group ms-required
     22         *
     23         * @covers ::get_locale
    2224         */
    2325        public function test_local_option_should_take_precedence_on_multisite() {
    2426                global $locale;
     
    3638
    3739        /**
    3840         * @group ms-required
     41         *
     42         * @covers ::get_locale
    3943         */
    4044        public function test_network_option_should_be_fallback_on_multisite() {
    4145                if ( ! is_multisite() ) {
     
    5660
    5761        /**
    5862         * @group ms-excluded
     63         *
     64         * @covers ::get_locale
    5965         */
    6066        public function test_option_should_be_respected_on_nonmultisite() {
    6167                if ( is_multisite() ) {
     
    7581
    7682        }
    7783
     84        /**
     85         * @covers ::get_locale
     86         */
    7887        public function test_should_fall_back_on_en_US() {
    7988                global $locale;
    8089                $old_locale = $locale;
     
    8695                $this->assertSame( 'en_US', $found );
    8796        }
    8897
     98        /**
     99         * @covers ::get_locale
     100         */
    89101        public function test_should_respect_get_locale_filter() {
    90102                add_filter( 'locale', array( $this, 'filter_get_locale' ) );
    91103                $found = get_locale();
  • tests/phpunit/tests/l10n/getUserLocale.php

     
    2727                parent::tearDown();
    2828        }
    2929
     30        /**
     31         * @covers ::get_user_locale
     32         */
    3033        public function test_user_locale_property() {
    3134                set_current_screen( 'dashboard' );
    3235                $this->assertSame( 'de_DE', get_user_locale() );
     
    3336                $this->assertSame( get_user_by( 'id', $this->user_id )->locale, get_user_locale() );
    3437        }
    3538
     39        /**
     40         * @covers ::get_user_locale
     41         */
    3642        public function test_update_user_locale() {
    3743                set_current_screen( 'dashboard' );
    3844                update_user_meta( $this->user_id, 'locale', 'fr_FR' );
     
    3945                $this->assertSame( 'fr_FR', get_user_locale() );
    4046        }
    4147
     48        /**
     49         * @covers ::get_user_locale
     50         */
    4251        public function test_returns_site_locale_if_empty() {
    4352                set_current_screen( 'dashboard' );
    4453                update_user_meta( $this->user_id, 'locale', '' );
     
    4554                $this->assertSame( get_locale(), get_user_locale() );
    4655        }
    4756
     57        /**
     58         * @covers ::get_user_locale
     59         */
    4860        public function test_returns_site_locale_if_no_user() {
    4961                wp_set_current_user( 0 );
    5062                $this->assertSame( get_locale(), get_user_locale() );
    5163        }
    5264
     65        /**
     66         * @covers ::get_user_locale
     67         */
    5368        public function test_returns_correct_user_locale() {
    5469                set_current_screen( 'dashboard' );
    5570                $this->assertSame( 'de_DE', get_user_locale() );
    5671        }
    5772
     73        /**
     74         * @covers ::get_user_locale
     75         */
    5876        public function test_returns_correct_user_locale_on_frontend() {
    5977                $this->assertSame( 'de_DE', get_user_locale() );
    6078        }
    6179
     80        /**
     81         * @covers ::get_user_locale
     82         */
    6283        public function test_site_locale_is_not_affected() {
    6384                set_current_screen( 'dashboard' );
    6485                $this->assertSame( 'en_US', get_locale() );
    6586        }
    6687
     88        /**
     89         * @covers ::get_user_locale
     90         */
    6791        public function test_site_locale_is_not_affected_on_frontend() {
    6892                $this->assertSame( 'en_US', get_locale() );
    6993        }
     
    7094
    7195        /**
    7296         * @group ms-required
     97         *
     98         * @covers ::get_user_locale
    7399         */
    74100        public function test_user_locale_is_same_across_network() {
    75101                if ( ! is_multisite() ) {
     
    86112                $this->assertSame( $user_locale, $user_locale_2 );
    87113        }
    88114
     115        /**
     116         * @covers ::get_user_locale
     117         */
    89118        public function test_user_id_argument_with_id() {
    90119                $user_id = $this->factory()->user->create(
    91120                        array(
     
    103132                $this->assertSame( get_locale(), $user_locale2 );
    104133        }
    105134
     135        /**
     136         * @covers ::get_user_locale
     137         */
    106138        public function test_user_id_argument_with_wp_user_object() {
    107139                $user_id = $this->factory()->user->create(
    108140                        array(
     
    122154                $this->assertSame( get_locale(), $user_locale2 );
    123155        }
    124156
     157        /**
     158         * @covers ::get_user_locale
     159         */
    125160        public function test_user_id_argument_with_nonexistent_user() {
    126161                global $wpdb;
    127162
     
    132167                $this->assertSame( get_locale(), $user_locale );
    133168        }
    134169
     170        /**
     171         * @covers ::get_user_locale
     172         */
    135173        public function test_user_id_argument_with_invalid_type() {
    136174                $user_locale = get_user_locale( 'string' );
    137175                $this->assertSame( get_locale(), $user_locale );
  • tests/phpunit/tests/l10n/loadScriptTextdomain.php

     
    1313         * @ticket 49145
    1414         *
    1515         * @dataProvider data_test_resolve_relative_path
     16         *
     17         * @covers ::file_get_contents
    1618         */
    1719        public function test_resolve_relative_path( $translation_path, $handle, $src, $textdomain, $filter = array() ) {
    1820                if ( ! empty( $filter ) ) {
  • tests/phpunit/tests/l10n/loadTextdomain.php

     
    3939                return $locale;
    4040        }
    4141
     42        /**
     43         * @covers ::is_textdomain_loaded
     44         */
    4245        public function test_is_textdomain_loaded() {
    4346                $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
    4447        }
    4548
     49        /**
     50         * @covers ::unload_textdomain
     51         */
    4652        public function test_unload_textdomain() {
    4753                $this->assertFalse( unload_textdomain( 'wp-tests-domain' ) );
    4854        }
    4955
     56        /**
     57         * @covers ::unload_textdomain
     58         */
    5059        public function test_load_textdomain() {
    5160                $loaded = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
    5261
     
    5564                $this->assertTrue( $loaded );
    5665        }
    5766
     67        /**
     68         * @covers ::unload_textdomain
     69         */
    5870        public function test_is_textdomain_loaded_after_loading() {
    5971                load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
    6072
     
    6577                $this->assertTrue( $loaded );
    6678        }
    6779
     80        /**
     81         * @covers ::unload_textdomain
     82         */
    6883        public function test_unload_textdomain_after_loading() {
    6984                load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
    7085
     
    7186                $this->assertTrue( unload_textdomain( 'wp-tests-domain' ) );
    7287        }
    7388
     89        /**
     90         * @covers ::is_textdomain_loaded
     91         */
    7492        public function test_is_textdomain_loaded_after_unloading() {
    7593                load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' );
    7694
     
    8199
    82100        /**
    83101         * @ticket 21319
     102         *
     103         * @covers ::load_textdomain
    84104         */
    85105        public function test_load_textdomain_non_existent_file() {
    86106                $this->assertFalse( load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ) );
     
    88108
    89109        /**
    90110         * @ticket 21319
     111         *
     112         * @covers ::is_textdomain_loaded
    91113         */
    92114        public function test_is_textdomain_loaded_non_existent_file() {
    93115                load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
     
    97119
    98120        /**
    99121         * @ticket 21319
     122         *
     123         * @covers ::get_translations_for_domain
    100124         */
    101125        public function test_get_translations_for_domain_non_existent_file() {
    102126                load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
     
    106130
    107131        /**
    108132         * @ticket 21319
     133         *
     134         * @covers ::unload_textdomain
    109135         */
    110136        public function test_unload_textdomain_non_existent_file() {
    111137                load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
     
    115141
    116142        /**
    117143         * @ticket 21319
     144         *
     145         * @covers ::is_textdomain_loaded
    118146         */
    119147        function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() {
    120148                $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
     
    122150                $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
    123151        }
    124152
     153        /**
     154         * @covers ::load_textdomain
     155         */
    125156        function test_override_load_textdomain_noop() {
    126157                add_filter( 'override_load_textdomain', '__return_true' );
    127158                $load_textdomain = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' );
     
    131162                $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) );
    132163        }
    133164
     165        /**
     166         * @covers ::load_textdomain
     167         */
    134168        function test_override_load_textdomain_non_existent_mofile() {
    135169                add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 );
    136170                $load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/non-existent-file.mo' );
     
    145179                $this->assertFalse( $is_textdomain_loaded_after );
    146180        }
    147181
     182        /**
     183         * @covers ::load_textdomain
     184         */
    148185        function test_override_load_textdomain_custom_mofile() {
    149186                add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 );
    150187                $load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo' );
     
    187224                return true;
    188225        }
    189226
     227        /**
     228         * @covers ::load_muplugin_textdomain
     229         */
    190230        public function test_load_muplugin_textdomain_site_locale() {
    191231                load_muplugin_textdomain( 'wp-tests-domain' );
    192232
     
    195235
    196236        /**
    197237         * @ticket 38485
     238         *
     239         * @covers ::load_muplugin_textdomain
    198240         */
    199241        public function test_load_muplugin_textdomain_user_locale() {
    200242                set_current_screen( 'dashboard' );
     
    207249                $this->assertSame( get_user_locale(), $this->locale );
    208250        }
    209251
     252        /**
     253         * @covers ::load_plugin_textdomain
     254         */
    210255        public function test_load_plugin_textdomain_site_locale() {
    211256                load_plugin_textdomain( 'wp-tests-domain' );
    212257
     
    215260
    216261        /**
    217262         * @ticket 38485
     263         *
     264         * @covers ::load_plugin_textdomain
    218265         */
    219266        public function test_load_plugin_textdomain_user_locale() {
    220267                set_current_screen( 'dashboard' );
     
    227274                $this->assertSame( get_user_locale(), $this->locale );
    228275        }
    229276
     277        /**
     278         * @covers ::load_theme_textdomain
     279         */
    230280        public function test_load_theme_textdomain_site_locale() {
    231281                load_theme_textdomain( 'wp-tests-domain' );
    232282
     
    235285
    236286        /**
    237287         * @ticket 38485
     288         *
     289         * @covers ::load_theme_textdomain
    238290         */
    239291        public function test_load_theme_textdomain_user_locale() {
    240292                set_current_screen( 'dashboard' );
  • tests/phpunit/tests/l10n/loadTextdomainJustInTime.php

     
    6565
    6666        /**
    6767         * @ticket 34114
     68         *
     69         * @covers ::is_textdomain_loaded
    6870         */
    6971        public function test_plugin_translation_should_be_translated_without_calling_load_plugin_textdomain() {
    7072                add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
     
    8486
    8587        /**
    8688         * @ticket 34114
     89         *
     90         * @covers ::is_textdomain_loaded
    8791         */
    8892        public function test_theme_translation_should_be_translated_without_calling_load_theme_textdomain() {
    8993                add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
     
    105109
    106110        /**
    107111         * @ticket 34114
     112         *
     113         * @covers ::get_translations_for_domain
    108114         */
    109115        public function test_get_translations_for_domain_does_not_return_null_if_override_load_textdomain_is_used() {
    110116                add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
     
    118124
    119125        /**
    120126         * @ticket 37113
     127         *
     128         * @covers ::is_textdomain_loaded
    121129         */
    122130        public function test_should_allow_unloading_of_text_domain() {
    123131                add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) );
     
    157165
    158166        /**
    159167         * @ticket 26511
     168         *
     169         * @covers ::switch_to_locale
    160170         */
    161171        public function test_plugin_translation_after_switching_locale() {
    162172                require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
     
    170180
    171181        /**
    172182         * @ticket 37997
     183         *
     184         * @covers ::switch_to_locale
    173185         */
    174186        public function test_plugin_translation_after_switching_locale_twice() {
    175187                require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
     
    188200
    189201        /**
    190202         * @ticket 26511
     203         *
     204         * @covers ::switch_to_locale
    191205         */
    192206        public function test_theme_translation_after_switching_locale() {
    193207                switch_theme( 'internationalized-theme' );
     
    205219
    206220        /**
    207221         * @ticket 38485
     222         *
     223         * @covers ::wp_set_current_user
    208224         */
    209225        public function test_plugin_translation_with_user_locale() {
    210226                require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php';
     
    221237
    222238        /**
    223239         * @ticket 38485
     240         *
     241         * @covers ::wp_set_current_user
    224242         */
    225243        public function test_theme_translation_with_user_locale() {
    226244                switch_theme( 'internationalized-theme' );
     
    239257
    240258        /**
    241259         * @ticket 37997
     260         *
     261         * @covers ::__
    242262         */
    243263        public function test_get_locale_is_called_only_once_per_textdomain() {
    244264                $textdomain = 'foo-bar-baz';
  • tests/phpunit/tests/l10n/localeSwitcher.php

     
    3535                parent::tearDown();
    3636        }
    3737
     38        /**
     39         * @covers ::switch_to_locale
     40         */
    3841        public function test_switch_to_non_existent_locale_returns_false() {
    3942                $this->assertFalse( switch_to_locale( 'foo_BAR' ) );
    4043        }
    4144
     45        /**
     46         * @covers ::switch_to_locale
     47         */
    4248        public function test_switch_to_non_existent_locale_does_not_change_locale() {
    4349                switch_to_locale( 'foo_BAR' );
    4450
     
    4551                $this->assertSame( 'en_US', get_locale() );
    4652        }
    4753
     54        /**
     55         * @covers ::switch_to_locale
     56         */
    4857        public function test_switch_to_locale_returns_true() {
    4958                $expected = switch_to_locale( 'en_GB' );
    5059
     
    5463                $this->assertTrue( $expected );
    5564        }
    5665
     66        /**
     67         * @covers ::switch_to_locale
     68         */
    5769        public function test_switch_to_locale_changes_the_locale() {
    5870                switch_to_locale( 'en_GB' );
    5971
     
    6577                $this->assertSame( 'en_GB', $locale );
    6678        }
    6779
     80        /**
     81         * @covers ::switch_to_locale
     82         */
    6883        public function test_switch_to_locale_loads_translation() {
    6984                switch_to_locale( 'es_ES' );
    7085
     
    7691                $this->assertSame( 'Parámetro no válido. ', $actual );
    7792        }
    7893
     94        /**
     95         * @covers ::switch_to_locale
     96         */
    7997        public function test_switch_to_locale_changes_wp_locale_global() {
    8098                global $wp_locale;
    8199
     
    94112                $this->assertSameSetsWithIndex( $expected, $wp_locale_de_de->number_format );
    95113        }
    96114
     115        /**
     116         * @covers ::switch_to_locale
     117         */
    97118        public function test_switch_to_locale_en_US() {
    98119                switch_to_locale( 'en_GB' );
    99120                $locale_en_gb = get_locale();
     
    107128                $this->assertSame( 'en_US', $locale_en_us );
    108129        }
    109130
     131        /**
     132         * @covers ::switch_to_locale
     133         * @covers ::restore_previous_locale
     134         */
    110135        public function test_switch_to_locale_multiple_times() {
    111136                switch_to_locale( 'en_GB' );
    112137                switch_to_locale( 'es_ES' );
     
    119144                $this->assertSame( 'es_ES', $locale );
    120145        }
    121146
     147        /**
     148         * @covers ::switch_to_locale
     149         * @covers ::restore_previous_locale
     150         */
    122151        public function test_switch_to_locale_multiple_times_loads_translation() {
    123152                switch_to_locale( 'en_GB' );
    124153                switch_to_locale( 'de_DE' );
     
    134163                $this->assertSame( 'Parámetro no válido. ', $actual );
    135164        }
    136165
     166        /**
     167         * @covers ::restore_previous_locale
     168         */
    137169        public function test_restore_previous_locale_without_switching() {
    138170                $this->assertFalse( restore_previous_locale() );
    139171        }
    140172
     173        /**
     174         * @covers ::switch_to_locale
     175         * @covers ::restore_previous_locale
     176         */
    141177        public function test_restore_previous_locale_changes_the_locale_back() {
    142178                switch_to_locale( 'en_GB' );
    143179
     
    147183                $this->assertSame( 'en_US', get_locale() );
    148184        }
    149185
     186        /**
     187         * @covers ::switch_to_locale
     188         * @covers ::restore_previous_locale
     189         */
    150190        public function test_restore_previous_locale_after_switching_multiple_times() {
    151191                switch_to_locale( 'en_GB' );
    152192                switch_to_locale( 'es_ES' );
     
    160200                $this->assertSame( 'en_GB', $locale );
    161201        }
    162202
     203        /**
     204         * @covers ::switch_to_locale
     205         * @covers ::restore_previous_locale
     206         */
    163207        public function test_restore_previous_locale_restores_translation() {
    164208                switch_to_locale( 'es_ES' );
    165209                restore_previous_locale();
     
    169213                $this->assertSame( 'Invalid parameter.', $actual );
    170214        }
    171215
     216        /**
     217         * @covers ::switch_to_locale
     218         * @covers ::restore_previous_locale
     219         */
    172220        public function test_restore_previous_locale_action_passes_previous_locale() {
    173221                switch_to_locale( 'en_GB' );
    174222                switch_to_locale( 'es_ES' );
     
    185233                $this->assertSame( 'es_ES', $previous_locale );
    186234        }
    187235
     236        /**
     237         * @covers ::switch_to_locale
     238         * @covers ::restore_previous_locale
     239         */
    188240        public function test_restore_previous_locale_restores_wp_locale_global() {
    189241                global $wp_locale;
    190242
     
    199251                $this->assertSameSetsWithIndex( $expected, $wp_locale->number_format );
    200252        }
    201253
     254        /**
     255         * @covers ::restore_previous_locale
     256         */
    202257        public function test_restore_current_locale_without_switching() {
    203258                $this->assertFalse( restore_current_locale() );
    204259        }
    205260
     261        /**
     262         * @covers ::switch_to_locale
     263         * @covers ::restore_previous_locale
     264         */
    206265        public function test_restore_current_locale_after_switching_multiple_times() {
    207266                switch_to_locale( 'en_GB' );
    208267                switch_to_locale( 'nl_NL' );
     
    218277                $this->previous_locale = $previous_locale;
    219278        }
    220279
     280        /**
     281         * @covers ::is_locale_switched
     282         */
    221283        public function test_is_locale_switched_if_not_switched() {
    222284                $this->assertFalse( is_locale_switched() );
    223285        }
    224286
     287        /**
     288         * @covers ::is_locale_switched
     289         */
    225290        public function test_is_locale_switched_original_locale() {
    226291                $original_locale = get_locale();
    227292
     
    235300                $this->assertTrue( $is_locale_switched );
    236301        }
    237302
     303        /**
     304         * @covers ::switch_to_locale
     305         * @covers ::restore_current_locale
     306         */
    238307        public function test_is_locale_switched() {
    239308                switch_to_locale( 'en_GB' );
    240309                switch_to_locale( 'nl_NL' );
     
    246315                $this->assertTrue( $is_locale_switched );
    247316        }
    248317
     318        /**
     319         * @covers ::wp_set_current_user
     320         * @covers ::restore_current_locale
     321         */
    249322        public function test_switch_to_site_locale_if_user_locale_is_set() {
    250323                global $l10n, $wp_locale_switcher;
    251324
     
    294367                $this->assertSame( 'de_DE', $language_header_after_restore );
    295368        }
    296369
     370        /**
     371         * @covers ::wp_set_current_user
     372         * @covers ::get_user_locale
     373         */
    297374        public function test_switch_to_different_site_locale_if_user_locale_is_set() {
    298375                global $l10n, $wp_locale_switcher;
    299376
     
    347424                $this->assertSame( 'de_DE', $language_header_after_restore );
    348425        }
    349426
     427        /**
     428         * @covers ::wp_set_current_user
     429         * @covers ::get_user_locale
     430         */
    350431        public function test_multiple_switches_to_site_locale_and_user_locale() {
    351432                global $wp_locale_switcher;
    352433