From ef660d9ddbbfada4187ea8aa2dd6eb1d136cb11c Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 22 Aug 2024 01:36:23 +0100 Subject: [PATCH 1/3] Restructure and update stubs - Move test files to dedicated paths in `/tests` - Remove unused class imports - Update method DocBlock comments - Rename methods to more readable phrases --- .../{feature-test.stub => tests/feature.stub} | 6 ++---- src/Commands/stubs/tests/unit.stub | 16 +++++++++++++++ src/Commands/stubs/unit-test.stub | 20 ------------------- 3 files changed, 18 insertions(+), 24 deletions(-) rename src/Commands/stubs/{feature-test.stub => tests/feature.stub} (52%) create mode 100644 src/Commands/stubs/tests/unit.stub delete mode 100644 src/Commands/stubs/unit-test.stub diff --git a/src/Commands/stubs/feature-test.stub b/src/Commands/stubs/tests/feature.stub similarity index 52% rename from src/Commands/stubs/feature-test.stub rename to src/Commands/stubs/tests/feature.stub index 316953493..db7d415e9 100644 --- a/src/Commands/stubs/feature-test.stub +++ b/src/Commands/stubs/tests/feature.stub @@ -3,15 +3,13 @@ namespace $NAMESPACE$; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Foundation\Testing\RefreshDatabase; class $CLASS$ extends TestCase { /** - * A basic feature test example. + * A basic test example. */ - public function testExample(): void + public function test_the_application_returns_a_successful_response(): void { $response = $this->get('/'); diff --git a/src/Commands/stubs/tests/unit.stub b/src/Commands/stubs/tests/unit.stub new file mode 100644 index 000000000..938e5da00 --- /dev/null +++ b/src/Commands/stubs/tests/unit.stub @@ -0,0 +1,16 @@ +assertTrue(true); + } +} diff --git a/src/Commands/stubs/unit-test.stub b/src/Commands/stubs/unit-test.stub deleted file mode 100644 index be0bd559b..000000000 --- a/src/Commands/stubs/unit-test.stub +++ /dev/null @@ -1,20 +0,0 @@ -assertTrue(true); - } -} From b37a93382f40c526b8a93ddcd0b491e70c9c8acf Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 22 Aug 2024 01:37:50 +0100 Subject: [PATCH 2/3] Update `TestMakeCommand::getTemplateContents()` --- src/Commands/Make/TestMakeCommand.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Commands/Make/TestMakeCommand.php b/src/Commands/Make/TestMakeCommand.php index 105861903..e2bacea1a 100644 --- a/src/Commands/Make/TestMakeCommand.php +++ b/src/Commands/Make/TestMakeCommand.php @@ -61,11 +61,7 @@ protected function getOptions() protected function getTemplateContents() { $module = $this->laravel['modules']->findOrFail($this->getModuleName()); - $stub = '/unit-test.stub'; - - if ($this->option('feature')) { - $stub = '/feature-test.stub'; - } + $stub = '/tests/'.(($this->option('feature')) ? 'feature' : 'unit').'.stub'; return (new Stub($stub, [ 'NAMESPACE' => $this->getClassNamespace($module), From 651a267db7f31633d10487b0f7f87f5bac088a7e Mon Sep 17 00:00:00 2001 From: Solomon Ochepa Date: Thu, 22 Aug 2024 01:59:36 +0100 Subject: [PATCH 3/3] [test] Update snapshots --- ...est_it_can_change_the_default_feature_namespace__1.txt | 6 ++---- ...n_change_the_default_feature_namespace_specific__1.txt | 6 ++---- ...__test_it_can_change_the_default_unit_namespace__1.txt | 8 ++------ ..._can_change_the_default_unit_namespace_specific__1.txt | 8 ++------ ..._it_generated_correct_feature_file_with_content__1.txt | 6 ++---- ...est_it_generated_correct_unit_file_with_content__1.txt | 8 ++------ 6 files changed, 12 insertions(+), 30 deletions(-) diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt index dba6e35a1..3986e14b4 100644 --- a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace__1.txt @@ -3,15 +3,13 @@ namespace Modules\Blog\SuperTests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Foundation\Testing\RefreshDatabase; class EloquentPostRepositoryTest extends TestCase { /** - * A basic feature test example. + * A basic test example. */ - public function testExample(): void + public function test_the_application_returns_a_successful_response(): void { $response = $this->get('/'); diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt index dba6e35a1..3986e14b4 100644 --- a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_feature_namespace_specific__1.txt @@ -3,15 +3,13 @@ namespace Modules\Blog\SuperTests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Foundation\Testing\RefreshDatabase; class EloquentPostRepositoryTest extends TestCase { /** - * A basic feature test example. + * A basic test example. */ - public function testExample(): void + public function test_the_application_returns_a_successful_response(): void { $response = $this->get('/'); diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt index 273dc9657..ae35f4fe3 100644 --- a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace__1.txt @@ -3,17 +3,13 @@ namespace Modules\Blog\SuperTests\Unit; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Foundation\Testing\RefreshDatabase; class EloquentPostRepositoryTest extends TestCase { /** - * A basic unit test example. - * - * @return void + * A basic test example. */ - public function testExample() + public function test_that_true_is_true(): void { $this->assertTrue(true); } diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt index fcbfc0da3..d6cc19884 100644 --- a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_can_change_the_default_unit_namespace_specific__1.txt @@ -3,17 +3,13 @@ namespace Modules\Blog\Tests\Unit; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Foundation\Testing\RefreshDatabase; class EloquentPostRepositoryTest extends TestCase { /** - * A basic unit test example. - * - * @return void + * A basic test example. */ - public function testExample() + public function test_that_true_is_true(): void { $this->assertTrue(true); } diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt index 6378738a3..f59071152 100644 --- a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_feature_file_with_content__1.txt @@ -3,15 +3,13 @@ namespace Modules\Blog\Tests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Foundation\Testing\RefreshDatabase; class EloquentPostRepositoryTest extends TestCase { /** - * A basic feature test example. + * A basic test example. */ - public function testExample(): void + public function test_the_application_returns_a_successful_response(): void { $response = $this->get('/'); diff --git a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt index fcbfc0da3..d6cc19884 100644 --- a/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt +++ b/tests/Commands/Make/__snapshots__/TestMakeCommandTest__test_it_generated_correct_unit_file_with_content__1.txt @@ -3,17 +3,13 @@ namespace Modules\Blog\Tests\Unit; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithFaker; -use Illuminate\Foundation\Testing\RefreshDatabase; class EloquentPostRepositoryTest extends TestCase { /** - * A basic unit test example. - * - * @return void + * A basic test example. */ - public function testExample() + public function test_that_true_is_true(): void { $this->assertTrue(true); }