Esempio n. 1
0
 public function onError(puzzle_event_ErrorEvent $event)
 {
     // Only track when no response is present, meaning this didn't ever
     // emit a complete event
     if (!$event->getResponse()) {
         $this->add($event->getRequest());
     }
 }
Esempio n. 2
0
 public function testInterceptsWithEvent()
 {
     $client = new puzzle_Client();
     $request = new puzzle_message_Request('GET', '/');
     $response = new puzzle_message_Response(404);
     $transaction = new puzzle_adapter_Transaction($client, $request);
     $except = new puzzle_exception_RequestException('foo', $request, $response);
     $event = new puzzle_event_ErrorEvent($transaction, $except);
     $event->throwImmediately(true);
     $this->assertTrue($except->getThrowImmediately());
     $event->throwImmediately(false);
     $this->assertFalse($except->getThrowImmediately());
     $this->assertSame($except, $event->getException());
     $this->assertSame($response, $event->getResponse());
     $this->assertSame($request, $event->getRequest());
     $this->_closure_testInterceptsWithEvent_res = null;
     $request->getEmitter()->on('complete', array($this, '__callback_testInterceptsWithEvent'));
     $good = new puzzle_message_Response(200);
     $event->intercept($good);
     $this->assertTrue($event->isPropagationStopped());
     $this->assertSame($this->_closure_testInterceptsWithEvent_res->getClient(), $event->getClient());
     $this->assertSame($good, $this->_closure_testInterceptsWithEvent_res->getResponse());
 }