expect(function () { new Response(200, ['Host' => new stdClass()]); })->toThrow(new InvalidArgumentException()); }); it('assigns headers defaults', function () { expect((new Response(200, []))->getHeaders())->toBe(['CACHE-CONTROL' => ['no-store', 'no-cache', 'must-revalidate', 'post-check=0', 'pre-check=0'], 'CONTENT-TYPE' => ['text/html; charset=utf-8']]); }); it('assigns headers, defaults can be overriden', function () { expect((new Response(200, ['Cache-Control' => 'no-cache']))->getHeaders())->toBe(['CACHE-CONTROL' => ['no-cache'], 'CONTENT-TYPE' => ['text/html; charset=utf-8']]); }); it('assigns headers as array if scalar value given', function () { expect((new Response(200, ['Host' => 'example.com']))->getHeaders()['HOST'])->toBe(['example.com']); }); it('removes content for empty responses status codes', function () { $req = new Response(204, ['Content-Type' => 'text/plain'], 'Hello World'); expect($req->getHeaders())->not->toContainKey('CONTENT-TYPE'); expect($req->getBody())->toBeNull(); }); it('assigns content type, defaults to text/html', function () { expect((new Response(200, []))->getHeaders()['CONTENT-TYPE'])->toBe(['text/html; charset=utf-8']); }); it('assigns content type charset, defaults to utf-8', function () { expect((new Response(200, ['Content-Type' => 'text/html']))->getHeaders()['CONTENT-TYPE'])->toBe(['text/html; charset=utf-8']); }); it('throws InvalidArgumentException on invalid body', function () { expect(function () { new Response(200, [], []); })->toThrow(new InvalidArgumentException()); }); }); describe('->prepare', function () {