/** * @covers ::getType */ public function testInstanceKeepsType() { $header = $this->prophesize('\\Crunch\\FastCGI\\Protocol\\Header'); $header->getLength()->willReturn(3); $header->getType()->shouldBeCalled(); $record = new Record($header->reveal(), 'foo'); $record->getType(); }
/** * @param Record $record * * @return Response|null * @throws \RuntimeException */ public function pushRecord(Record $record) { switch (true) { case $record->getType()->isStdout(): $this->stdout .= $record->getContent(); break; case $record->getType()->isStderr(): $this->stderr .= $record->getContent(); break; case $record->getType()->isEndRequest(): return new Response($this->requestId, new StringReader($this->stdout), new StringReader($this->stderr)); break; default: throw new \RuntimeException(sprintf('Unknown package type \'%d\'', $record->getType())); break; } }
/** * @param Record $record * * @return RequestInterface|null */ public function pushRecord(Record $record) { $this->records[] = $record; if (!$record->getType()->isStdin() || $record->getContent()) { return; } return $this->buildRequest(); }