/** * @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()); }
public function testRewindDetachedThrowsRuntimeException() { $this->body->detach(); $this->setExpectedException('\\RuntimeException'); $this->body->rewind(); }