public function testRetryDelay()
 {
     $middlewareFactory = new MiddlewareFactory();
     $mock = new MockHandler(array(new ConnectException("+1 second delay", new Request('GET', 'test')), new ConnectException("+2 second delay", new Request('GET', 'test')), new Response(200)));
     $handler = HandlerStack::create($mock);
     $handler->push($middlewareFactory->retry(true));
     $client = new Client(['handler' => $handler]);
     $startTime = time();
     $client->request('GET', '/')->getStatusCode();
     $endTime = time();
     $this->assertGreaterThan($startTime + 2, $endTime);
 }
 /**
  * @return Client
  */
 private function newClient()
 {
     $middlewareFactory = new MiddlewareFactory();
     $middlewareFactory->setLogger($this->logger);
     $handlerStack = HandlerStack::create(new CurlHandler());
     $handlerStack->push($middlewareFactory->retry());
     if (array_key_exists('user-agent', $this->config)) {
         $ua = $this->config['user-agent'];
     } else {
         $ua = 'Addwiki - mediawiki-api-base';
     }
     if (array_key_exists('middleware', $this->config)) {
         foreach ($this->config['middleware'] as $middleware) {
             $handlerStack->push($middleware);
         }
     }
     return new Client(array('cookies' => true, 'handler' => $handlerStack, 'headers' => array('User-Agent' => $ua)));
 }