Skip to content

Commit

Permalink
remove font files created by tests after tests run (#54771)
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbenedetto authored Sep 26, 2023
1 parent da8f1aa commit 10cf4e6
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 );
}
}
}

0 comments on commit 10cf4e6

Please sign in to comment.