public function testHasThrowState() { $e = puzzle_exception_RequestException::create(new puzzle_message_Request('GET', '/'), new puzzle_message_Response(442)); $this->assertFalse($e->getThrowImmediately()); $e->setThrowImmediately(true); $this->assertTrue($e->getThrowImmediately()); }
/** * Throw a puzzle_exception_RequestException on an HTTP protocol error * * @param puzzle_event_CompleteEvent $event Emitted event * @throws puzzle_exception_RequestException */ public function onComplete(puzzle_event_CompleteEvent $event) { $code = (string) $event->getResponse()->getStatusCode(); // Throw an exception for an unsuccessful response if ($code[0] === '4' || $code[0] === '5') { throw puzzle_exception_RequestException::create($event->getRequest(), $event->getResponse()); } }
public function onSetup() { $this->_mockPuzzleRequest = $this->mock('puzzle_message_RequestInterface'); $this->_mockPuzzleResponse = $this->mock('puzzle_message_ResponseInterface'); $this->_mockPuzzleResponse->shouldReceive('getStatusCode')->times(3)->andReturn(404); $this->_mockPuzzleResponse->shouldReceive('getReasonPhrase')->once()->andReturn('some reason!'); $this->_mockPuzzleResponse->shouldReceive('getEffectiveUrl')->once()->andReturn('http://bar.foo/z/y.php?test=true#frag'); $this->_mockPuzzleRequest->shouldReceive('getUrl')->twice()->andReturn('http://foo.bar/z/y.php?test=true#frag'); $this->_mockPuzzleException = puzzle_exception_RequestException::create($this->_mockPuzzleRequest, $this->_mockPuzzleResponse); $this->_sut = new tubepress_http_impl_puzzle_RequestException($this->_mockPuzzleException); }