Make WordPress Core

Changeset 53538


Ignore:
Timestamp:
06/20/2022 09:35:03 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Tests: Improve Tests_Image_Functions::test_wp_crop_image*() tests.

Includes:

  • Adding @covers annotations.
  • Adding a failure message to each assertion when multiple assertions are used in the test.

Follow-up to [1126/tests], [53495], [53497], [53521], [53523], [53524], [53525], [53526], [53529], [53530], [53531], [53537].

Props jrf.
See #55652.

File:
1 edited

Legend:

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

    r53537 r53538  
    485485    /**
    486486     * @ticket 55403
     487     * @covers ::wp_crop_image
    487488     */
    488489    public function test_wp_crop_image_with_filtered_extension() {
     
    509510
    510511    /**
     512     * @covers ::wp_crop_image
    511513     * @requires function imagejpeg
    512514     */
     
    521523            100
    522524        );
    523         $this->assertNotWPError( $file );
    524         $this->assertFileExists( $file );
     525        $this->assertNotWPError( $file, 'Cropping the image resulted in a WP_Error.' );
     526        $this->assertFileExists( $file, "The file $file does not exist." );
     527
    525528        $image = wp_get_image_editor( $file );
    526529        $size  = $image->get_size();
    527         $this->assertSame( 100, $size['height'] );
    528         $this->assertSame( 100, $size['width'] );
     530
     531        $this->assertSame( 100, $size['height'], 'Cropped image height does not match expectation.' );
     532        $this->assertSame( 100, $size['width'], 'Cropped image width does not match expectation.' );
    529533
    530534        unlink( $file );
     
    532536
    533537    /**
     538     * @covers ::wp_crop_image
    534539     * @requires function imagejpeg
    535540     * @requires extension openssl
     
    552557        }
    553558
    554         $this->assertNotWPError( $file );
    555         $this->assertFileExists( $file );
     559        $this->assertNotWPError( $file, 'Cropping the image resulted in a WP_Error.' );
     560        $this->assertFileExists( $file, "The file $file does not exist." );
     561
    556562        $image = wp_get_image_editor( $file );
    557563        $size  = $image->get_size();
    558         $this->assertSame( 100, $size['height'] );
    559         $this->assertSame( 100, $size['width'] );
     564
     565        $this->assertSame( 100, $size['height'], 'Cropped image height does not match expectation.' );
     566        $this->assertSame( 100, $size['width'], 'Cropped image width does not match expectation.' );
    560567
    561568        unlink( $file );
    562569    }
    563570
    564     public function test_wp_crop_image_file_not_exist() {
     571    /**
     572     * @covers ::wp_crop_image
     573     */
     574    public function test_wp_crop_image_file_not_exists() {
    565575        $file = wp_crop_image(
    566576            DIR_TESTDATA . '/images/canoladoesnotexist.jpg',
     
    576586
    577587    /**
     588     * @covers ::wp_crop_image
    578589     * @requires extension openssl
    579590     */
    580     public function test_wp_crop_image_url_not_exist() {
     591    public function test_wp_crop_image_url_not_exists() {
    581592        $file = wp_crop_image(
    582593            'https://asdftestblog1.files.wordpress.com/2008/04/canoladoesnotexist.jpg',
     
    593604    /**
    594605     * @ticket 23325
     606     * @covers ::wp_crop_image
    595607     */
    596608    public function test_wp_crop_image_error_on_saving() {
Note: See TracChangeset for help on using the changeset viewer.