Skip to content

Commit 14dd540

Browse files
committed
feat: use model test state
refs: #97
1 parent ee4d61f commit 14dd540

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Generators/AbstractTestsGenerator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ abstract class AbstractTestsGenerator extends EntityGenerator
1717
protected bool $withAuth = false;
1818

1919
const array FIXTURE_TYPES = [
20-
'create' => ['request', 'response'],
21-
'update' => ['request'],
20+
'create' => ['request', 'response', 'state'],
21+
'update' => ['request', 'state'],
22+
'delete' => ['state'],
2223
];
2324

2425
const string EMPTY_GUARDED_FIELD = '*';
@@ -194,6 +195,8 @@ protected function generateFixtures(): void
194195
$object = $this->getFixtureValuesList($this->model);
195196
$entity = Str::snake($this->model);
196197

198+
dd($object, self::FIXTURE_TYPES);
199+
197200
foreach (self::FIXTURE_TYPES as $type => $modifications) {
198201
if ($this->isFixtureNeeded($type)) {
199202
foreach ($modifications as $modification) {

stubs/test.blade.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testCreate()
4949

5050
$this->assertEqualsFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_response.json', $response->json());
5151

52-
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_response.json');
52+
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_state.json');
5353
}
5454

5555
@if ($withAuth)
@@ -77,7 +77,7 @@ public function testUpdate()
7777

7878
$response->assertNoContent();
7979

80-
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_response.json');
80+
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_state.json');
8181
}
8282

8383
public function testUpdateNotExists()
@@ -116,7 +116,7 @@ public function testDelete()
116116

117117
$response->assertNoContent();
118118

119-
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('delete_{{\Illuminate\Support\Str::snake($entity)}}_response.json');
119+
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('delete_{{\Illuminate\Support\Str::snake($entity)}}_state.json');
120120
}
121121

122122
public function testDeleteNotExists()

0 commit comments

Comments
 (0)