Make WordPress Core


Ignore:
Timestamp:
02/22/2015 09:06:36 PM (10 years ago)
Author:
boonebgorges
Message:

Better image-type support checks in image unit tests.

PHP can be compiled without support for certain image types. Our unit tests
should be sensitive to these configurations.

Fixes #31124.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/image/editor_gd.php

    r31040 r31510  
    3232    }
    3333
    34     /**
    35      * Check support for GD compatible mime types.
    36      */
    37     public function test_supports_mime_type() {
     34    public function test_supports_mime_type_jpeg() {
    3835        $gd_image_editor = new WP_Image_Editor_GD( null );
    39 
    40         $this->assertTrue( $gd_image_editor->supports_mime_type( 'image/jpeg' ), 'Does not support image/jpeg' );
    41         $this->assertTrue( $gd_image_editor->supports_mime_type( 'image/png' ), 'Does not support image/png' );
    42         $this->assertTrue( $gd_image_editor->supports_mime_type( 'image/gif' ), 'Does not support image/gif' );
     36        $expected = imagetypes() & IMG_JPG;
     37        $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/jpeg' ) );
     38    }
     39
     40    public function test_supports_mime_type_png() {
     41        $gd_image_editor = new WP_Image_Editor_GD( null );
     42        $expected = imagetypes() & IMG_PNG;
     43        $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/png' ) );
     44    }
     45
     46    public function test_supports_mime_type_gif() {
     47        $gd_image_editor = new WP_Image_Editor_GD( null );
     48        $expected = imagetypes() & IMG_GIF;
     49        $this->assertEquals( $expected, $gd_image_editor->supports_mime_type( 'image/gif' ) );
    4350    }
    4451
     
    461468     */
    462469    public function test_image_preserves_alpha_on_resize() {
     470        if ( ! ( imagetypes() & IMG_PNG ) ) {
     471            $this->markTestSkipped( 'This test requires PHP to be compiled with PNG support.' );
     472        }
     473
    463474        $file = DIR_TESTDATA . '/images/transparent.png';
    464475
     
    484495     */
    485496    public function test_image_preserves_alpha() {
     497        if ( ! ( imagetypes() & IMG_PNG ) ) {
     498            $this->markTestSkipped( 'This test requires PHP to be compiled with PNG support.' );
     499        }
     500
    486501        $file = DIR_TESTDATA . '/images/transparent.png';
    487502
     
    506521     */
    507522    public function test_image_preserves_alpha_on_rotate() {
     523        if ( ! ( imagetypes() & IMG_PNG ) ) {
     524            $this->markTestSkipped( 'This test requires PHP to be compiled with PNG support.' );
     525        }
     526
    508527        $file = DIR_TESTDATA . '/images/transparent.png';
    509528
Note: See TracChangeset for help on using the changeset viewer.