diff --git a/tests/phpunit/tests/rest-api/rest-server.php b/tests/phpunit/tests/rest-api/rest-server.php index aa927c8b1c..06beab745a 100644 --- a/tests/phpunit/tests/rest-api/rest-server.php +++ b/tests/phpunit/tests/rest-api/rest-server.php @@ -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',