Skip to content

Commit 7dc31b0

Browse files
committed
refactor: code
refs: #113
1 parent 8028968 commit 7dc31b0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/Generators/TestsGenerator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ protected function generateTests(): void
5555
'databaseTableName' => $this->getTableName($this->model),
5656
'entities' => $this->getTableName($this->model, '-'),
5757
'withAuth' => $this->withAuth,
58-
'modelsNamespace' => $this->getOrCreateNamespace('models')
58+
'modelsNamespace' => $this->getOrCreateNamespace('models'),
59+
'hasModificationEndpoints' => !empty(array_intersect($this->crudOptions, ['C', 'U', 'D'])),
5960
]);
6061

6162
$testName = $this->getTestClassName();

stubs/test.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace App\Tests;
22

3-
@if (!empty(array_intersect($options, ['C', 'U', 'D'])))
3+
@if ($hasModificationEndpoints)
44
use RonasIT\Support\Tests\ModelTestState;
55
use {{$modelsNamespace}}\{{$entity}};
66
@endif
@@ -17,7 +17,7 @@ class {{$entity}}Test extends TestCase
1717
protected static User $user;
1818

1919
@endif
20-
@if (!empty(array_intersect($options, ['C', 'U', 'D'])))
20+
@if ($hasModificationEndpoints)
2121
protected static ModelTestState ${{\Illuminate\Support\Str::camel($entity)}}State;
2222

2323
@endif
@@ -28,7 +28,7 @@ public function setUp() : void
2828

2929
self::$user ??= User::find(1);
3030
@endif
31-
@if (!empty(array_intersect($options, ['C', 'U', 'D'])))
31+
@if ($hasModificationEndpoints)
3232

3333
self::${{\Illuminate\Support\Str::camel($entity)}}State ??= new ModelTestState({{$entity}}::class);
3434
@endif

0 commit comments

Comments
 (0)