Example #1
0
 it('assigns method from REQUEST_METHOD', function () {
     expect((new ServerRequest(['REQUEST_METHOD' => 'HEAD']))->getMethod())->toBe('HEAD');
 });
 it('assigns uri from REQUEST_URI', function () {
     $req = new ServerRequest(['REQUEST_URI' => 'http://*****:*****@example.com/path']);
     expect($req->getTarget())->toBe('/path');
     expect($req->getHeaders()['HOST'])->toBe(['example.com']);
 });
 it('assigns query as query parameters', function () {
     $req = new ServerRequest(NULL, ['foo' => 'bar']);
     expect($req->getQuery())->toBeA('array')->toContainKey('foo');
     expect($req->getQuery()['foo'])->toBe('bar');
 });
 it('assigns query from query string', function () {
     $req = new ServerRequest(['REQUEST_URI' => '/path?foo=bar'], []);
     expect($req->getQuery())->toBeA('array')->toContainKey('foo');
     expect($req->getQuery()['foo'])->toBe('bar');
 });
 it('assigns xargs as form parameters', function () {
     $req = new ServerRequest(NULL, NULL, ['foo' => 'bar']);
     expect($req->getParsedBody())->toBeA('array')->toContainKey('foo');
     expect($req->getParsedBody()['foo'])->toBe('bar');
 });
 it('assigns content headers from server', function () {
     $req = new ServerRequest(['CONTENT_TYPE' => 'text/plain', 'CONTENT_LENGTH' => 0]);
     expect($req->getHeaders())->toBeA('array')->toContainKey('CONTENT-TYPE')->toContainKey('CONTENT-LENGTH');
     expect($req->getHeaders()['CONTENT-TYPE'])->toBe(['text/plain']);
     expect($req->getHeaders()['CONTENT-LENGTH'])->toBe([0]);
 });
 it('throws UnexpectedValueException with invalid uploaded file', function () {
     expect(function () {