Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/06/2021 07:15:14 PM (3 years ago)
Author:
imath
Message:

PHPUnit: fix failing tests about media

Since WP 50170 revision, errors about getimagesize() and exif_read_data() are not silenced anymore. We must now make sure to write media files where they should be for these two functions.

Tests involving exif_read_data() will be skipped from now on when testing against PHP 5.6 as no matter the image you use, you'll always get an Illegal IDF size error. It appears to be a bug with this version of PHP.

See #8432 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/core/class-bp-media-extractor.php

    r11842 r12840  
    322322
    323323    public function test_extract_images_from_content_with_galleries_variant_ids() {
    324         $attachment_ids   = array();
    325         $attachment_ids[] = $this->fake_attachment_upload( DIR_TESTDATA . '/images/test-image-large.png' );
    326         $attachment_ids[] = $this->fake_attachment_upload( DIR_TESTDATA . '/images/canola.jpg' );
    327         $attachment_ids   = join( ',', $attachment_ids );
    328         $post_id          = self::factory()->post->create( array( 'post_content' => "[gallery ids='{$attachment_ids}']" ) );
     324        $attachment_ids = array(
     325            'large'  => 0,
     326            'canola' => 0,
     327        );
     328
     329        $attachment_ids['large'] = self::factory()->attachment->create_upload_object( BP_TESTS_DIR . 'assets/test-image-large.jpg' );
     330        $attachment_ids['canola'] = self::factory()->attachment->create_upload_object( BP_TESTS_DIR . 'assets/canola.jpg' );
     331
     332        $attachments = join( ',', $attachment_ids );
     333        $post_id     = self::factory()->post->create( array( 'post_content' => "[gallery ids='{$attachments}']" ) );
    329334
    330335        // Extract the gallery images.
     
    337342        $this->assertCount( 2, $media );
    338343
    339         $this->assertSame( WP_CONTENT_URL . '/uploads/test-image-large.png', $media[0]['url'] );
    340         $this->assertSame( WP_CONTENT_URL . '/uploads/canola.jpg', $media[1]['url'] );
     344        $expected_urls = array(
     345            'large'  => wp_get_attachment_url( $attachment_ids['large'] ),
     346            'canola' => wp_get_attachment_url( $attachment_ids['canola'] ),
     347        );
     348
     349        $this->assertSame( $expected_urls['large'], $media[0]['url'] );
     350        $this->assertSame( $expected_urls['canola'], $media[1]['url'] );
    341351    }
    342352
Note: See TracChangeset for help on using the changeset viewer.