@@ -10,6 +10,7 @@ class ModelMakeCommandTest extends TestCase
10
10
'app/Http/Controllers/FooController.php ' ,
11
11
'app/Http/Controllers/BarController.php ' ,
12
12
'database/factories/FooFactory.php ' ,
13
+ 'database/factories/Foo/BarFactory.php ' ,
13
14
'database/seeders/FooSeeder.php ' ,
14
15
'tests/Feature/Models/FooTest.php ' ,
15
16
];
@@ -119,6 +120,30 @@ public function testItCanGenerateModelFileWithFactoryOption()
119
120
$ this ->assertFilenameNotExists ('database/seeders/FooSeeder.php ' );
120
121
}
121
122
123
+ public function testItCanGenerateModelFileWithFactoryOptionForDeepFolder ()
124
+ {
125
+ $ this ->artisan ('make:model ' , ['name ' => 'Foo/Bar ' , '--factory ' => true ])
126
+ ->assertExitCode (0 );
127
+
128
+ $ this ->assertFileContains ([
129
+ 'namespace App\Models\Foo; ' ,
130
+ 'use Illuminate\Database\Eloquent\Factories\HasFactory; ' ,
131
+ 'use Illuminate\Database\Eloquent\Model; ' ,
132
+ 'class Bar extends Model ' ,
133
+ '/** @use HasFactory<\Database\Factories\Foo\BarFactory> */ ' ,
134
+ 'use HasFactory; ' ,
135
+ ], 'app/Models/Foo/Bar.php ' );
136
+
137
+ $ this ->assertFileNotContains ([
138
+ '{{ factoryImport }} ' ,
139
+ '{{ factory }} ' ,
140
+ ], 'app/Models/Foo/Bar.php ' );
141
+
142
+ $ this ->assertFilenameNotExists ('app/Http/Controllers/Foo/BarController.php ' );
143
+ $ this ->assertFilenameExists ('database/factories/Foo/BarFactory.php ' );
144
+ $ this ->assertFilenameNotExists ('database/seeders/Foo/BarSeeder.php ' );
145
+ }
146
+
122
147
public function testItCanGenerateModelFileWithMigrationOption ()
123
148
{
124
149
$ this ->artisan ('make:model ' , ['name ' => 'Foo ' , '--migration ' => true ])
0 commit comments