Changeset 42343 for trunk/tests/phpunit/tests/image/editorGd.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/image/editorGd.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/image/editorGd.php
r41261 r42343 3 3 /** 4 4 * Test the WP_Image_Editor_GD class 5 * 5 6 * @group image 6 7 * @group media … … 34 35 public function test_supports_mime_type_jpeg() { 35 36 $gd_image_editor = new WP_Image_Editor_GD( null ); 36 $expected = imagetypes() & IMG_JPG;37 $expected = imagetypes() & IMG_JPG; 37 38 $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/jpeg' ) ); 38 39 } … … 40 41 public function test_supports_mime_type_png() { 41 42 $gd_image_editor = new WP_Image_Editor_GD( null ); 42 $expected = imagetypes() & IMG_PNG;43 $expected = imagetypes() & IMG_PNG; 43 44 $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/png' ) ); 44 45 } … … 46 47 public function test_supports_mime_type_gif() { 47 48 $gd_image_editor = new WP_Image_Editor_GD( null ); 48 $expected = imagetypes() & IMG_GIF;49 $expected = imagetypes() & IMG_GIF; 49 50 $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/gif' ) ); 50 51 } … … 79 80 $gd_image_editor->load(); 80 81 81 $sizes_array = array(82 $sizes_array = array( 82 83 array( 83 84 'width' => 50, … … 101 102 102 103 // Now, verify real dimensions are as expected 103 $image_path = DIR_TESTDATA . '/images/' . $resized[0]['file'];104 $image_path = DIR_TESTDATA . '/images/' . $resized[0]['file']; 104 105 $this->assertImageDimensions( 105 106 $image_path, … … 150 151 ), 151 152 array( 152 'width' => 0,153 ), 154 array( 155 'width' => 0,156 'crop' => true,157 ), 158 array( 159 'width' => null,160 ), 161 array( 162 'width' => null,163 'crop' => true,164 ), 165 array( 166 'width' => '',167 ), 168 array( 169 'width' => '',170 'crop' => true,153 'width' => 0, 154 ), 155 array( 156 'width' => 0, 157 'crop' => true, 158 ), 159 array( 160 'width' => null, 161 ), 162 array( 163 'width' => null, 164 'crop' => true, 165 ), 166 array( 167 'width' => '', 168 ), 169 array( 170 'width' => '', 171 'crop' => true, 171 172 ), 172 173 ); … … 372 373 $this->assertEquals( $expected_array, $resized ); 373 374 374 foreach ( $resized as $key => $image_data ){375 foreach ( $resized as $key => $image_data ) { 375 376 $image_path = DIR_TESTDATA . '/images/' . $image_data['file']; 376 377 … … 378 379 $this->assertImageDimensions( 379 380 $image_path, 380 $expected_array[ $key]['width'],381 $expected_array[ $key]['height']381 $expected_array[ $key ]['width'], 382 $expected_array[ $key ]['height'] 382 383 ); 383 384 } … … 417 418 $this->assertEquals( 418 419 array( 419 'width' => 50,420 'width' => 50, 420 421 'height' => 50, 421 422 ), … … 484 485 $editor->save( $save_to_file ); 485 486 486 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0, 0 ), 127 );487 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0, 0 ), 127 ); 487 488 488 489 unlink( $save_to_file ); … … 511 512 $editor->save( $save_to_file ); 512 513 513 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0, 0 ), 127 );514 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0, 0 ), 127 ); 514 515 515 516 unlink( $save_to_file ); … … 517 518 518 519 /** 519 *520 520 * @ticket 30596 521 521 */ … … 527 527 $file = DIR_TESTDATA . '/images/transparent.png'; 528 528 529 $image = imagecreatefrompng( $file );530 $rgb = imagecolorat( $image, 0, 0 );529 $image = imagecreatefrompng( $file ); 530 $rgb = imagecolorat( $image, 0, 0 ); 531 531 $expected = imagecolorsforindex( $image, $rgb ); 532 532 533 533 $editor = new WP_Image_Editor_GD( $file ); 534 $this->assertNotInstanceOf( 'WP_Error', $editor );535 $editor->load();536 $editor->rotate( 180 );537 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png';538 539 $editor->save( $save_to_file );540 541 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0,0 ), $expected['alpha'] );542 unlink( $save_to_file );534 $this->assertNotInstanceOf( 'WP_Error', $editor ); 535 $editor->load(); 536 $editor->rotate( 180 ); 537 $save_to_file = tempnam( get_temp_dir(), '' ) . '.png'; 538 539 $editor->save( $save_to_file ); 540 541 $this->assertImageAlphaAtPointGD( $save_to_file, array( 0, 0 ), $expected['alpha'] ); 542 unlink( $save_to_file ); 543 543 544 544 } … … 546 546 /** 547 547 * Test WP_Image_Editor_GD handles extension-less images 548 * 548 549 * @ticket 39195 549 550 */ 550 551 public function test_image_non_existent_extension() { 551 $image_editor = new WP_Image_Editor_GD( DIR_TESTDATA .'/images/test-image-no-extension' );552 $result = $image_editor->load();552 $image_editor = new WP_Image_Editor_GD( DIR_TESTDATA . '/images/test-image-no-extension' ); 553 $result = $image_editor->load(); 553 554 554 555 $this->assertTrue( $result );
Note: See TracChangeset
for help on using the changeset viewer.