diff --git a/phpunit/tests/fonts/font-library/wpRestFontLibraryController/base.php b/phpunit/tests/fonts/font-library/wpRestFontLibraryController/base.php index f1e712bab85b40..5caa40b2892932 100644 --- a/phpunit/tests/fonts/font-library/wpRestFontLibraryController/base.php +++ b/phpunit/tests/fonts/font-library/wpRestFontLibraryController/base.php @@ -7,9 +7,19 @@ */ abstract class WP_REST_Font_Library_Controller_UnitTestCase extends WP_UnitTestCase { + /** + * Fonts directory. + * + * @var string + */ + protected static $fonts_dir; + + public function set_up() { parent::set_up(); + static::$fonts_dir = WP_Font_Library::get_fonts_dir(); + // Create a user with administrator role. $admin_id = $this->factory->user->create( array( @@ -30,5 +40,10 @@ public function tear_down() { $property = $reflection->getProperty( 'collections' ); $property->setAccessible( true ); $property->setValue( array() ); + + // Clean up the /fonts directory. + foreach ( $this->files_in_dir( static::$fonts_dir ) as $file ) { + @unlink( $file ); + } } }