Пример #1
0
 /**
  * @param $input
  * @return Body
  */
 protected function buildBody($input)
 {
     $getContent = function () use($input) {
         if (is_array($input)) {
             return http_build_query($input);
         }
         return $input;
     };
     $content = $getContent();
     $body = new RequestBody();
     $body->write($content);
     $body->rewind();
     return $body;
 }
 public function testGetParametersWithBodyPriority()
 {
     $body = new RequestBody();
     $body->write('foo=bar&abc=xyz');
     $body->rewind();
     $request = $this->requestFactory()->withBody($body)->withHeader('Content-Type', 'application/x-www-form-urlencoded');
     $this->assertEquals(['abc' => 'xyz', 'foo' => 'bar'], $request->getParams());
 }
Пример #3
0
 public function testRewindDetachedThrowsRuntimeException()
 {
     $this->body->detach();
     $this->setExpectedException('\\RuntimeException');
     $this->body->rewind();
 }