strtoupper($method), 'REQUEST_URI' => $uri, ]; return $creator->fromArrays($server, $headers, [], [], []); } public function testDefaultRestWhenNoAccept(): void { putenv('API_FORMAT'); // unset to use default $kernel = $this->kernel(); $req = $this->request('GET', '/_phred/format'); $res = $kernel->handle($req); $this->assertSame(200, $res->getStatusCode()); $this->assertStringStartsWith('application/json', $res->getHeaderLine('Content-Type')); $data = json_decode((string) $res->getBody(), true); $this->assertIsArray($data); $this->assertSame('rest', $data['format'] ?? null); } public function testJsonApiWhenAcceptHeaderPresent(): void { putenv('API_FORMAT'); // unset $kernel = $this->kernel(); $req = $this->request('GET', '/_phred/format', ['Accept' => 'application/vnd.api+json']); $res = $kernel->handle($req); $this->assertSame(200, $res->getStatusCode()); $this->assertSame('application/vnd.api+json', $res->getHeaderLine('Content-Type')); $doc = json_decode((string) $res->getBody(), true); $this->assertIsArray($doc); $this->assertArrayHasKey('data', $doc); $this->assertSame('jsonapi', $doc['data']['format'] ?? null); } public function testEnvDefaultJsonApiWithoutAccept(): void { putenv('API_FORMAT=jsonapi'); $kernel = $this->kernel(); $req = $this->request('GET', '/_phred/format'); $res = $kernel->handle($req); $this->assertSame(200, $res->getStatusCode()); $this->assertSame('application/vnd.api+json', $res->getHeaderLine('Content-Type')); $doc = json_decode((string) $res->getBody(), true); $this->assertIsArray($doc); $this->assertArrayHasKey('data', $doc); $this->assertSame('jsonapi', $doc['data']['format'] ?? null); } }