public function testExceptionUnexpectedResponseError() { $message = uniqid(); $method = uniqid(); $uri = uniqid(); $response = uniqid(); $e = Exception::unexpectedResponseError($message, $method, $uri, $response); $json = json_decode($e->getMessage(), true); $this->assertArrayHasKey('description', $json); $this->assertEquals($message, $json['description']); $this->assertArrayHasKey('method', $json); $this->assertEquals($method, $json['method']); $this->assertArrayHasKey('uri', $json); $this->assertEquals($uri, $json['uri']); $this->assertArrayHasKey('response', $json); $this->assertEquals($response, $json['response']); $this->assertEquals(400, $e->getCode()); }
public function pollMaqlTask($uri) { $try = 1; do { sleep(10 * $try); $result = $this->get($uri); if (!isset($result['wTaskStatus']['status'])) { throw Exception::unexpectedResponseError('Task polling failed', 'GET', $uri, $result); } $try++; } while (in_array($result['wTaskStatus']['status'], ['PREPARED', 'RUNNING'])); if ($result['wTaskStatus']['status'] == 'ERROR') { throw Exception::error($uri, $result); } }