Skip to content

Commit 1fc50ce

Browse files
committed
test: Added Cleanup Method
1 parent 6746050 commit 1fc50ce

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

tests/WebFiori/Framework/Tests/Cli/IntegrationAllCommandsTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,31 @@
2020
* @author Ibrahim
2121
*/
2222
class IntegrationAllCommandsTest extends CLITestCase {
23+
24+
private function cleanupTestFiles() {
25+
$cleanupPaths = [
26+
APP_PATH . 'Database' . DIRECTORY_SEPARATOR . 'Migrations' . DIRECTORY_SEPARATOR . 'CreateUsersTable*.php',
27+
APP_PATH . 'Database' . DIRECTORY_SEPARATOR . 'Seeders' . DIRECTORY_SEPARATOR . 'SeedUsers*.php',
28+
APP_PATH . 'Infrastructure' . DIRECTORY_SEPARATOR . 'Schema' . DIRECTORY_SEPARATOR . 'TestTable*.php',
29+
APP_PATH . 'Domain' . DIRECTORY_SEPARATOR . 'UserEntity*.php',
30+
APP_PATH . 'Infrastructure' . DIRECTORY_SEPARATOR . 'Repository' . DIRECTORY_SEPARATOR . 'TestRepo*.php',
31+
APP_PATH . 'Apis' . DIRECTORY_SEPARATOR . 'Test*Service.php'
32+
];
33+
34+
foreach ($cleanupPaths as $pattern) {
35+
foreach (glob($pattern) as $file) {
36+
unlink($file);
37+
}
38+
}
39+
}
40+
2341
/**
2442
* @test
2543
*/
2644
public function testAddDBConnection00() {
45+
// Clean up any leftover migration/seeder files from previous test runs
46+
$this->cleanupTestFiles();
47+
2748
//Step 1: Add DB Connection
2849
$connName = 'db-connection-'.(count(App::getConfig()->getDBConnections()) + 1);
2950
$output = $this->executeSingleCommand(new AddDbConnectionCommand(), [], [

0 commit comments

Comments
 (0)