Ticket #39265: I_folders.patch
File I_folders.patch, 57.6 KB (added by , 4 years ago) |
---|
-
tests/phpunit/tests/image/dimensions.php
6 6 * @group upload 7 7 */ 8 8 class Tests_Image_Dimensions extends WP_UnitTestCase { 9 10 /** 11 * @covers ::image_resize_dimensions 12 */ 9 13 function test_400x400_no_crop() { 10 14 // Landscape: resize 640x480 to fit 400x400: 400x300. 11 15 $out = image_resize_dimensions( 640, 480, 400, 400, false ); … … 18 22 $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); 19 23 } 20 24 25 /** 26 * @covers ::image_resize_dimensions 27 */ 21 28 function test_400x0_no_crop() { 22 29 // Landscape: resize 640x480 to fit 400w: 400x300. 23 30 $out = image_resize_dimensions( 640, 480, 400, 0, false ); … … 30 37 $this->assertSame( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); 31 38 } 32 39 40 /** 41 * @covers ::image_resize_dimensions 42 */ 33 43 function test_0x400_no_crop() { 34 44 // Landscape: resize 640x480 to fit 400h: 533x400. 35 45 $out = image_resize_dimensions( 640, 480, 0, 400, false ); … … 42 52 $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); 43 53 } 44 54 55 /** 56 * @covers ::image_resize_dimensions 57 */ 45 58 function test_800x800_no_crop() { 46 59 // Landscape: resize 640x480 to fit 800x800. 47 60 $out = image_resize_dimensions( 640, 480, 800, 800, false ); … … 54 67 $this->assertFalse( $out ); 55 68 } 56 69 70 /** 71 * @covers ::image_resize_dimensions 72 */ 57 73 function test_800x0_no_crop() { 58 74 // Landscape: resize 640x480 to fit 800w. 59 75 $out = image_resize_dimensions( 640, 480, 800, 0, false ); … … 66 82 $this->assertFalse( $out ); 67 83 } 68 84 85 /** 86 * @covers ::image_resize_dimensions 87 */ 69 88 function test_0x800_no_crop() { 70 89 // Landscape: resize 640x480 to fit 800h. 71 90 $out = image_resize_dimensions( 640, 480, 0, 800, false ); … … 78 97 $this->assertFalse( $out ); 79 98 } 80 99 81 // Cropped versions. 82 100 /** 101 * Cropped versions. 102 * 103 * @covers ::image_resize_dimensions 104 */ 83 105 function test_400x400_crop() { 84 106 // Landscape: crop 640x480 to fit 400x400: 400x400 taken from a 480x480 crop at (80. 0). 85 107 $out = image_resize_dimensions( 640, 480, 400, 400, true ); … … 92 114 $this->assertSame( array( 0, 0, 0, 80, 400, 400, 480, 480 ), $out ); 93 115 } 94 116 117 /** 118 * @covers ::image_resize_dimensions 119 */ 95 120 function test_400x0_crop() { 96 121 // Landscape: resize 640x480 to fit 400w: 400x300. 97 122 $out = image_resize_dimensions( 640, 480, 400, 0, true ); … … 104 129 $this->assertSame( array( 0, 0, 0, 0, 400, 533, 480, 640 ), $out ); 105 130 } 106 131 132 /** 133 * @covers ::image_resize_dimensions 134 */ 107 135 function test_0x400_crop() { 108 136 // Landscape: resize 640x480 to fit 400h: 533x400. 109 137 $out = image_resize_dimensions( 640, 480, 0, 400, true ); … … 116 144 $this->assertSame( array( 0, 0, 0, 0, 300, 400, 480, 640 ), $out ); 117 145 } 118 146 147 /** 148 * @covers ::image_resize_dimensions 149 */ 119 150 function test_400x500_crop() { 120 151 // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop at (80. 0). 121 152 $out = image_resize_dimensions( 640, 480, 400, 500, true ); … … 128 159 $this->assertSame( array( 0, 0, 0, 20, 400, 500, 480, 600 ), $out ); 129 160 } 130 161 162 /** 163 * @covers ::image_resize_dimensions 164 */ 131 165 function test_640x480() { 132 166 // Crop 640x480 to fit 640x480 (no change). 133 167 $out = image_resize_dimensions( 640, 480, 640, 480, true ); … … 155 189 156 190 /** 157 191 * @ticket 19393 192 * 193 * @covers ::image_resize_dimensions 158 194 */ 159 195 function test_crop_anchors() { 160 196 // Landscape: crop 640x480 to fit 400x500: 400x400 taken from a 480x480 crop. -
tests/phpunit/tests/image/editor.php
26 26 * Test wp_get_image_editor() where load returns true 27 27 * 28 28 * @ticket 6821 29 * 30 * @covers ::wp_get_image_editor 29 31 */ 30 32 public function test_get_editor_load_returns_true() { 31 33 $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); … … 37 39 * Test wp_get_image_editor() where load returns false 38 40 * 39 41 * @ticket 6821 42 * 43 * @covers ::wp_get_image_editor 40 44 */ 41 45 public function test_get_editor_load_returns_false() { 42 46 WP_Image_Editor_Mock::$load_return = new WP_Error(); … … 66 70 * Test test_quality 67 71 * 68 72 * @ticket 6821 73 * 74 * @covers ::wp_get_image_editor 69 75 */ 70 76 public function test_set_quality() { 71 77 … … 113 119 * Test generate_filename 114 120 * 115 121 * @ticket 6821 122 * 123 * @covers ::wp_get_image_editor 116 124 */ 117 125 public function test_generate_filename() { 118 126 … … 152 160 * Test get_size 153 161 * 154 162 * @ticket 6821 163 * 164 * @covers ::wp_get_image_editor 155 165 */ 156 166 public function test_get_size() { 157 167 … … 176 186 * Test get_suffix 177 187 * 178 188 * @ticket 6821 189 * 190 * @covers ::wp_get_image_editor 179 191 */ 180 192 public function test_get_suffix() { 181 193 $editor = wp_get_image_editor( DIR_TESTDATA . '/images/canola.jpg' ); -
tests/phpunit/tests/image/editorGd.php
32 32 parent::tearDown(); 33 33 } 34 34 35 /** 36 * @covers WP_Image_Editor_GD::supports_mime_type 37 */ 35 38 public function test_supports_mime_type_jpeg() { 36 39 $gd_image_editor = new WP_Image_Editor_GD( null ); 37 40 $expected = (bool) ( imagetypes() & IMG_JPG ); … … 38 41 $this->assertSame( $expected, $gd_image_editor->supports_mime_type( 'image/jpeg' ) ); 39 42 } 40 43 44 /** 45 * @covers WP_Image_Editor_GD::supports_mime_type 46 */ 41 47 public function test_supports_mime_type_png() { 42 48 $gd_image_editor = new WP_Image_Editor_GD( null ); 43 49 $expected = (bool) ( imagetypes() & IMG_PNG ); … … 44 50 $this->assertSame( $expected, $gd_image_editor->supports_mime_type( 'image/png' ) ); 45 51 } 46 52 53 /** 54 * @covers WP_Image_Editor_GD::supports_mime_type 55 */ 47 56 public function test_supports_mime_type_gif() { 48 57 $gd_image_editor = new WP_Image_Editor_GD( null ); 49 58 $expected = (bool) ( imagetypes() & IMG_GIF ); … … 52 61 53 62 /** 54 63 * Test resizing an image, not using crop 64 * 65 * @covers WP_Image_Editor_GD::resize 55 66 */ 56 67 public function test_resize() { 57 68 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 72 83 73 84 /** 74 85 * Test multi_resize with single image resize and no crop 86 * 87 * @covers WP_Image_Editor_GD::multi_resize 75 88 */ 76 89 public function test_single_multi_resize() { 77 90 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 114 127 * both height and weight are missing, null, or 0. 115 128 * 116 129 * ticket 26823 130 * 131 * @covers WP_Image_Editor_GD::multi_resize 117 132 */ 118 133 public function test_multi_resize_does_not_create() { 119 134 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 182 197 * Test multi_resize with multiple sizes 183 198 * 184 199 * ticket 26823 200 * 201 * @covers WP_Image_Editor_GD::multi_resize 185 202 */ 186 203 public function test_multi_resize() { 187 204 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 386 403 387 404 /** 388 405 * Test resizing an image with cropping 406 * 407 * @covers WP_Image_Editor_GD::resize 389 408 */ 390 409 public function test_resize_and_crop() { 391 410 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 406 425 407 426 /** 408 427 * Test cropping an image 428 * 429 * @covers WP_Image_Editor_GD::crop 409 430 */ 410 431 public function test_crop() { 411 432 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; … … 426 447 427 448 /** 428 449 * Test rotating an image 180 deg 450 * 451 * @covers WP_Image_Editor_GD::rotate 429 452 */ 430 453 public function test_rotate() { 431 454 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; … … 445 468 446 469 /** 447 470 * Test flipping an image 471 * 472 * @covers WP_Image_Editor_GD::flip 448 473 */ 449 474 public function test_flip() { 450 475 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; … … 466 491 * Test the image created with WP_Image_Editor_GD preserves alpha when resizing 467 492 * 468 493 * @ticket 23039 494 * 495 * @covers WP_Image_Editor_GD::resize 469 496 */ 470 497 public function test_image_preserves_alpha_on_resize() { 471 498 if ( ! ( imagetypes() & IMG_PNG ) ) { … … 493 520 * Test the image created with WP_Image_Editor_GD preserves alpha with no resizing etc 494 521 * 495 522 * @ticket 23039 523 * 524 * @covers WP_Image_Editor_GD::load 496 525 */ 497 526 public function test_image_preserves_alpha() { 498 527 if ( ! ( imagetypes() & IMG_PNG ) ) { … … 518 547 519 548 /** 520 549 * @ticket 30596 550 * 551 * @covers WP_Image_Editor_GD::rotate 521 552 */ 522 553 public function test_image_preserves_alpha_on_rotate() { 523 554 if ( ! ( imagetypes() & IMG_PNG ) ) { … … 546 577 * Test WP_Image_Editor_GD handles extension-less images 547 578 * 548 579 * @ticket 39195 580 * 581 * @covers WP_Image_Editor_GD::load 549 582 */ 550 583 public function test_image_non_existent_extension() { 551 584 $image_editor = new WP_Image_Editor_GD( DIR_TESTDATA . '/images/test-image-no-extension' ); -
tests/phpunit/tests/image/editorImagick.php
46 46 47 47 /** 48 48 * Test resizing an image, not using crop 49 * 50 * @covers WP_Image_Editor_GD::resize 49 51 */ 50 52 public function test_resize() { 51 53 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 66 68 67 69 /** 68 70 * Test multi_resize with single image resize and no crop 71 * 72 * @covers WP_Image_Editor_GD::multi_resize 69 73 */ 70 74 public function test_single_multi_resize() { 71 75 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 108 112 * both height and weight are missing, null, or 0. 109 113 * 110 114 * ticket 26823 115 * 116 * @covers WP_Image_Editor_GD::multi_resize 111 117 */ 112 118 public function test_multi_resize_does_not_create() { 113 119 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 176 182 * Test multi_resize with multiple sizes 177 183 * 178 184 * ticket 26823 185 * 186 * @covers WP_Image_Editor_GD::multi_resize 179 187 */ 180 188 public function test_multi_resize() { 181 189 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 380 388 381 389 /** 382 390 * Test resizing an image with cropping 391 * 392 * @covers WP_Image_Editor_GD::resize 383 393 */ 384 394 public function test_resize_and_crop() { 385 395 $file = DIR_TESTDATA . '/images/waffles.jpg'; … … 400 410 401 411 /** 402 412 * Test cropping an image 413 * 414 * @covers WP_Image_Editor_GD::crop 403 415 */ 404 416 public function test_crop() { 405 417 $file = DIR_TESTDATA . '/images/gradient-square.jpg'; … … 420 432 421 433 /** 422 434 * Test rotating an image 180 deg 435 * 436 * @covers WP_Image_Editor_GD::rotate 423 437 */ 424 438 public function test_rotate() { 425 439 $file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png'; … … 439 453 440 454 /** 441 455 * Test flipping an image 456 * 457 * @covers WP_Image_Editor_GD::flip 442 458 */ 443 459 public function test_flip() { 444 460 $file = DIR_TESTDATA . '/images/one-blue-pixel-100x100.png'; … … 460 476 * Test the image created with WP_Image_Editor_Imagick preserves alpha when resizing 461 477 * 462 478 * @ticket 24871 479 * 480 * @covers WP_Image_Editor_GD::resize 463 481 */ 464 482 public function test_image_preserves_alpha_on_resize() { 465 483 $file = DIR_TESTDATA . '/images/transparent.png'; … … 484 502 * Test the image created with WP_Image_Editor_Imagick preserves alpha with no resizing etc 485 503 * 486 504 * @ticket 24871 505 * 506 * @covers WP_Image_Editor_GD::load 487 507 */ 488 508 public function test_image_preserves_alpha() { 489 509 $file = DIR_TESTDATA . '/images/transparent.png'; … … 506 526 507 527 /** 508 528 * @ticket 30596 529 * 530 * @covers WP_Image_Editor_GD::rotate 509 531 */ 510 532 public function test_image_preserves_alpha_on_rotate() { 511 533 $file = DIR_TESTDATA . '/images/transparent.png'; … … 530 552 * Test WP_Image_Editor_Imagick handles extension-less images 531 553 * 532 554 * @ticket 39195 555 * 556 * @covers WP_Image_Editor_GD::load 533 557 */ 534 558 public function test_image_non_existent_extension() { 535 559 $image_editor = new WP_Image_Editor_Imagick( DIR_TESTDATA . '/images/test-image-no-extension' ); … … 543 567 * 544 568 * @ticket 37140 545 569 * @requires function exif_read_data 570 * 571 * @covers WP_Image_Editor_GD::rotate 546 572 */ 547 573 public function test_remove_orientation_data_on_rotate() { 548 574 $file = DIR_TESTDATA . '/images/test-image-upside-down.jpg'; … … 570 596 571 597 /** 572 598 * Test that images can be loaded and written over streams 599 * 600 * @covers WP_Image_Editor_GD::load 573 601 */ 574 602 public function test_streams() { 575 603 stream_wrapper_register( 'wptest', 'WP_Test_Stream' ); … … 600 628 601 629 /** 602 630 * @ticket 51665 631 * 632 * @covers WP_Image_Editor_GD::save 603 633 */ 604 634 public function test_directory_creation() { 605 635 $file = realpath( DIR_TESTDATA ) . '/images/a2-small.jpg'; -
tests/phpunit/tests/image/functions.php
45 45 return $mime_type; 46 46 } 47 47 48 /** 49 * @covers ::file_is_valid_image 50 */ 48 51 function test_is_image_positive() { 49 52 // These are all image files recognized by PHP. 50 53 $files = array( … … 71 74 } 72 75 } 73 76 77 /** 78 * @covers ::file_is_valid_image 79 */ 74 80 function test_is_image_negative() { 75 81 // These are actually image files but aren't recognized or usable by PHP. 76 82 $files = array( … … 84 90 } 85 91 } 86 92 93 /** 94 * @covers ::file_is_displayable_image 95 */ 87 96 function test_is_displayable_image_positive() { 88 97 // These are all usable in typical web browsers. 89 98 $files = array( … … 102 111 } 103 112 } 104 113 114 /** 115 * @covers ::file_is_displayable_image 116 */ 105 117 function test_is_displayable_image_negative() { 106 118 // These are image files but aren't suitable for web pages because of compatibility or size issues. 107 119 $files = array( … … 126 138 127 139 /** 128 140 * @ticket 50833 141 * 142 * @covers ::is_gd_image 129 143 */ 130 144 function test_is_gd_image_invalid_types() { 131 145 $this->assertFalse( is_gd_image( new stdClass() ) ); … … 140 154 /** 141 155 * @ticket 50833 142 156 * @requires extension gd 157 * 158 * @covers ::is_gd_image 143 159 */ 144 160 function test_is_gd_image_valid_types() { 145 161 $this->assertTrue( is_gd_image( imagecreate( 5, 5 ) ) ); … … 150 166 * 151 167 * @ticket 6821 152 168 * @requires extension fileinfo 169 * 170 * @covers ::wp_save_image_file 153 171 */ 154 172 public function test_wp_save_image_file() { 155 173 $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); … … 206 224 * 207 225 * @ticket 6821 208 226 * @requires extension fileinfo 227 * 228 * @covers WP_Image_Editor_GD::save 229 * @covers WP_Image_Editor_Imagick::save 209 230 */ 210 231 public function test_mime_overrides_filename() { 211 232 $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); … … 248 269 * 249 270 * @ticket 6821 250 271 * @requires extension fileinfo 272 * 273 * @covers WP_Image_Editor_GD::save 274 * @covers WP_Image_Editor_Imagick::save 251 275 */ 252 276 public function test_inferred_mime_types() { 253 277 $classes = array( 'WP_Image_Editor_GD', 'WP_Image_Editor_Imagick' ); … … 306 330 * 307 331 * @ticket 17814 308 332 * @expectedDeprecated wp_load_image 333 * 334 * @covers WP_Image_Editor_GD::load 335 * @covers WP_Image_Editor_Imagick::load 309 336 */ 310 337 public function test_load_directory() { 311 338 … … 341 368 342 369 /** 343 370 * @requires function imagejpeg 371 * 372 * @covers ::wp_crop_image 344 373 */ 345 374 public function test_wp_crop_image_file() { 346 375 $file = wp_crop_image( … … 365 394 /** 366 395 * @requires function imagejpeg 367 396 * @requires extension openssl 397 * 398 * @covers ::wp_crop_image 368 399 */ 369 400 public function test_wp_crop_image_url() { 370 401 $file = wp_crop_image( … … 393 424 unlink( $file ); 394 425 } 395 426 427 /** 428 * @covers ::wp_crop_image 429 */ 396 430 public function test_wp_crop_image_file_not_exist() { 397 431 $file = wp_crop_image( 398 432 DIR_TESTDATA . '/images/canoladoesnotexist.jpg', … … 408 442 409 443 /** 410 444 * @requires extension openssl 445 * 446 * @covers ::wp_crop_image 411 447 */ 412 448 public function test_wp_crop_image_url_not_exist() { 413 449 $file = wp_crop_image( … … 428 464 429 465 /** 430 466 * @ticket 23325 467 * 468 * @covers ::wp_crop_image 431 469 */ 432 470 public function test_wp_crop_image_error_on_saving() { 433 471 WP_Image_Editor_Mock::$save_return = new WP_Error(); … … 450 488 451 489 /** 452 490 * @ticket 31050 491 * 492 * @covers ::wp_generate_attachment_metadata 453 493 */ 454 494 public function test_wp_generate_attachment_metadata_pdf() { 455 495 if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) { … … 518 558 * Crop setting for PDF. 519 559 * 520 560 * @ticket 43226 561 * 562 * @covers ::wp_generate_attachment_metadata 521 563 */ 522 564 public function test_crop_setting_for_pdf() { 523 565 if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) { … … 585 627 586 628 /** 587 629 * @ticket 39231 630 * 631 * @covers ::wp_generate_attachment_metadata 588 632 */ 589 633 public function test_fallback_intermediate_image_sizes() { 590 634 if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) { … … 645 689 * Test PDF preview doesn't overwrite existing JPEG. 646 690 * 647 691 * @ticket 39875 692 * 693 * @covers ::wp_generate_attachment_metadata 648 694 */ 649 695 public function test_pdf_preview_doesnt_overwrite_existing_jpeg() { 650 696 if ( ! wp_image_editor_supports( array( 'mime_type' => 'application/pdf' ) ) ) { -
tests/phpunit/tests/image/header.php
13 13 $this->custom_image_header = new Custom_Image_Header( '__return_null' ); 14 14 } 15 15 16 /** 17 * @covers Custom_Image_Header::get_header_dimensions 18 */ 16 19 function test_header_image_has_correct_dimensions_with_max_width() { 17 20 global $_wp_theme_features; 18 21 … … 33 36 34 37 } 35 38 39 /** 40 * @covers Custom_Image_Header::get_header_dimensions 41 */ 36 42 function test_header_image_has_correct_dimensions_with_fixed() { 37 43 global $_wp_theme_features; 38 44 … … 53 59 54 60 } 55 61 62 /** 63 * @covers Custom_Image_Header::get_header_dimensions 64 */ 56 65 function test_header_image_has_correct_dimensions_with_flex_height() { 57 66 global $_wp_theme_features; 58 67 … … 73 82 74 83 } 75 84 85 /** 86 * @covers Custom_Image_Header::get_header_dimensions 87 */ 76 88 function test_header_image_has_correct_dimensions_with_flex_width() { 77 89 global $_wp_theme_features; 78 90 … … 93 105 94 106 } 95 107 108 /** 109 * @covers Custom_Image_Header::get_header_dimensions 110 */ 96 111 function test_header_image_has_correct_dimensions_with_flex_width_and_height() { 97 112 global $_wp_theme_features; 98 113 … … 113 128 114 129 } 115 130 131 /** 132 * @covers Custom_Image_Header::create_attachment_object 133 */ 116 134 function test_create_attachment_object() { 117 135 $id = wp_insert_attachment( 118 136 array( … … 132 150 $this->assertSame( 'image/jpeg', $object['post_mime_type'] ); 133 151 } 134 152 153 /** 154 * @covers Custom_Image_Header::create_attachment_object 155 * @covers Custom_Image_Header::insert_attachment 156 */ 135 157 function test_insert_cropped_attachment() { 136 158 $id = wp_insert_attachment( 137 159 array( … … 153 175 154 176 /** 155 177 * @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 156 182 */ 157 183 function test_check_get_previous_crop() { 158 184 $id = wp_insert_attachment( -
tests/phpunit/tests/image/intermediateSize.php
22 22 return parent::_make_attachment( $upload, $parent_post_id ); 23 23 } 24 24 25 /** 26 * @covers ::image_make_intermediate_size 27 */ 25 28 function test_make_intermediate_size_no_size() { 26 29 $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 0, false ); 27 30 … … 30 33 31 34 /** 32 35 * @requires function imagejpeg 36 * 37 * @covers ::image_make_intermediate_size 33 38 */ 34 39 function test_make_intermediate_size_width() { 35 40 $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 0, false ); … … 39 44 40 45 /** 41 46 * @requires function imagejpeg 47 * 48 * @covers ::image_make_intermediate_size 42 49 */ 43 50 function test_make_intermediate_size_height() { 44 51 $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 0, 75, false ); … … 48 55 49 56 /** 50 57 * @requires function imagejpeg 58 * 59 * @covers ::image_make_intermediate_size 51 60 */ 52 61 function test_make_intermediate_size_successful() { 53 62 $image = image_make_intermediate_size( DIR_TESTDATA . '/images/a2-small.jpg', 100, 75, true ); … … 65 74 /** 66 75 * @ticket 17626 67 76 * @requires function imagejpeg 77 * 78 * @covers ::image_make_intermediate_size 68 79 */ 69 80 function test_get_intermediate_sizes_by_name() { 70 81 add_image_size( 'test-size', 330, 220, true ); … … 86 97 /** 87 98 * @ticket 17626 88 99 * @requires function imagejpeg 100 * 101 * @covers ::image_make_intermediate_size 89 102 */ 90 103 function test_get_intermediate_sizes_by_array_exact() { 91 104 // Only one dimention match shouldn't return false positive (see: #17626). … … 108 121 /** 109 122 * @ticket 17626 110 123 * @requires function imagejpeg 124 * 125 * @covers ::image_make_intermediate_size 111 126 */ 112 127 function test_get_intermediate_sizes_by_array_nearest() { 113 128 // If an exact size is not found, it should be returned. … … 130 145 131 146 /** 132 147 * @ticket 17626 148 * 149 * @covers ::image_make_intermediate_size 133 150 */ 134 151 function test_get_intermediate_sizes_by_array_nearest_false() { 135 152 // If an exact size is not found, it should be returned. … … 152 169 /** 153 170 * @ticket 17626 154 171 * @requires function imagejpeg 172 * 173 * @covers ::image_make_intermediate_size 155 174 */ 156 175 function test_get_intermediate_sizes_by_array_zero_height() { 157 176 // Generate random width. … … 181 200 * @ticket 17626 182 201 * @ticket 34087 183 202 * @requires function imagejpeg 203 * 204 * @covers ::image_make_intermediate_size 184 205 */ 185 206 function test_get_intermediate_sizes_by_array_zero_width() { 186 207 // 202 is the smallest height that will trigger a miss for 'false-height'. … … 210 231 * @ticket 17626 211 232 * @ticket 34087 212 233 * @requires function imagejpeg 234 * 235 * @covers ::image_make_intermediate_size 213 236 */ 214 237 public function test_get_intermediate_sizes_should_match_size_with_off_by_one_aspect_ratio() { 215 238 // Original is 600x400. 300x201 is close enough to match. … … 234 257 /** 235 258 * @ticket 34384 236 259 * @requires function imagejpeg 260 * 261 * @covers ::image_make_intermediate_size 237 262 */ 238 263 public function test_get_intermediate_size_with_small_size_array() { 239 264 // Add a hard cropped size that matches the aspect ratio we're going to test. … … 252 277 /** 253 278 * @ticket 34384 254 279 * @requires function imagejpeg 280 * 281 * @covers ::image_make_intermediate_size 255 282 */ 256 283 public function test_get_intermediate_size_with_small_size_array_fallback() { 257 284 $file = DIR_TESTDATA . '/images/waffles.jpg'; -
tests/phpunit/tests/image/meta.php
9 9 */ 10 10 class Tests_Image_Meta extends WP_UnitTestCase { 11 11 12 /** 13 * @covers ::wp_read_image_metadata 14 */ 12 15 function test_exif_d70() { 13 16 // Exif from a Nikon D70. 14 17 $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0008.jpg' ); … … 25 28 $this->assertSame( '', $out['title'] ); 26 29 } 27 30 31 /** 32 * @covers ::wp_read_image_metadata 33 */ 28 34 function test_exif_d70_mf() { 29 35 // Exif from a Nikon D70 - manual focus lens, so some data is unavailable. 30 36 $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG' ); … … 42 48 // $this->assertSame( array( 'Flowers' ), $out['keywords'] ); 43 49 } 44 50 51 /** 52 * @covers ::wp_read_image_metadata 53 */ 45 54 function test_exif_d70_iptc() { 46 55 // Exif from a Nikon D70 with IPTC data added later. 47 56 $out = wp_read_image_metadata( DIR_TESTDATA . '/images/2004-07-22-DSC_0007.jpg' ); … … 58 67 $this->assertSame( 'IPTC Headline', $out['title'] ); 59 68 } 60 69 70 /** 71 * @covers ::wp_read_image_metadata 72 */ 61 73 function test_exif_fuji() { 62 74 // Exif from a Fuji FinePix S5600 (thanks Mark). 63 75 $out = wp_read_image_metadata( DIR_TESTDATA . '/images/a2-small.jpg' ); … … 77 89 78 90 /** 79 91 * @ticket 6571 92 * 93 * @covers ::wp_read_image_metadata 80 94 */ 81 95 function test_exif_error() { 82 96 // https://core.trac.wordpress.org/ticket/6571 … … 95 109 $this->assertSame( '', $out['title'] ); 96 110 } 97 111 112 /** 113 * @covers ::wp_read_image_metadata 114 */ 98 115 function test_exif_no_data() { 99 116 // No Exif data in this image (from burningwell.org). 100 117 $out = wp_read_image_metadata( DIR_TESTDATA . '/images/canola.jpg' ); … … 113 130 114 131 /** 115 132 * @ticket 9417 133 * 134 * @covers ::wp_read_image_metadata 116 135 */ 117 136 function test_utf8_iptc_tags() { 118 137 // Trilingual UTF-8 text in the ITPC caption-abstract field. … … 123 142 124 143 /** 125 144 * wp_read_image_metadata() should return false if the image file doesn't exist. 145 * 146 * @covers ::wp_read_image_metadata 126 147 */ 127 148 public function test_missing_image_file() { 128 149 $out = wp_read_image_metadata( DIR_TESTDATA . '/images/404_image.png' ); … … 132 153 133 154 /** 134 155 * @ticket 33772 156 * 157 * @covers ::wp_read_image_metadata 135 158 */ 136 159 public function test_exif_keywords() { 137 160 $out = wp_read_image_metadata( DIR_TESTDATA . '/images/33772.jpg' ); -
tests/phpunit/tests/image/resize.php
26 26 return array( $this->editor_engine ); 27 27 } 28 28 29 /** 30 * @covers WP_Image_Editor::resize 31 */ 29 32 function test_resize_jpg() { 30 33 $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 25, 25 ); 31 34 … … 38 41 unlink( $image ); 39 42 } 40 43 44 /** 45 * @covers WP_Image_Editor::resize 46 */ 41 47 function test_resize_png() { 42 48 $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.png', 25, 25 ); 43 49 … … 54 60 unlink( $image ); 55 61 } 56 62 63 /** 64 * @covers WP_Image_Editor::resize 65 */ 57 66 function test_resize_gif() { 58 67 $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.gif', 25, 25 ); 59 68 … … 70 79 unlink( $image ); 71 80 } 72 81 82 /** 83 * @covers WP_Image_Editor::resize 84 */ 73 85 function test_resize_larger() { 74 86 // image_resize() should refuse to make an image larger. 75 87 $image = $this->resize_helper( DIR_TESTDATA . '/images/test-image.jpg', 100, 100 ); … … 78 90 $this->assertSame( 'error_getting_dimensions', $image->get_error_code() ); 79 91 } 80 92 93 /** 94 * @covers WP_Image_Editor::resize 95 */ 81 96 function test_resize_thumb_128x96() { 82 97 $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 96 ); 83 98 … … 90 105 unlink( $image ); 91 106 } 92 107 108 /** 109 * @covers WP_Image_Editor::resize 110 */ 93 111 function test_resize_thumb_128x0() { 94 112 $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 128, 0 ); 95 113 … … 102 120 unlink( $image ); 103 121 } 104 122 123 /** 124 * @covers WP_Image_Editor::resize 125 */ 105 126 function test_resize_thumb_0x96() { 106 127 $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 0, 96 ); 107 128 … … 114 135 unlink( $image ); 115 136 } 116 137 138 /** 139 * @covers WP_Image_Editor::resize 140 */ 117 141 function test_resize_thumb_150x150_crop() { 118 142 $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 150, true ); 119 143 … … 126 150 unlink( $image ); 127 151 } 128 152 153 /** 154 * @covers WP_Image_Editor::resize 155 */ 129 156 function test_resize_thumb_150x100_crop() { 130 157 $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 150, 100, true ); 131 158 … … 138 165 unlink( $image ); 139 166 } 140 167 168 /** 169 * @covers WP_Image_Editor::resize 170 */ 141 171 function test_resize_thumb_50x150_crop() { 142 172 $image = $this->resize_helper( DIR_TESTDATA . '/images/2007-06-17DSC_4173.JPG', 50, 150, true ); 143 173 … … 154 184 * Try resizing a non-existent image 155 185 * 156 186 * @ticket 6821 187 * 188 * @covers WP_Image_Editor::resize 157 189 */ 158 190 public function test_resize_non_existent_image() { 159 191 $image = $this->resize_helper( DIR_TESTDATA . '/images/test-non-existent-image.jpg', 25, 25 ); -
tests/phpunit/tests/image/resizeGd.php
28 28 * Try resizing a php file (bad image) 29 29 * 30 30 * @ticket 6821 31 * 32 * @covers WP_Image_Editor::resize 31 33 */ 32 34 public function test_resize_bad_image() { 33 35 -
tests/phpunit/tests/image/resizeImagick.php
14 14 * Use the Imagick image editor engine 15 15 * 16 16 * @var string 17 * 18 * @covers WP_Image_Editor::resize 17 19 */ 18 20 public $editor_engine = 'WP_Image_Editor_Imagick'; 19 21 -
tests/phpunit/tests/image/siteIcon.php
28 28 remove_theme_mod( 'custom_logo' ); 29 29 } 30 30 31 /** 32 * @covers WP_Site_Icon::intermediate_image_sizes 33 */ 31 34 function test_intermediate_image_sizes() { 32 35 $image_sizes = $this->wp_site_icon->intermediate_image_sizes( array() ); 33 36 … … 39 42 $this->assertSame( $sizes, $image_sizes ); 40 43 } 41 44 45 /** 46 * @covers WP_Site_Icon::intermediate_image_sizes 47 */ 42 48 function test_intermediate_image_sizes_with_filter() { 43 49 add_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) ); 44 50 $image_sizes = $this->wp_site_icon->intermediate_image_sizes( array() ); … … 60 66 remove_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) ); 61 67 } 62 68 69 /** 70 * @covers WP_Site_Icon::additional_sizes 71 */ 63 72 function test_additional_sizes() { 64 73 $image_sizes = $this->wp_site_icon->additional_sizes( array() ); 65 74 … … 75 84 $this->assertSame( $sizes, $image_sizes ); 76 85 } 77 86 87 /** 88 * @covers WP_Site_Icon::additional_sizes 89 */ 78 90 function test_additional_sizes_with_filter() { 79 91 add_filter( 'site_icon_image_sizes', array( $this, '_custom_test_sizes' ) ); 80 92 $image_sizes = $this->wp_site_icon->additional_sizes( array() ); … … 98 110 unset( $this->wp_site_icon->site_icon_sizes[ array_search( 321, $this->wp_site_icon->site_icon_sizes, true ) ] ); 99 111 } 100 112 113 /** 114 * @covers WP_Site_Icon::create_attachment_object 115 */ 101 116 function test_create_attachment_object() { 102 117 $attachment_id = $this->_insert_attachment(); 103 118 $parent_url = get_post( $attachment_id )->guid; … … 112 127 $this->assertSame( $object['guid'], $cropped ); 113 128 } 114 129 130 /** 131 * @covers WP_Site_Icon::create_attachment_object 132 * @covers WP_Site_Icon::insert_attachment 133 */ 115 134 function test_insert_cropped_attachment() { 116 135 $attachment_id = $this->_insert_attachment(); 117 136 $parent_url = get_post( $attachment_id )->guid; … … 124 143 $this->assertGreaterThan( 0, $cropped_id ); 125 144 } 126 145 146 /** 147 * @covers ::wp_delete_attachment 148 */ 127 149 function test_delete_attachment_data() { 128 150 $attachment_id = $this->_insert_attachment(); 129 151 update_option( 'site_icon', $attachment_id ); … … 135 157 136 158 /** 137 159 * @ticket 34368 160 * 161 * @covers WP_Site_Icon::get_post_metadata 138 162 */ 139 163 function test_get_post_metadata() { 140 164 $attachment_id = $this->_insert_attachment(); -
tests/phpunit/tests/image/size.php
7 7 */ 8 8 class Tests_Image_Size extends WP_UnitTestCase { 9 9 10 /** 11 * @covers ::wp_constrain_dimensions 12 */ 10 13 function test_constrain_dims_zero() { 11 14 // No constraint - should have no effect. 12 15 $out = wp_constrain_dimensions( 640, 480, 0, 0 ); … … 22 25 $this->assertSame( array( 118, 177 ), $out ); 23 26 } 24 27 28 /** 29 * @covers ::wp_constrain_dimensions 30 */ 25 31 function test_constrain_dims_smaller() { 26 32 // Image size is smaller than the constraint - no effect. 27 33 $out = wp_constrain_dimensions( 500, 600, 1024, 768 ); … … 34 40 $this->assertSame( array( 500, 600 ), $out ); 35 41 } 36 42 43 /** 44 * @covers ::wp_constrain_dimensions 45 */ 37 46 function test_constrain_dims_equal() { 38 47 // Image size is equal to the constraint - no effect. 39 48 $out = wp_constrain_dimensions( 1024, 768, 1024, 768 ); … … 46 55 $this->assertSame( array( 1024, 768 ), $out ); 47 56 } 48 57 58 /** 59 * @covers ::wp_constrain_dimensions 60 */ 49 61 function test_constrain_dims_larger() { 50 62 // Image size is larger than the constraint - result should be constrained. 51 63 $out = wp_constrain_dimensions( 1024, 768, 500, 600 ); … … 68 80 $this->assertSame( array( 200, 533 ), $out ); 69 81 } 70 82 83 /** 84 * @covers ::wp_constrain_dimensions 85 */ 71 86 function test_constrain_dims_boundary() { 72 87 // One dimension is larger than the constraint, one smaller - result should be constrained. 73 88 $out = wp_constrain_dimensions( 1024, 768, 500, 800 ); … … 86 101 87 102 /** 88 103 * @expectedDeprecated wp_shrink_dimensions 104 * 105 * @covers ::wp_shrink_dimensions 89 106 */ 90 107 function test_shrink_dimensions_default() { 91 108 $out = wp_shrink_dimensions( 640, 480 ); … … 97 114 98 115 /** 99 116 * @expectedDeprecated wp_shrink_dimensions 117 * 118 * @covers ::wp_shrink_dimensions 100 119 */ 101 120 function test_shrink_dimensions_smaller() { 102 121 // Image size is smaller than the constraint - no effect. … … 109 128 110 129 /** 111 130 * @expectedDeprecated wp_shrink_dimensions 131 * 132 * @covers ::wp_shrink_dimensions 112 133 */ 113 134 function test_shrink_dimensions_equal() { 114 135 // Image size is equal to the constraint - no effect. … … 121 142 122 143 /** 123 144 * @expectedDeprecated wp_shrink_dimensions 145 * 146 * @covers ::wp_shrink_dimensions 124 147 */ 125 148 function test_shrink_dimensions_larger() { 126 149 // Image size is larger than the constraint - result should be constrained. … … 133 156 134 157 /** 135 158 * @expectedDeprecated wp_shrink_dimensions 159 * 160 * @covers ::wp_shrink_dimensions 136 161 */ 137 162 function test_shrink_dimensions_boundary() { 138 163 // One dimension is larger than the constraint, one smaller - result should be constrained. … … 150 175 $this->assertSame( array( 525, 700 ), $out ); 151 176 } 152 177 178 /** 179 * @covers ::image_constrain_size_for_editor 180 */ 153 181 function test_constrain_size_for_editor_thumb() { 154 182 $out = image_constrain_size_for_editor( 600, 400, 'thumb' ); 155 183 $this->assertSame( array( 150, 100 ), $out ); … … 158 186 $this->assertSame( array( 64, 64 ), $out ); 159 187 } 160 188 189 /** 190 * @covers ::image_constrain_size_for_editor 191 */ 161 192 function test_constrain_size_for_editor_medium() { 162 193 // Default max width is 500, no constraint on height. 163 194 global $content_width; … … 185 216 $content_width = $_content_width; 186 217 } 187 218 219 /** 220 * @covers ::image_constrain_size_for_editor 221 */ 188 222 function test_constrain_size_for_editor_full() { 189 223 global $content_width; 190 224 -
tests/phpunit/tests/import/import.php
39 39 parent::tearDown(); 40 40 } 41 41 42 /** 43 * @covers WP_Import::import 44 */ 42 45 function test_small_import() { 43 46 global $wpdb; 44 47 … … 207 210 $this->assertSame( 1, count( $cats ) ); 208 211 } 209 212 213 /** 214 * @covers WP_Import::import 215 */ 210 216 function test_double_import() { 211 217 $authors = array( 212 218 'admin' => false, … … 273 279 274 280 /** 275 281 * @ticket 21007 282 * 283 * @covers WP_Import::import 276 284 */ 277 285 public function test_slashes_should_not_be_stripped() { 278 286 global $wpdb; -
tests/phpunit/tests/import/parser.php
24 24 require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php'; 25 25 } 26 26 27 /** 28 * @covers WXR_Parser_SimpleXML::parse 29 * @covers WXR_Parser_XML::parse 30 */ 27 31 function test_malformed_wxr() { 28 32 $file = DIR_TESTDATA . '/export/malformed.xml'; 29 33 … … 36 40 } 37 41 } 38 42 43 /** 44 * @covers WXR_Parser_SimpleXML::parse 45 * @covers WXR_Parser_XML::parse 46 * @covers WXR_Parser_Regex::parse 47 */ 39 48 function test_invalid_wxr() { 40 49 $f1 = DIR_TESTDATA . '/export/missing-version-tag.xml'; 41 50 $f2 = DIR_TESTDATA . '/export/invalid-version-tag.xml'; … … 50 59 } 51 60 } 52 61 62 /** 63 * @covers WXR_Parser_SimpleXML::parse 64 * @covers WXR_Parser_XML::parse 65 * @covers WXR_Parser_Regex::parse 66 */ 53 67 function test_wxr_version_1_1() { 54 68 $file = DIR_TESTDATA . '/export/valid-wxr-1.1.xml'; 55 69 … … 143 157 } 144 158 } 145 159 160 /** 161 * @covers WXR_Parser_SimpleXML::parse 162 * @covers WXR_Parser_XML::parse 163 * @covers WXR_Parser_Regex::parse 164 */ 146 165 function test_wxr_version_1_0() { 147 166 $file = DIR_TESTDATA . '/export/valid-wxr-1.0.xml'; 148 167 … … 236 255 * sections that contain escaped closing tags ("]]>" -> "]]]]><![CDATA[>"). 237 256 * 238 257 * @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 239 262 */ 240 263 function test_escaped_cdata_closing_sequence() { 241 264 $file = DIR_TESTDATA . '/export/crazy-cdata-escaped.xml'; … … 269 292 /** 270 293 * Ensure that the regex parser can still parse invalid CDATA blocks (i.e. those 271 294 * with "]]>" unescaped within a CDATA section). 295 * 296 * @covers WXR_Parser_Regex::parse 272 297 */ 273 298 function test_unescaped_cdata_closing_sequence() { 274 299 $file = DIR_TESTDATA . '/export/crazy-cdata.xml'; -
tests/phpunit/tests/import/postmeta.php
24 24 require_once DIR_TESTDATA . '/plugins/wordpress-importer/wordpress-importer.php'; 25 25 } 26 26 27 /** 28 * @covers WP_Import::import 29 */ 27 30 function test_serialized_postmeta_no_cdata() { 28 31 $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-no-cdata.xml', array( 'johncoswell' => 'john' ) ); 29 32 $expected['special_post_title'] = 'A special title'; … … 31 34 $this->assertSame( $expected, get_post_meta( 122, 'post-options', true ) ); 32 35 } 33 36 37 /** 38 * @covers WP_Import::import 39 */ 34 40 function test_utw_postmeta() { 35 41 $this->_import_wp( DIR_TESTDATA . '/export/test-utw-post-meta-import.xml', array( 'johncoswell' => 'john' ) ); 36 42 … … 79 85 80 86 /** 81 87 * @ticket 9633 88 * 89 * @covers WP_Import::import 82 90 */ 83 91 function test_serialized_postmeta_with_cdata() { 84 92 $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) ); … … 93 101 94 102 /** 95 103 * @ticket 11574 104 * 105 * @covers WP_Import::import 96 106 */ 97 107 function test_serialized_postmeta_with_evil_stuff_in_cdata() { 98 108 $this->_import_wp( DIR_TESTDATA . '/export/test-serialized-postmeta-with-cdata.xml', array( 'johncoswell' => 'johncoswell' ) ); -
tests/phpunit/tests/l10n/getLocale.php
19 19 20 20 /** 21 21 * @group ms-required 22 * 23 * @covers ::get_locale 22 24 */ 23 25 public function test_local_option_should_take_precedence_on_multisite() { 24 26 global $locale; … … 36 38 37 39 /** 38 40 * @group ms-required 41 * 42 * @covers ::get_locale 39 43 */ 40 44 public function test_network_option_should_be_fallback_on_multisite() { 41 45 if ( ! is_multisite() ) { … … 56 60 57 61 /** 58 62 * @group ms-excluded 63 * 64 * @covers ::get_locale 59 65 */ 60 66 public function test_option_should_be_respected_on_nonmultisite() { 61 67 if ( is_multisite() ) { … … 75 81 76 82 } 77 83 84 /** 85 * @covers ::get_locale 86 */ 78 87 public function test_should_fall_back_on_en_US() { 79 88 global $locale; 80 89 $old_locale = $locale; … … 86 95 $this->assertSame( 'en_US', $found ); 87 96 } 88 97 98 /** 99 * @covers ::get_locale 100 */ 89 101 public function test_should_respect_get_locale_filter() { 90 102 add_filter( 'locale', array( $this, 'filter_get_locale' ) ); 91 103 $found = get_locale(); -
tests/phpunit/tests/l10n/getUserLocale.php
27 27 parent::tearDown(); 28 28 } 29 29 30 /** 31 * @covers ::get_user_locale 32 */ 30 33 public function test_user_locale_property() { 31 34 set_current_screen( 'dashboard' ); 32 35 $this->assertSame( 'de_DE', get_user_locale() ); … … 33 36 $this->assertSame( get_user_by( 'id', $this->user_id )->locale, get_user_locale() ); 34 37 } 35 38 39 /** 40 * @covers ::get_user_locale 41 */ 36 42 public function test_update_user_locale() { 37 43 set_current_screen( 'dashboard' ); 38 44 update_user_meta( $this->user_id, 'locale', 'fr_FR' ); … … 39 45 $this->assertSame( 'fr_FR', get_user_locale() ); 40 46 } 41 47 48 /** 49 * @covers ::get_user_locale 50 */ 42 51 public function test_returns_site_locale_if_empty() { 43 52 set_current_screen( 'dashboard' ); 44 53 update_user_meta( $this->user_id, 'locale', '' ); … … 45 54 $this->assertSame( get_locale(), get_user_locale() ); 46 55 } 47 56 57 /** 58 * @covers ::get_user_locale 59 */ 48 60 public function test_returns_site_locale_if_no_user() { 49 61 wp_set_current_user( 0 ); 50 62 $this->assertSame( get_locale(), get_user_locale() ); 51 63 } 52 64 65 /** 66 * @covers ::get_user_locale 67 */ 53 68 public function test_returns_correct_user_locale() { 54 69 set_current_screen( 'dashboard' ); 55 70 $this->assertSame( 'de_DE', get_user_locale() ); 56 71 } 57 72 73 /** 74 * @covers ::get_user_locale 75 */ 58 76 public function test_returns_correct_user_locale_on_frontend() { 59 77 $this->assertSame( 'de_DE', get_user_locale() ); 60 78 } 61 79 80 /** 81 * @covers ::get_user_locale 82 */ 62 83 public function test_site_locale_is_not_affected() { 63 84 set_current_screen( 'dashboard' ); 64 85 $this->assertSame( 'en_US', get_locale() ); 65 86 } 66 87 88 /** 89 * @covers ::get_user_locale 90 */ 67 91 public function test_site_locale_is_not_affected_on_frontend() { 68 92 $this->assertSame( 'en_US', get_locale() ); 69 93 } … … 70 94 71 95 /** 72 96 * @group ms-required 97 * 98 * @covers ::get_user_locale 73 99 */ 74 100 public function test_user_locale_is_same_across_network() { 75 101 if ( ! is_multisite() ) { … … 86 112 $this->assertSame( $user_locale, $user_locale_2 ); 87 113 } 88 114 115 /** 116 * @covers ::get_user_locale 117 */ 89 118 public function test_user_id_argument_with_id() { 90 119 $user_id = $this->factory()->user->create( 91 120 array( … … 103 132 $this->assertSame( get_locale(), $user_locale2 ); 104 133 } 105 134 135 /** 136 * @covers ::get_user_locale 137 */ 106 138 public function test_user_id_argument_with_wp_user_object() { 107 139 $user_id = $this->factory()->user->create( 108 140 array( … … 122 154 $this->assertSame( get_locale(), $user_locale2 ); 123 155 } 124 156 157 /** 158 * @covers ::get_user_locale 159 */ 125 160 public function test_user_id_argument_with_nonexistent_user() { 126 161 global $wpdb; 127 162 … … 132 167 $this->assertSame( get_locale(), $user_locale ); 133 168 } 134 169 170 /** 171 * @covers ::get_user_locale 172 */ 135 173 public function test_user_id_argument_with_invalid_type() { 136 174 $user_locale = get_user_locale( 'string' ); 137 175 $this->assertSame( get_locale(), $user_locale ); -
tests/phpunit/tests/l10n/loadScriptTextdomain.php
13 13 * @ticket 49145 14 14 * 15 15 * @dataProvider data_test_resolve_relative_path 16 * 17 * @covers ::file_get_contents 16 18 */ 17 19 public function test_resolve_relative_path( $translation_path, $handle, $src, $textdomain, $filter = array() ) { 18 20 if ( ! empty( $filter ) ) { -
tests/phpunit/tests/l10n/loadTextdomain.php
39 39 return $locale; 40 40 } 41 41 42 /** 43 * @covers ::is_textdomain_loaded 44 */ 42 45 public function test_is_textdomain_loaded() { 43 46 $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); 44 47 } 45 48 49 /** 50 * @covers ::unload_textdomain 51 */ 46 52 public function test_unload_textdomain() { 47 53 $this->assertFalse( unload_textdomain( 'wp-tests-domain' ) ); 48 54 } 49 55 56 /** 57 * @covers ::unload_textdomain 58 */ 50 59 public function test_load_textdomain() { 51 60 $loaded = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' ); 52 61 … … 55 64 $this->assertTrue( $loaded ); 56 65 } 57 66 67 /** 68 * @covers ::unload_textdomain 69 */ 58 70 public function test_is_textdomain_loaded_after_loading() { 59 71 load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' ); 60 72 … … 65 77 $this->assertTrue( $loaded ); 66 78 } 67 79 80 /** 81 * @covers ::unload_textdomain 82 */ 68 83 public function test_unload_textdomain_after_loading() { 69 84 load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' ); 70 85 … … 71 86 $this->assertTrue( unload_textdomain( 'wp-tests-domain' ) ); 72 87 } 73 88 89 /** 90 * @covers ::is_textdomain_loaded 91 */ 74 92 public function test_is_textdomain_loaded_after_unloading() { 75 93 load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/pomo/simple.mo' ); 76 94 … … 81 99 82 100 /** 83 101 * @ticket 21319 102 * 103 * @covers ::load_textdomain 84 104 */ 85 105 public function test_load_textdomain_non_existent_file() { 86 106 $this->assertFalse( load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ) ); … … 88 108 89 109 /** 90 110 * @ticket 21319 111 * 112 * @covers ::is_textdomain_loaded 91 113 */ 92 114 public function test_is_textdomain_loaded_non_existent_file() { 93 115 load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ); … … 97 119 98 120 /** 99 121 * @ticket 21319 122 * 123 * @covers ::get_translations_for_domain 100 124 */ 101 125 public function test_get_translations_for_domain_non_existent_file() { 102 126 load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ); … … 106 130 107 131 /** 108 132 * @ticket 21319 133 * 134 * @covers ::unload_textdomain 109 135 */ 110 136 public function test_unload_textdomain_non_existent_file() { 111 137 load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ); … … 115 141 116 142 /** 117 143 * @ticket 21319 144 * 145 * @covers ::is_textdomain_loaded 118 146 */ 119 147 function test_is_textdomain_is_not_loaded_after_gettext_call_with_no_translations() { 120 148 $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); … … 122 150 $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); 123 151 } 124 152 153 /** 154 * @covers ::load_textdomain 155 */ 125 156 function test_override_load_textdomain_noop() { 126 157 add_filter( 'override_load_textdomain', '__return_true' ); 127 158 $load_textdomain = load_textdomain( 'wp-tests-domain', DIR_TESTDATA . '/non-existent-file' ); … … 131 162 $this->assertFalse( is_textdomain_loaded( 'wp-tests-domain' ) ); 132 163 } 133 164 165 /** 166 * @covers ::load_textdomain 167 */ 134 168 function test_override_load_textdomain_non_existent_mofile() { 135 169 add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 ); 136 170 $load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/non-existent-file.mo' ); … … 145 179 $this->assertFalse( $is_textdomain_loaded_after ); 146 180 } 147 181 182 /** 183 * @covers ::load_textdomain 184 */ 148 185 function test_override_load_textdomain_custom_mofile() { 149 186 add_filter( 'override_load_textdomain', array( $this, '_override_load_textdomain_filter' ), 10, 3 ); 150 187 $load_textdomain = load_textdomain( 'wp-tests-domain', WP_LANG_DIR . '/plugins/internationalized-plugin-de_DE.mo' ); … … 187 224 return true; 188 225 } 189 226 227 /** 228 * @covers ::load_muplugin_textdomain 229 */ 190 230 public function test_load_muplugin_textdomain_site_locale() { 191 231 load_muplugin_textdomain( 'wp-tests-domain' ); 192 232 … … 195 235 196 236 /** 197 237 * @ticket 38485 238 * 239 * @covers ::load_muplugin_textdomain 198 240 */ 199 241 public function test_load_muplugin_textdomain_user_locale() { 200 242 set_current_screen( 'dashboard' ); … … 207 249 $this->assertSame( get_user_locale(), $this->locale ); 208 250 } 209 251 252 /** 253 * @covers ::load_plugin_textdomain 254 */ 210 255 public function test_load_plugin_textdomain_site_locale() { 211 256 load_plugin_textdomain( 'wp-tests-domain' ); 212 257 … … 215 260 216 261 /** 217 262 * @ticket 38485 263 * 264 * @covers ::load_plugin_textdomain 218 265 */ 219 266 public function test_load_plugin_textdomain_user_locale() { 220 267 set_current_screen( 'dashboard' ); … … 227 274 $this->assertSame( get_user_locale(), $this->locale ); 228 275 } 229 276 277 /** 278 * @covers ::load_theme_textdomain 279 */ 230 280 public function test_load_theme_textdomain_site_locale() { 231 281 load_theme_textdomain( 'wp-tests-domain' ); 232 282 … … 235 285 236 286 /** 237 287 * @ticket 38485 288 * 289 * @covers ::load_theme_textdomain 238 290 */ 239 291 public function test_load_theme_textdomain_user_locale() { 240 292 set_current_screen( 'dashboard' ); -
tests/phpunit/tests/l10n/loadTextdomainJustInTime.php
65 65 66 66 /** 67 67 * @ticket 34114 68 * 69 * @covers ::is_textdomain_loaded 68 70 */ 69 71 public function test_plugin_translation_should_be_translated_without_calling_load_plugin_textdomain() { 70 72 add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) ); … … 84 86 85 87 /** 86 88 * @ticket 34114 89 * 90 * @covers ::is_textdomain_loaded 87 91 */ 88 92 public function test_theme_translation_should_be_translated_without_calling_load_theme_textdomain() { 89 93 add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) ); … … 105 109 106 110 /** 107 111 * @ticket 34114 112 * 113 * @covers ::get_translations_for_domain 108 114 */ 109 115 public function test_get_translations_for_domain_does_not_return_null_if_override_load_textdomain_is_used() { 110 116 add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) ); … … 118 124 119 125 /** 120 126 * @ticket 37113 127 * 128 * @covers ::is_textdomain_loaded 121 129 */ 122 130 public function test_should_allow_unloading_of_text_domain() { 123 131 add_filter( 'locale', array( $this, 'filter_set_locale_to_german' ) ); … … 157 165 158 166 /** 159 167 * @ticket 26511 168 * 169 * @covers ::switch_to_locale 160 170 */ 161 171 public function test_plugin_translation_after_switching_locale() { 162 172 require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php'; … … 170 180 171 181 /** 172 182 * @ticket 37997 183 * 184 * @covers ::switch_to_locale 173 185 */ 174 186 public function test_plugin_translation_after_switching_locale_twice() { 175 187 require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php'; … … 188 200 189 201 /** 190 202 * @ticket 26511 203 * 204 * @covers ::switch_to_locale 191 205 */ 192 206 public function test_theme_translation_after_switching_locale() { 193 207 switch_theme( 'internationalized-theme' ); … … 205 219 206 220 /** 207 221 * @ticket 38485 222 * 223 * @covers ::wp_set_current_user 208 224 */ 209 225 public function test_plugin_translation_with_user_locale() { 210 226 require_once DIR_TESTDATA . '/plugins/internationalized-plugin.php'; … … 221 237 222 238 /** 223 239 * @ticket 38485 240 * 241 * @covers ::wp_set_current_user 224 242 */ 225 243 public function test_theme_translation_with_user_locale() { 226 244 switch_theme( 'internationalized-theme' ); … … 239 257 240 258 /** 241 259 * @ticket 37997 260 * 261 * @covers ::__ 242 262 */ 243 263 public function test_get_locale_is_called_only_once_per_textdomain() { 244 264 $textdomain = 'foo-bar-baz'; -
tests/phpunit/tests/l10n/localeSwitcher.php
35 35 parent::tearDown(); 36 36 } 37 37 38 /** 39 * @covers ::switch_to_locale 40 */ 38 41 public function test_switch_to_non_existent_locale_returns_false() { 39 42 $this->assertFalse( switch_to_locale( 'foo_BAR' ) ); 40 43 } 41 44 45 /** 46 * @covers ::switch_to_locale 47 */ 42 48 public function test_switch_to_non_existent_locale_does_not_change_locale() { 43 49 switch_to_locale( 'foo_BAR' ); 44 50 … … 45 51 $this->assertSame( 'en_US', get_locale() ); 46 52 } 47 53 54 /** 55 * @covers ::switch_to_locale 56 */ 48 57 public function test_switch_to_locale_returns_true() { 49 58 $expected = switch_to_locale( 'en_GB' ); 50 59 … … 54 63 $this->assertTrue( $expected ); 55 64 } 56 65 66 /** 67 * @covers ::switch_to_locale 68 */ 57 69 public function test_switch_to_locale_changes_the_locale() { 58 70 switch_to_locale( 'en_GB' ); 59 71 … … 65 77 $this->assertSame( 'en_GB', $locale ); 66 78 } 67 79 80 /** 81 * @covers ::switch_to_locale 82 */ 68 83 public function test_switch_to_locale_loads_translation() { 69 84 switch_to_locale( 'es_ES' ); 70 85 … … 76 91 $this->assertSame( 'Parámetro no válido. ', $actual ); 77 92 } 78 93 94 /** 95 * @covers ::switch_to_locale 96 */ 79 97 public function test_switch_to_locale_changes_wp_locale_global() { 80 98 global $wp_locale; 81 99 … … 94 112 $this->assertSameSetsWithIndex( $expected, $wp_locale_de_de->number_format ); 95 113 } 96 114 115 /** 116 * @covers ::switch_to_locale 117 */ 97 118 public function test_switch_to_locale_en_US() { 98 119 switch_to_locale( 'en_GB' ); 99 120 $locale_en_gb = get_locale(); … … 107 128 $this->assertSame( 'en_US', $locale_en_us ); 108 129 } 109 130 131 /** 132 * @covers ::switch_to_locale 133 * @covers ::restore_previous_locale 134 */ 110 135 public function test_switch_to_locale_multiple_times() { 111 136 switch_to_locale( 'en_GB' ); 112 137 switch_to_locale( 'es_ES' ); … … 119 144 $this->assertSame( 'es_ES', $locale ); 120 145 } 121 146 147 /** 148 * @covers ::switch_to_locale 149 * @covers ::restore_previous_locale 150 */ 122 151 public function test_switch_to_locale_multiple_times_loads_translation() { 123 152 switch_to_locale( 'en_GB' ); 124 153 switch_to_locale( 'de_DE' ); … … 134 163 $this->assertSame( 'Parámetro no válido. ', $actual ); 135 164 } 136 165 166 /** 167 * @covers ::restore_previous_locale 168 */ 137 169 public function test_restore_previous_locale_without_switching() { 138 170 $this->assertFalse( restore_previous_locale() ); 139 171 } 140 172 173 /** 174 * @covers ::switch_to_locale 175 * @covers ::restore_previous_locale 176 */ 141 177 public function test_restore_previous_locale_changes_the_locale_back() { 142 178 switch_to_locale( 'en_GB' ); 143 179 … … 147 183 $this->assertSame( 'en_US', get_locale() ); 148 184 } 149 185 186 /** 187 * @covers ::switch_to_locale 188 * @covers ::restore_previous_locale 189 */ 150 190 public function test_restore_previous_locale_after_switching_multiple_times() { 151 191 switch_to_locale( 'en_GB' ); 152 192 switch_to_locale( 'es_ES' ); … … 160 200 $this->assertSame( 'en_GB', $locale ); 161 201 } 162 202 203 /** 204 * @covers ::switch_to_locale 205 * @covers ::restore_previous_locale 206 */ 163 207 public function test_restore_previous_locale_restores_translation() { 164 208 switch_to_locale( 'es_ES' ); 165 209 restore_previous_locale(); … … 169 213 $this->assertSame( 'Invalid parameter.', $actual ); 170 214 } 171 215 216 /** 217 * @covers ::switch_to_locale 218 * @covers ::restore_previous_locale 219 */ 172 220 public function test_restore_previous_locale_action_passes_previous_locale() { 173 221 switch_to_locale( 'en_GB' ); 174 222 switch_to_locale( 'es_ES' ); … … 185 233 $this->assertSame( 'es_ES', $previous_locale ); 186 234 } 187 235 236 /** 237 * @covers ::switch_to_locale 238 * @covers ::restore_previous_locale 239 */ 188 240 public function test_restore_previous_locale_restores_wp_locale_global() { 189 241 global $wp_locale; 190 242 … … 199 251 $this->assertSameSetsWithIndex( $expected, $wp_locale->number_format ); 200 252 } 201 253 254 /** 255 * @covers ::restore_previous_locale 256 */ 202 257 public function test_restore_current_locale_without_switching() { 203 258 $this->assertFalse( restore_current_locale() ); 204 259 } 205 260 261 /** 262 * @covers ::switch_to_locale 263 * @covers ::restore_previous_locale 264 */ 206 265 public function test_restore_current_locale_after_switching_multiple_times() { 207 266 switch_to_locale( 'en_GB' ); 208 267 switch_to_locale( 'nl_NL' ); … … 218 277 $this->previous_locale = $previous_locale; 219 278 } 220 279 280 /** 281 * @covers ::is_locale_switched 282 */ 221 283 public function test_is_locale_switched_if_not_switched() { 222 284 $this->assertFalse( is_locale_switched() ); 223 285 } 224 286 287 /** 288 * @covers ::is_locale_switched 289 */ 225 290 public function test_is_locale_switched_original_locale() { 226 291 $original_locale = get_locale(); 227 292 … … 235 300 $this->assertTrue( $is_locale_switched ); 236 301 } 237 302 303 /** 304 * @covers ::switch_to_locale 305 * @covers ::restore_current_locale 306 */ 238 307 public function test_is_locale_switched() { 239 308 switch_to_locale( 'en_GB' ); 240 309 switch_to_locale( 'nl_NL' ); … … 246 315 $this->assertTrue( $is_locale_switched ); 247 316 } 248 317 318 /** 319 * @covers ::wp_set_current_user 320 * @covers ::restore_current_locale 321 */ 249 322 public function test_switch_to_site_locale_if_user_locale_is_set() { 250 323 global $l10n, $wp_locale_switcher; 251 324 … … 294 367 $this->assertSame( 'de_DE', $language_header_after_restore ); 295 368 } 296 369 370 /** 371 * @covers ::wp_set_current_user 372 * @covers ::get_user_locale 373 */ 297 374 public function test_switch_to_different_site_locale_if_user_locale_is_set() { 298 375 global $l10n, $wp_locale_switcher; 299 376 … … 347 424 $this->assertSame( 'de_DE', $language_header_after_restore ); 348 425 } 349 426 427 /** 428 * @covers ::wp_set_current_user 429 * @covers ::get_user_locale 430 */ 350 431 public function test_multiple_switches_to_site_locale_and_user_locale() { 351 432 global $wp_locale_switcher; 352 433