diff --git a/src/Commands/Generator.php b/src/Commands/Generator.php index e92a2cc..9dfd472 100644 --- a/src/Commands/Generator.php +++ b/src/Commands/Generator.php @@ -19,7 +19,7 @@ */ abstract class Generator extends Command implements GeneratesCodeListener, PromptsForMissingInput { - use CodeGenerator; + use CodeGenerator, TestGenerator; /** * The filesystem instance. @@ -202,7 +202,7 @@ public function afterCodeHasBeenGenerated(string $className, string $path): void { if (\in_array(CreatesMatchingTest::class, class_uses_recursive($this))) { /** @phpstan-ignore-next-line */ - $this->handleTestCreation($path); + $this->handleTestCreationUsingCanvas($path); } } diff --git a/src/TestGenerator.php b/src/TestGenerator.php new file mode 100644 index 0000000..6b7184e --- /dev/null +++ b/src/TestGenerator.php @@ -0,0 +1,24 @@ +option('test') && ! $this->option('pest')) { + return false; + } + + return $this->callSilent('make:test', [ + 'name' => Str::of($path)->after($this->preset->sourcePath())->beforeLast('.php')->append('Test')->replace('\\', '/'), + '--pest' => $this->option('pest'), + ]) == 0; + } +}