/** * @param string $captchaId * @return false|DeathByCaptchaCaptchaSolution */ private function pullSolutionFor($captchaId) { $maxAttempts = $this->pullPreferences->getMaxAttempts(); while ($maxAttempts--) { /* @var Response $response */ $response = $this->httpClient->get('/api/captcha/' . $captchaId, ['query' => ['username' => $this->credentials->getUsername(), 'password' => $this->credentials->getPassword()]]); $json = $response->json(); if (!empty($json['text'])) { return new DeathByCaptchaCaptchaSolution($json['text'], $captchaId); } sleep($this->pullPreferences->getInterval()); } return false; }
/** * @test */ public function getInterval() { $this->assertEquals(5, $this->preferences->getInterval()); }