Skip to content

Commit 33aba43

Browse files
Update HelperMakeCommand
- Update HelperMakeCommandTest - Update snapshots
1 parent 09beb83 commit 33aba43

4 files changed

+10
-9
lines changed

src/Commands/Make/HelperMakeCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ private function getClassNameWithoutNamespace(): array|string
6666

6767
public function getDefaultNamespace(): string
6868
{
69-
return config('modules.paths.generator.helpers.namespace', 'Helpers');
69+
return config('modules.paths.generator.helpers.namespace')
70+
?? $this->namespace(config('modules.paths.generator.helpers.path', 'app/Helpers'));
7071
}
7172

7273
protected function getStubName(): string

tests/Commands/Make/HelperMakeCommandTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function test_it_generates_a_new_helper_class()
3939
{
4040
$code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']);
4141

42-
$this->assertTrue(is_file($this->modulePath.'/Helpers/MyHelper.php'));
42+
$this->assertTrue(is_file($this->modulePath.'/app/Helpers/MyHelper.php'));
4343
$this->assertSame(0, $code);
4444
}
4545

@@ -48,23 +48,23 @@ public function test_it_generates_a_new_helper_class_can_override_with_force_opt
4848
$this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']);
4949
$code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog', '--force' => true]);
5050

51-
$this->assertTrue(is_file($this->modulePath.'/Helpers/MyHelper.php'));
51+
$this->assertTrue(is_file($this->modulePath.'/app/Helpers/MyHelper.php'));
5252
$this->assertSame(0, $code);
5353
}
5454

5555
public function test_it_generates_a_new_helper_class_can_use_invoke_option()
5656
{
5757
$code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog', '--invokable' => true]);
5858

59-
$this->assertTrue(is_file($this->modulePath.'/Helpers/MyHelper.php'));
59+
$this->assertTrue(is_file($this->modulePath.'/app/Helpers/MyHelper.php'));
6060
$this->assertSame(0, $code);
6161
}
6262

6363
public function test_it_generated_correct_file_with_content()
6464
{
6565
$code = $this->artisan('module:make-helper', ['name' => 'MyHelper', 'module' => 'Blog']);
6666

67-
$file = $this->finder->get($this->modulePath.'/Helpers/MyHelper.php');
67+
$file = $this->finder->get($this->modulePath.'/app/Helpers/MyHelper.php');
6868

6969
$this->assertMatchesSnapshot($file);
7070
$this->assertSame(0, $code);
@@ -74,15 +74,15 @@ public function test_it_can_generate_a_helper_in_sub_namespace_in_correct_folder
7474
{
7575
$code = $this->artisan('module:make-helper', ['name' => 'Api\\MyHelper', 'module' => 'Blog']);
7676

77-
$this->assertTrue(is_file($this->modulePath.'/Helpers/Api/MyHelper.php'));
77+
$this->assertTrue(is_file($this->modulePath.'/app/Helpers/Api/MyHelper.php'));
7878
$this->assertSame(0, $code);
7979
}
8080

8181
public function test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file()
8282
{
8383
$code = $this->artisan('module:make-helper', ['name' => 'Api\\MyHelper', 'module' => 'Blog']);
8484

85-
$file = $this->finder->get($this->modulePath.'/Helpers/Api/MyHelper.php');
85+
$file = $this->finder->get($this->modulePath.'/app/Helpers/Api/MyHelper.php');
8686

8787
$this->assertMatchesSnapshot($file);
8888
$this->assertSame(0, $code);

tests/Commands/Make/__snapshots__/HelperMakeCommandTest__test_it_can_generate_a_helper_in_sub_namespace_with_correct_generated_file__1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Modules\Blog\Helpers\Api;
3+
namespace Modules\Blog\App\Helpers\Api;
44

55
class MyHelper
66
{

tests/Commands/Make/__snapshots__/HelperMakeCommandTest__test_it_generated_correct_file_with_content__1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Modules\Blog\Helpers;
3+
namespace Modules\Blog\App\Helpers;
44

55
class MyHelper
66
{

0 commit comments

Comments
 (0)