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.

git-svn-id: https://develop.svn.wordpress.org/trunk@54403 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2022-10-07 01:07:28 +00:00
parent 28fdf705dc
commit 063f946989

View File

@ -12,11 +12,27 @@
class Tests_REST_Server extends WP_Test_REST_TestCase {
protected static $icon_id;
/**
* Called before setting up all tests.
*/
public static function set_up_before_class() {
parent::set_up_before_class();
// Require files that need to load once.
require_once DIR_TESTROOT . '/includes/mock-invokable.php';
}
public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
$filename = DIR_TESTDATA . '/images/test-image-large.jpg';
self::$icon_id = $factory->attachment->create_upload_object( $filename );
}
public static function tear_down_after_class() {
wp_delete_attachment( self::$icon_id, true );
parent::tear_down_after_class();
}
public function set_up() {
parent::set_up();
@ -35,16 +51,6 @@ class Tests_REST_Server extends WP_Test_REST_TestCase {
parent::tear_down();
}
/**
* Called before setting up all tests.
*/
public static function set_up_before_class() {
parent::set_up_before_class();
// Require files that need to load once.
require_once DIR_TESTROOT . '/includes/mock-invokable.php';
}
public function test_envelope() {
$data = array(
'amount of arbitrary data' => 'alot',