public function testItErrorsWhenIncorrectStatusCodeIsFound() { try { Response::createFromString("010 server ready - posting allowed\r\n"); $this->fail('::createFromString() throws a Rvdv\\Nntp\\Exception\\RuntimeException because status code is less than 100'); } catch (\Exception $e) { $this->assertInstanceof('Rvdv\\Nntp\\Exception\\RuntimeException', $e, '::createFromString() throws a Rvdv\\Nntp\\Exception\\RuntimeException because status code is less than 100'); } try { Response::createFromString("700 server ready - posting allowed\r\n"); $this->fail('::createFromString() throws a Rvdv\\Nntp\\Exception\\RuntimeException because status code is greater than 600'); } catch (\Exception $e) { $this->assertInstanceof('Rvdv\\Nntp\\Exception\\RuntimeException', $e, '::createFromString() throws a Rvdv\\Nntp\\Exception\\RuntimeException because status code is greater than 600'); } }
public function testItReturnsInjectedResponseAsString() { $response = Response::createFromString("200 server ready - posting allowed\r\n"); $multiLineResponse = new MultiLineResponse($response, new \SplFixedArray()); $this->assertEquals('server ready - posting allowed [200]', (string) $multiLineResponse); }
public function onPostingNotPermitted(Response $response) { throw new RuntimeException('Posting not permitted.', $response->getStatusCode()); }
public function onPostingFailed(Response $response) { throw new RuntimeException(sprintf('Posting failed: %s', $response->getMessage()), $response->getStatusCode()); }
public function onNoSuchArticleId(Response $response) { throw new RuntimeException('No article with that message-id.', $response->getStatusCode()); }
protected function getResponse() { $buffer = ''; while (!$this->socket->eof()) { $buffer .= $this->socket->gets(self::BUFFER_SIZE); if ("\r\n" === substr($buffer, -2)) { break; } if ($buffer === false) { $this->disconnect(); throw new RuntimeException('Incorrect data received from buffer'); } } return Response::createFromString($buffer); }
public function onGroupSelected(Response $response) { $message = $response->getMessage(); $this->result = array_combine(['count', 'first', 'last', 'name'], explode(' ', $message)); }
/** * Return the message's reference. * * @param Response $response */ public function onFoundPath(Response $response) { $this->result = $response->getMessage(); }
public function onError(Response $response) { throw new RuntimeException('Error retrieving group list', $response->getStatusCode()); }