Update unit test to account for log files generated elsewhere in the test suite

This commit is contained in:
Corey McKrill 2023-10-25 09:17:47 -07:00
parent 3444484126
commit 3e7b8d1eec
No known key found for this signature in database
GPG Key ID: 84BBFE669C4D97B8
1 changed files with 25 additions and 4 deletions

View File

@ -19,9 +19,23 @@ class FileControllerTest extends WC_Unit_Test_Case {
*/
private $handler;
/**
* "System Under Test", an instance of the class to be tested.
*
* @var FileController
*/
private $sut;
/**
* Set up to do before running any of these tests.
*
* @return void
*/
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
self::delete_all_log_files();
}
/**
* Set up before each test.
*
@ -40,13 +54,20 @@ class FileControllerTest extends WC_Unit_Test_Case {
* @return void
*/
public function tearDown(): void {
// Delete all created log files.
self::delete_all_log_files();
parent::tearDown();
}
/**
* Delete all existing log files.
*
* @return void
*/
private static function delete_all_log_files(): void {
$files = glob( trailingslashit( realpath( Constants::get_constant( 'WC_LOG_DIR' ) ) ) . '*.log' );
foreach ( $files as $file ) {
@unlink( $file );
}
parent::tearDown();
}
/**