/**
  * @issue https://github.com/guzzle/guzzle/issues/867
  */
 public function testDoesNotFailInEventSystemForNetworkError()
 {
     $c = new Client();
     $r = $c->createRequest('GET', Server::$url, ['timeout' => 1, 'connect_timeout' => 1, 'proxy' => 'http://127.0.0.1:123/foo']);
     $events = [];
     $fn = function (AbstractTransferEvent $event) use(&$events) {
         $events[] = [get_class($event), $event->hasResponse(), $event->getResponse()];
     };
     $pool = new Pool($c, [$r], ['error' => $fn, 'end' => $fn]);
     $pool->wait();
     $this->assertCount(2, $events);
     $this->assertEquals('GuzzleHttp5Legacy\\Event\\ErrorEvent', $events[0][0]);
     $this->assertFalse($events[0][1]);
     $this->assertNull($events[0][2]);
     $this->assertEquals('GuzzleHttp5Legacy\\Event\\EndEvent', $events[1][0]);
     $this->assertFalse($events[1][1]);
     $this->assertNull($events[1][2]);
 }
Esempio n. 2
0
 public function testDoesNotInfinitelyRecurse()
 {
     $client = new Client(['handler' => function () {
         throw new \RuntimeException('No network access');
     }]);
     $last = null;
     $client->getEmitter()->on('before', function (BeforeEvent $e) use(&$last) {
         $e->intercept(new Response(200));
         if (function_exists('xdebug_get_stack_depth')) {
             if ($last) {
                 $this->assertEquals($last, xdebug_get_stack_depth());
             } else {
                 $last = xdebug_get_stack_depth();
             }
         }
     });
     $requests = [];
     for ($i = 0; $i < 100; $i++) {
         $requests[] = $client->createRequest('GET', 'http://foo.com');
     }
     $pool = new Pool($client, $requests);
     $pool->wait();
 }