7
7
use Faker \Factory as FakerFactory ;
8
8
use Faker \Generator ;
9
9
use Illuminate \Contracts \Console \Kernel ;
10
- use Illuminate \Database \Eloquent \Factories \Factory ;
11
10
use Illuminate \Support \Facades \Artisan ;
12
- use Illuminate \Support \Facades \File ;
13
11
use Orchestra \Testbench \TestCase as OrchestraTestCase ;
14
12
use Spatie \LaravelRay \RayServiceProvider ;
15
13
use WayOfDev \Cycle \Bridge \Laravel \Providers \CycleServiceProvider ;
@@ -29,6 +27,8 @@ class TestCase extends OrchestraTestCase
29
27
use InteractsWithDatabase;
30
28
use RefreshDatabase;
31
29
30
+ protected ?string $ migrationsPath = null ;
31
+
32
32
final protected static function faker (string $ locale = 'en_US ' ): Generator
33
33
{
34
34
/** @var array<string, Generator> $fakers */
@@ -45,27 +45,24 @@ protected function setUp(): void
45
45
{
46
46
parent ::setUp ();
47
47
48
- $ this ->cleanupMigrations ();
48
+ $ this ->migrationsPath = __DIR__ . '/../app/database/migrations/cycle ' ;
49
+ $ this ->cleanupMigrations ($ this ->migrationsPath . '/*.php ' );
49
50
$ this ->refreshDatabase ();
50
51
51
- Factory::guessFactoryNamesUsing (
52
- static fn (string $ modelName ) => 'WayOfDev \\Laravel \\Cycle \\Database \\Factories \\' . class_basename ($ modelName ) . 'Factory '
53
- );
54
-
55
52
if (app ()->environment () === 'testing ' ) {
56
53
config ()->set ([
57
54
'cycle.tokenizer.directories ' => array_merge (
58
55
config ('cycle.tokenizer.directories ' ),
59
56
[__DIR__ . '/../app/Entities ' ]
60
57
),
61
- 'cycle.migrations.directory ' => __DIR__ . ' /../app/database/migrations/cycle ' ,
58
+ 'cycle.migrations.directory ' => $ this -> migrationsPath ,
62
59
]);
63
60
}
64
61
}
65
62
66
63
protected function tearDown (): void
67
64
{
68
- $ this ->cleanupMigrations ();
65
+ $ this ->cleanupMigrations ($ this -> migrationsPath . ' /*.php ' );
69
66
$ this ->refreshDatabase ();
70
67
71
68
parent ::tearDown ();
@@ -105,14 +102,4 @@ protected function getPackageProviders($app): array
105
102
RayServiceProvider::class,
106
103
];
107
104
}
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
- }
118
105
}
0 commit comments