diff --git a/tests/ResetsApplication.php b/tests/ResetsApplication.php new file mode 100644 index 0000000..6330d67 --- /dev/null +++ b/tests/ResetsApplication.php @@ -0,0 +1,23 @@ +__invoke(); + StarterFileService::publish(); + } +} \ No newline at end of file diff --git a/tests/TestCase.php b/tests/TestCase.php index b1472d3..e4cf6e5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,18 +2,14 @@ namespace Tests; -use Hyde\Framework\Actions\CreatesDefaultDirectories; -use Hyde\Framework\Hyde; -use Hyde\Framework\Services\StarterFileService; -use Illuminate\Support\Facades\File; use LaravelZero\Framework\Testing\TestCase as BaseTestCase; -/** - * @todo make the directory resets more granular to speed up testing. - */ abstract class TestCase extends BaseTestCase { use CreatesApplication; + use ResetsApplication; + + protected static bool $booted = false; /** * Setup the test environment. @@ -24,16 +20,11 @@ protected function setUp(): void { parent::setUp(); - File::deleteDirectories([ - Hyde::path('_pages'), - Hyde::path('_posts'), - Hyde::path('_media'), - Hyde::path('_docs'), - Hyde::path('_site'), - ]); + if (!self::$booted) { + $this->resetApplication(); - (new CreatesDefaultDirectories)->__invoke(); - StarterFileService::publish(); + self::$booted = true; + } } /** @@ -43,17 +34,6 @@ protected function setUp(): void */ protected function tearDown(): void { - File::deleteDirectories([ - Hyde::path('_pages'), - Hyde::path('_posts'), - Hyde::path('_media'), - Hyde::path('_docs'), - Hyde::path('_site'), - ]); - - (new CreatesDefaultDirectories)->__invoke(); - StarterFileService::publish(); - parent::tearDown(); } }