77use Faker \Factory as FakerFactory ;
88use Faker \Generator ;
99use Illuminate \Contracts \Console \Kernel ;
10- use Illuminate \Database \Eloquent \Factories \Factory ;
1110use Illuminate \Support \Facades \Artisan ;
12- use Illuminate \Support \Facades \File ;
1311use Orchestra \Testbench \TestCase as OrchestraTestCase ;
1412use Spatie \LaravelRay \RayServiceProvider ;
1513use WayOfDev \Cycle \Bridge \Laravel \Providers \CycleServiceProvider ;
@@ -29,6 +27,8 @@ class TestCase extends OrchestraTestCase
2927 use InteractsWithDatabase;
3028 use RefreshDatabase;
3129
30+ protected ?string $ migrationsPath = null ;
31+
3232 final protected static function faker (string $ locale = 'en_US ' ): Generator
3333 {
3434 /** @var array<string, Generator> $fakers */
@@ -45,27 +45,24 @@ protected function setUp(): void
4545 {
4646 parent ::setUp ();
4747
48- $ this ->cleanupMigrations ();
48+ $ this ->migrationsPath = __DIR__ . '/../app/database/migrations/cycle ' ;
49+ $ this ->cleanupMigrations ($ this ->migrationsPath . '/*.php ' );
4950 $ this ->refreshDatabase ();
5051
51- Factory::guessFactoryNamesUsing (
52- static fn (string $ modelName ) => 'WayOfDev \\Laravel \\Cycle \\Database \\Factories \\' . class_basename ($ modelName ) . 'Factory '
53- );
54-
5552 if (app ()->environment () === 'testing ' ) {
5653 config ()->set ([
5754 'cycle.tokenizer.directories ' => array_merge (
5855 config ('cycle.tokenizer.directories ' ),
5956 [__DIR__ . '/../app/Entities ' ]
6057 ),
61- 'cycle.migrations.directory ' => __DIR__ . ' /../app/database/migrations/cycle ' ,
58+ 'cycle.migrations.directory ' => $ this -> migrationsPath ,
6259 ]);
6360 }
6461 }
6562
6663 protected function tearDown (): void
6764 {
68- $ this ->cleanupMigrations ();
65+ $ this ->cleanupMigrations ($ this -> migrationsPath . ' /*.php ' );
6966 $ this ->refreshDatabase ();
7067
7168 parent ::tearDown ();
@@ -105,14 +102,4 @@ protected function getPackageProviders($app): array
105102 RayServiceProvider::class,
106103 ];
107104 }
108-
109- protected function cleanupMigrations (): void
110- {
111- $ path = __DIR__ . '/../app/database/migrations/cycle/*.php ' ;
112-
113- $ files = File::glob ($ path );
114- foreach ($ files as $ file ) {
115- File::delete ($ file );
116- }
117- }
118105}
0 commit comments