@@ -21,7 +21,7 @@ class {{$entity}}Test extends TestCase
2121 protected static ModelTestState ${{ \Illuminate \Support \Str:: camel ($entity ) } } State;
2222
2323@endif
24- public function setUp() : void
24+ public function setUp(): void
2525 {
2626 parent::setUp();
2727@if ($withAuth )
@@ -47,7 +47,8 @@ public function testCreate()
4747
4848 $response->assertCreated();
4949
50- $this->assertEqualsFixture('create_{{ \Illuminate \Support \Str:: snake ($entity ) } } _response.json', $response->json());
50+ // TODO: Need to remove last argument after first successful start
51+ $this->assertEqualsFixture('create_{{ \Illuminate \Support \Str:: snake ($entity ) } } _response.json', $response->json(), true);
5152
5253 // TODO: Need to remove last argument after first successful start
5354 self::${{ \Illuminate \Support \Str:: camel ($entity ) } } State->assertChangesEqualsFixture('create_{{ \Illuminate \Support \Str:: snake ($entity ) } } _state.json', true);
@@ -93,6 +94,8 @@ public function testUpdateNotExists()
9394@endif
9495
9596 $response->assertNotFound();
97+
98+ self::${{ \Illuminate \Support \Str:: camel ($entity ) } } State->assertNotChanged();
9699 }
97100
98101@if ($withAuth )
@@ -103,6 +106,8 @@ public function testUpdateNoAuth()
103106 $response = $this->json('put', '/{{ $entities } } /1', $data);
104107
105108 $response->assertUnauthorized();
109+
110+ self::${{ \Illuminate \Support \Str:: camel ($entity ) } } State->assertNotChanged();
106111 }
107112
108113@endif
@@ -172,6 +177,15 @@ public function testGetNotExists()
172177
173178 $response->assertNotFound();
174179 }
180+ @if ($withAuth )
181+
182+ public function testGetNoAuth()
183+ {
184+ $response = $this->json('get', '/{{ $entities } } /1');
185+
186+ $response->assertUnauthorized();
187+ }
188+ @endif
175189
176190 public static function getSearchFilters(): array
177191 {
@@ -193,7 +207,7 @@ public static function getSearchFilters(): array
193207 #[DataProvider('getSearchFilters')]
194208 public function testSearch(array $filter, string $fixture)
195209 {
196- $response = $this->json('get', '/{{ $entities } } ', $filter);
210+ $response = $this->actingAs(self::$user)-> json('get', '/{{ $entities } } ', $filter);
197211
198212 $response->assertOk();
199213
@@ -202,5 +216,14 @@ public function testSearch(array $filter, string $fixture)
202216
203217 $this->assertEqualsFixture($fixture, $response->json());
204218 }
219+
220+ @if ($withAuth )
221+ public function testSearchNoAuth()
222+ {
223+ $response = $this->json('get', '/{{ $entities } } ');
224+
225+ $response->assertUnauthorized();
226+ }
227+ @endif
205228@endif
206229}
0 commit comments