/** * Method to test getUri(). * * @return void * * @covers Windwalker\Http\AbstractRequest::getUri * @covers Windwalker\Http\AbstractRequest::withUri */ public function testWithAndGetUri() { $this->assertInstanceOf('Windwalker\\Uri\\PsrUri', $this->instance->getUri()); $this->assertEquals('', (string) $this->instance->getUri()); $request = $this->instance->withUri(new PsrUri('http://example.com/flower/sakura?foo=bar#baz'), true); $this->assertNotSame($request, $this->instance); $this->assertEquals('http://example.com/flower/sakura?foo=bar#baz', (string) $request->getUri()); $this->assertEquals(array(), $request->getHeader('host')); $request = $this->instance->withUri(new PsrUri('http://windwalker.io/flower/sakura?foo=bar#baz')); $this->assertEquals('http://windwalker.io/flower/sakura?foo=bar#baz', (string) $request->getUri()); $this->assertEquals(array('windwalker.io'), $request->getHeader('host')); }
/** * Class init * * @param array $serverParams Server parameters, typically from $_SERVER * @param array $uploadedFiles Upload file information, a tree of UploadedFiles * @param string $uri URI for the request, if any. * @param string $method HTTP method for the request, if any. * @param string|resource|StreamInterface $body Message body, if any. * @param array $headers Headers for the message, if any. * * @throws \InvalidArgumentException */ public function __construct(array $serverParams = array(), array $uploadedFiles = array(), $uri = null, $method = null, $body = 'php://input', array $headers = array()) { if (!ServerHelper::validateUploadedFiles($uploadedFiles)) { throw new \InvalidArgumentException('Invalid uploaded files, every file should be an UploadedInterface'); } if ($body == 'php://input') { $body = new PhpInputStream(); } $this->serverParams = $serverParams; $this->uploadedFiles = $uploadedFiles; parent::__construct($uri, $method, $body, $headers); }