Skip to content

Commit

Permalink
fix: Include API key with test generation
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-code-labx committed May 13, 2024
1 parent eff7851 commit 79de5b1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/Commands/Generator/stubs/tests/resource.pest.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ describe('{{ modelClassName }}', function (): void {

$response = getJson(
uri: route('api.v1.filament.{{ $modelVarPlural }}.show', ${{ $modelVarSingular }}),
headers: ['x-rest-presenter' => '{{ modelClassName }}'],
headers: [
'x-rest-presenter-api-key' => config('rest-presenter.auth.key'),
'x-rest-presenter' => '{{ modelClassName }}'
],
)->assertOk()->json();

expect($response)
Expand All @@ -29,7 +32,10 @@ describe('{{ modelClassName }}', function (): void {
test('can list all {{ $modelVarPlural }}', function (): void {
$response = getJson(
uri: route('api.v1.filament.{{ $modelVarPlural }}.index'),
headers: ['x-rest-presenter' => '{{ modelClassName }}'],
headers: [
'x-rest-presenter-api-key' => config('rest-presenter.auth.key'),
'x-rest-presenter' => '{{ modelClassName }}'
],
)->assertOk()->json();

expect($response)
Expand Down
10 changes: 8 additions & 2 deletions src/Commands/Generator/stubs/tests/resource.test.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ class {{ testClassName }} extends TestCase
$response = $this->json(
method: 'GET',
uri: route('api.v1.filament.{{ $modelVarPlural }}.show', ${{ $modelVarSingular }}->id),
headers: ['x-rest-presenter' => '{{ modelClassName }}']
headers: [
'x-rest-presenter-api-key' => config('rest-presenter.auth.key'),
'x-rest-presenter' => '{{ modelClassName }}'
],
);

$response->assertStatus(200);
Expand All @@ -58,7 +61,10 @@ class {{ testClassName }} extends TestCase
$response = $this->json(
method: 'GET',
uri: route('api.v1.filament.{{ $modelVarPlural }}.index'),
headers: ['x-rest-presenter' => '{{ modelClassName }}']
headers: [
'x-rest-presenter-api-key' => config('rest-presenter.auth.key'),
'x-rest-presenter' => '{{ modelClassName }}'
],
);

$response->assertStatus(200);
Expand Down

0 comments on commit 79de5b1

Please sign in to comment.