Пример #1
0
 /**
  * @dataProvider provideValidHttpMethod
  */
 public function testCreateRequestInstance($method)
 {
     $request = new Request(Request::GET, '/', Request::HTTP, '1.1', ['Host' => 'http://wikipedia.com', 'User-Agent' => 'Mozilla/Firefox']);
     $this->assertSame(Request::GET, $request->getMethod());
     $this->assertSame('/', $request->getPath());
     $this->assertSame(Request::HTTP, $request->getScheme());
     $this->assertSame('1.1', $request->getSchemeVersion());
     $this->assertCount(2, $request->getHeaders());
     $this->assertSame(['host' => 'http://wikipedia.com', 'user-agent' => 'Mozilla/Firefox'], $request->getHeaders());
     $this->assertSame('http://wikipedia.com', $request->getHeader('Host'));
     $this->assertSame('Mozilla/Firefox', $request->getHeader('User-Agent'));
     $this->assertEmpty($request->getBody());
 }
Пример #2
0
 /**
  * @dataProvider provideValidHttpMethod
  * @param $method
  * @param $path
  * @param $http
  */
 public function testCreateRequestInstance($method, $path, $http)
 {
     $request = new Request($method, $path, $http, "1.1", ["Host" => "http://www.google.com", "Content-Type" => "text/html", "Accept" => "application/json"]);
     $this->assertSame($method, $request->getMethod(), "Assert of request method");
     $this->assertSame($path, $request->getPath(), "Assert of path");
     $this->assertSame($http, $request->getScheme(), "Assert of scheme");
     $this->assertSame("1.1", $request->getSchemeVersion(), "Assert of scheme version");
     $this->assertCount(3, $request->getHeaders());
     $this->assertSame(["host" => "http://www.google.com", "content-type" => "text/html", "accept" => "application/json"], $request->getHeaders());
     $this->assertSame("http://www.google.com", $request->getHeader("Host"));
     $this->assertSame("application/json", $request->getHeader("Accept"));
     $this->assertSame("text/html", $request->getHeader("Content-Type"));
     $this->assertEmpty($request->getBody(), "Assert of body");
 }
Пример #3
0
 /**
  * @dataProvider provideRequestParameters
  */
 public function testCreateRequestInstance($method, $path)
 {
     $body = '{ "foo": "bar" }';
     $headers = ['Host' => 'http://wikipedia.com', 'User-Agent' => 'Mozilla/Firefox', 'Content-Type' => 'application/json'];
     $request = new Request($method, $path, Request::HTTP, '1.1', $headers, $body);
     $this->assertSame($method, $request->getMethod());
     $this->assertSame($path, $request->getPath());
     $this->assertSame(Request::HTTP, $request->getScheme());
     $this->assertSame('1.1', $request->getSchemeVersion());
     $this->assertSame($body, $request->getBody());
     $this->assertCount(3, $request->getHeaders());
     $this->assertSame(['host' => 'http://wikipedia.com', 'user-agent' => 'Mozilla/Firefox', 'content-type' => 'application/json'], $request->getHeaders());
     $this->assertSame('http://wikipedia.com', $request->getHeader('Host'));
     $this->assertSame('Mozilla/Firefox', $request->getHeader('User-Agent'));
     $this->assertSame('application/json', $request->getHeader('Content-Type'));
 }