|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use ApiPlatform\Laravel\Test\ApiTestAssertionsTrait; |
| 6 | +use Illuminate\Contracts\Config\Repository; |
| 7 | +use Illuminate\Foundation\Application; |
| 8 | +use Illuminate\Foundation\Testing\RefreshDatabase; |
| 9 | +use Orchestra\Testbench\Concerns\WithWorkbench; |
| 10 | +use Orchestra\Testbench\TestCase; |
| 11 | +use Workbench\Database\Factories\AuthorFactory; |
| 12 | +use Workbench\Database\Factories\BookFactory; |
| 13 | + |
| 14 | +class HeaderLinkTest extends TestCase |
| 15 | +{ |
| 16 | + use ApiTestAssertionsTrait; |
| 17 | + use RefreshDatabase; |
| 18 | + use WithWorkbench; |
| 19 | + |
| 20 | + /** |
| 21 | + * @param Application $app |
| 22 | + */ |
| 23 | + protected function defineEnvironment($app): void |
| 24 | + { |
| 25 | + tap($app['config'], function (Repository $config): void { |
| 26 | + $config->set('app.debug', true); |
| 27 | + $config->set('api-platform.formats', ['jsonapi' => ['application/vnd.api+json']]); |
| 28 | + $config->set('api-platform.docs_formats', ['jsonapi' => ['application/vnd.api+json']]); |
| 29 | + }); |
| 30 | + } |
| 31 | + |
| 32 | + public function testHeaderLinkDoesNotExistWithoutJsonld(): void { |
| 33 | + BookFactory::new()->has(AuthorFactory::new())->count(10)->create(); |
| 34 | + $response = $this->get('/api/books', ['accept' => 'application/vnd.api+json']); |
| 35 | + $response->assertStatus(200); |
| 36 | + $response->assertHeaderMissing('link'); |
| 37 | + //$response->assertHeader('link', '<http://localhost/api/docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"'); |
| 38 | + } |
| 39 | +} |
0 commit comments