diff --git a/src/CrudMake.php b/src/CrudMake.php index 2504ad4..2c2e71d 100644 --- a/src/CrudMake.php +++ b/src/CrudMake.php @@ -137,7 +137,8 @@ class CrudMake extends Command public function getUnitTestContent() { - return $this->files->get(__DIR__.'/stubs/unit-test.stub'); + $stub = $this->files->get(__DIR__.'/stubs/unit-test.stub'); + return $this->replaceUnitTestDummyStrings($stub)->replaceClass($stub); } protected function makeDirectory($path) @@ -171,6 +172,17 @@ class CrudMake extends Command return $this; } + protected function replaceUnitTestDummyStrings(&$stub) + { + $stub = str_replace( + ['DummyClass'], + [$this->modelName.'Test'], + $stub + ); + + return $this; + } + protected function replaceClass($stub) { $class = str_plural($this->modelName); diff --git a/src/stubs/unit-test.stub b/src/stubs/unit-test.stub index 315e707..6a41a88 100644 --- a/src/stubs/unit-test.stub +++ b/src/stubs/unit-test.stub @@ -4,7 +4,6 @@ namespace DummyNamespace; use Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; class DummyClass extends TestCase { diff --git a/tests/CrudMakeCommandTest.php b/tests/CrudMakeCommandTest.php index 1bd42be..73602ad 100644 --- a/tests/CrudMakeCommandTest.php +++ b/tests/CrudMakeCommandTest.php @@ -187,9 +187,8 @@ namespace DummyNamespace; use Tests\TestCase; use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; -class DummyClass extends TestCase +class ItemTest extends TestCase { /** * A basic test example.