Skip to content

Commit 50757ad

Browse files
committed
refactor: generate tests without json extension in getJsonFixture and assertEqualsFixture methods
1 parent c682aa0 commit 50757ad

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

stubs/test.blade.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function setUp(): void
3737
@if (in_array('C', $options))
3838
public function testCreate()
3939
{
40-
$data = $this->getJsonFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_request.json');
40+
$data = $this->getJsonFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_request');
4141

4242
@if (!$withAuth)
4343
$response = $this->json('post', '/{{$entities}}', $data);
@@ -48,16 +48,16 @@ public function testCreate()
4848
$response->assertCreated();
4949

5050
// TODO: Need to remove last argument after first successful start
51-
$this->assertEqualsFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_response.json', $response->json(), true);
51+
$this->assertEqualsFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_response', $response->json(), true);
5252

5353
// TODO: Need to remove last argument after first successful start
54-
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_state.json', true);
54+
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_state', true);
5555
}
5656

5757
@if ($withAuth)
5858
public function testCreateNoAuth()
5959
{
60-
$data = $this->getJsonFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_request.json');
60+
$data = $this->getJsonFixture('create_{{\Illuminate\Support\Str::snake($entity)}}_request');
6161

6262
$response = $this->json('post', '/{{$entities}}', $data);
6363

@@ -69,7 +69,7 @@ public function testCreateNoAuth()
6969
@if (in_array('U', $options))
7070
public function testUpdate()
7171
{
72-
$data = $this->getJsonFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_request.json');
72+
$data = $this->getJsonFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_request');
7373

7474
@if (!$withAuth)
7575
$response = $this->json('put', '/{{$entities}}/1', $data);
@@ -80,12 +80,12 @@ public function testUpdate()
8080
$response->assertNoContent();
8181

8282
// TODO: Need to remove last argument after first successful start
83-
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_state.json', true);
83+
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_state', true);
8484
}
8585

8686
public function testUpdateNotExists()
8787
{
88-
$data = $this->getJsonFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_request.json');
88+
$data = $this->getJsonFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_request');
8989

9090
@if (!$withAuth)
9191
$response = $this->json('put', '/{{$entities}}/0', $data);
@@ -101,7 +101,7 @@ public function testUpdateNotExists()
101101
@if ($withAuth)
102102
public function testUpdateNoAuth()
103103
{
104-
$data = $this->getJsonFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_request.json');
104+
$data = $this->getJsonFixture('update_{{\Illuminate\Support\Str::snake($entity)}}_request');
105105

106106
$response = $this->json('put', '/{{$entities}}/1', $data);
107107

@@ -124,7 +124,7 @@ public function testDelete()
124124
$response->assertNoContent();
125125

126126
// TODO: Need to remove last argument after first successful start
127-
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('delete_{{\Illuminate\Support\Str::snake($entity)}}_state.json', true);
127+
self::${{\Illuminate\Support\Str::camel($entity)}}State->assertChangesEqualsFixture('delete_{{\Illuminate\Support\Str::snake($entity)}}_state', true);
128128
}
129129

130130
public function testDeleteNotExists()
@@ -162,9 +162,9 @@ public function testGet()
162162
$response->assertOk();
163163

164164
// TODO: Need to remove after first successful start
165-
$this->exportJson('get_{{\Illuminate\Support\Str::snake($entity)}}.json', $response->json());
165+
$this->exportJson('get_{{\Illuminate\Support\Str::snake($entity)}}', $response->json());
166166

167-
$this->assertEqualsFixture('get_{{\Illuminate\Support\Str::snake($entity)}}.json', $response->json());
167+
$this->assertEqualsFixture('get_{{\Illuminate\Support\Str::snake($entity)}}', $response->json());
168168
}
169169

170170
public function testGetNotExists()

tests/fixtures/TestGeneratorTest/post_test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public function testCreate()
3131
$response->assertCreated();
3232

3333
// TODO: Need to remove last argument after first successful start
34-
$this->assertEqualsFixture('create_post_response.json', $response->json(), true);
34+
$this->assertEqualsFixture('create_post_response', $response->json(), true);
3535

3636
// TODO: Need to remove last argument after first successful start
37-
self::$postState->assertChangesEqualsFixture('create_post_state.json', true);
37+
self::$postState->assertChangesEqualsFixture('create_post_state', true);
3838
}
3939

4040
public function testCreateNoAuth()
@@ -55,7 +55,7 @@ public function testUpdate()
5555
$response->assertNoContent();
5656

5757
// TODO: Need to remove last argument after first successful start
58-
self::$postState->assertChangesEqualsFixture('update_post_state.json', true);
58+
self::$postState->assertChangesEqualsFixture('update_post_state', true);
5959
}
6060

6161
public function testUpdateNotExists()
@@ -87,7 +87,7 @@ public function testDelete()
8787
$response->assertNoContent();
8888

8989
// TODO: Need to remove last argument after first successful start
90-
self::$postState->assertChangesEqualsFixture('delete_post_state.json', true);
90+
self::$postState->assertChangesEqualsFixture('delete_post_state', true);
9191
}
9292

9393
public function testDeleteNotExists()
@@ -115,7 +115,7 @@ public function testGet()
115115
// TODO: Need to remove after first successful start
116116
$this->exportJson('get_post.json', $response->json());
117117

118-
$this->assertEqualsFixture('get_post.json', $response->json());
118+
$this->assertEqualsFixture('get_post', $response->json());
119119
}
120120

121121
public function testGetNotExists()

tests/fixtures/TestGeneratorTest/post_test_read_delete.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testDelete()
2929
$response->assertNoContent();
3030

3131
// TODO: Need to remove last argument after first successful start
32-
self::$postState->assertChangesEqualsFixture('delete_post_state.json', true);
32+
self::$postState->assertChangesEqualsFixture('delete_post_state', true);
3333
}
3434

3535
public function testDeleteNotExists()
@@ -57,7 +57,7 @@ public function testGet()
5757
// TODO: Need to remove after first successful start
5858
$this->exportJson('get_post.json', $response->json());
5959

60-
$this->assertEqualsFixture('get_post.json', $response->json());
60+
$this->assertEqualsFixture('get_post', $response->json());
6161
}
6262

6363
public function testGetNotExists()

0 commit comments

Comments
 (0)