@@ -332,13 +332,15 @@ public function invalid_entity_throws_exception(): void
332
332
public function can_customize_namespace (): void
333
333
{
334
334
$ tester = new CommandTester ((new Application (self ::bootKernel ()))->find ('make:factory ' ));
335
+ $ expectedFile = self ::tempFile ('src/My/Namespace/TagFactory.php ' );
335
336
336
- $ this ->assertFileDoesNotExist (self :: tempFile ( ' src/My/Namespace/TagFactory.php ' ) );
337
+ $ this ->assertFileDoesNotExist ($ expectedFile );
337
338
338
339
$ tester ->setInputs ([Tag::class]);
339
340
$ tester ->execute (['--namespace ' => 'My \\Namespace ' ]);
340
341
341
- $ this ->assertFileExists (self ::tempFile ('src/My/Namespace/TagFactory.php ' ));
342
+ $ this ->assertFileExists ($ expectedFile );
343
+ $ this ->assertStringContainsString ('namespace App \\My \\Namespace; ' , \file_get_contents ($ expectedFile ));
342
344
}
343
345
344
346
/**
@@ -347,12 +349,48 @@ public function can_customize_namespace(): void
347
349
public function can_customize_namespace_with_test_flag (): void
348
350
{
349
351
$ tester = new CommandTester ((new Application (self ::bootKernel ()))->find ('make:factory ' ));
352
+ $ expectedFile = self ::tempFile ('tests/My/Namespace/TagFactory.php ' );
350
353
351
- $ this ->assertFileDoesNotExist (self :: tempFile ( ' tests/My/Namespace/TagFactory.php ' ) );
354
+ $ this ->assertFileDoesNotExist ($ expectedFile );
352
355
353
356
$ tester ->setInputs ([Tag::class]);
354
357
$ tester ->execute (['--namespace ' => 'My \\Namespace ' , '--test ' => true ]);
355
358
356
- $ this ->assertFileExists (self ::tempFile ('tests/My/Namespace/TagFactory.php ' ));
359
+ $ this ->assertFileExists ($ expectedFile );
360
+ $ this ->assertStringContainsString ('namespace App \\Tests \\My \\Namespace; ' , \file_get_contents ($ expectedFile ));
361
+ }
362
+
363
+ /**
364
+ * @test
365
+ */
366
+ public function can_customize_namespace_with_root_namespace_prefix (): void
367
+ {
368
+ $ tester = new CommandTester ((new Application (self ::bootKernel ()))->find ('make:factory ' ));
369
+ $ expectedFile = self ::tempFile ('src/My/Namespace/TagFactory.php ' );
370
+
371
+ $ this ->assertFileDoesNotExist ($ expectedFile );
372
+
373
+ $ tester ->setInputs ([Tag::class]);
374
+ $ tester ->execute (['--namespace ' => 'App \\My \\Namespace ' ]);
375
+
376
+ $ this ->assertFileExists ($ expectedFile );
377
+ $ this ->assertStringContainsString ('namespace App \\My \\Namespace; ' , \file_get_contents ($ expectedFile ));
378
+ }
379
+
380
+ /**
381
+ * @test
382
+ */
383
+ public function can_customize_namespace_with_test_flag_with_root_namespace_prefix (): void
384
+ {
385
+ $ tester = new CommandTester ((new Application (self ::bootKernel ()))->find ('make:factory ' ));
386
+ $ expectedFile = self ::tempFile ('tests/My/Namespace/TagFactory.php ' );
387
+
388
+ $ this ->assertFileDoesNotExist ($ expectedFile );
389
+
390
+ $ tester ->setInputs ([Tag::class]);
391
+ $ tester ->execute (['--namespace ' => 'App \\Tests \\My \\Namespace ' , '--test ' => true ]);
392
+
393
+ $ this ->assertFileExists ($ expectedFile );
394
+ $ this ->assertStringContainsString ('namespace App \\Tests \\My \\Namespace; ' , \file_get_contents ($ expectedFile ));
357
395
}
358
396
}
0 commit comments