Skip to content

Commit

Permalink
Refactor cleanSlate() to not rely on app being booted.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasperTey committed Nov 16, 2024
1 parent e4bb64d commit 7eb2500
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ protected function setUp(): void
);
});

$this->beforeApplicationDestroyed(function () {
$this->cleanSlate();
});
// $this->beforeApplicationDestroyed(function () {
// $this->cleanSlate();
// });

parent::setUp();
}

protected function tearDown(): void
{
$this->cleanSlate();

parent::tearDown();
}

public static function configValues(array $values)
{
static::$configValues = $values;
Expand Down Expand Up @@ -181,21 +188,22 @@ protected function composerReload()

protected function cleanSlate()
{
File::delete(base_path('config/ddd.php'));
$basePath = $this->getBasePath();

File::delete($basePath.'/config/ddd.php');

// File::cleanDirectory(app_path());
File::cleanDirectory(app_path('Models'));
File::cleanDirectory(base_path('database/factories'));
File::cleanDirectory($basePath.'/app/Models');
File::cleanDirectory($basePath.'/database/factories');

File::deleteDirectory(base_path('src'));
File::deleteDirectory(resource_path('stubs/ddd'));
File::deleteDirectory(base_path('stubs'));
File::deleteDirectory(base_path('Custom'));
File::deleteDirectory(app_path('Policies'));
File::deleteDirectory(app_path('Modules'));
File::deleteDirectory(base_path('bootstrap/cache/ddd'));
File::deleteDirectory($basePath.'/src');
File::deleteDirectory($basePath.'/resources/stubs/ddd');
File::deleteDirectory($basePath.'/stubs');
File::deleteDirectory($basePath.'/Custom');
File::deleteDirectory($basePath.'/app/Policies');
File::deleteDirectory($basePath.'/app/Modules');
File::deleteDirectory($basePath.'/bootstrap/cache/ddd');

File::copy(__DIR__.'/.skeleton/composer.json', base_path('composer.json'));
File::copy(__DIR__.'/.skeleton/composer.json', $basePath.'/composer.json');

return $this;
}
Expand Down

0 comments on commit 7eb2500

Please sign in to comment.