Make WordPress Core

Changeset 54403


Ignore:
Timestamp:
10/07/2022 01:07:28 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Tests: Clean up test image for site icon in Tests_REST_Server on teardown.

This makes sure there are no leftover images after the test class is run.

Follow-up to [52080], [53463], [53920].

See #55652.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r54083 r54403  
    1313    protected static $icon_id;
    1414
     15    /**
     16     * Called before setting up all tests.
     17     */
     18    public static function set_up_before_class() {
     19        parent::set_up_before_class();
     20
     21        // Require files that need to load once.
     22        require_once DIR_TESTROOT . '/includes/mock-invokable.php';
     23    }
     24
    1525    public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
    1626        $filename      = DIR_TESTDATA . '/images/test-image-large.jpg';
    1727        self::$icon_id = $factory->attachment->create_upload_object( $filename );
     28    }
     29
     30    public static function tear_down_after_class() {
     31        wp_delete_attachment( self::$icon_id, true );
     32
     33        parent::tear_down_after_class();
    1834    }
    1935
     
    3450
    3551        parent::tear_down();
    36     }
    37 
    38     /**
    39      * Called before setting up all tests.
    40      */
    41     public static function set_up_before_class() {
    42         parent::set_up_before_class();
    43 
    44         // Require files that need to load once.
    45         require_once DIR_TESTROOT . '/includes/mock-invokable.php';
    4652    }
    4753
Note: See TracChangeset for help on using the changeset viewer.