@@ -10,6 +10,7 @@ class ModelMakeCommandTest extends TestCase
1010 'app/Http/Controllers/FooController.php ' ,
1111 'app/Http/Controllers/BarController.php ' ,
1212 'database/factories/FooFactory.php ' ,
13+ 'database/factories/Foo/BarFactory.php ' ,
1314 'database/seeders/FooSeeder.php ' ,
1415 'tests/Feature/Models/FooTest.php ' ,
1516 ];
@@ -119,6 +120,30 @@ public function testItCanGenerateModelFileWithFactoryOption()
119120 $ this ->assertFilenameNotExists ('database/seeders/FooSeeder.php ' );
120121 }
121122
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+
122147 public function testItCanGenerateModelFileWithMigrationOption ()
123148 {
124149 $ this ->artisan ('make:model ' , ['name ' => 'Foo ' , '--migration ' => true ])
0 commit comments