1
0
Fork 0
mirror of synced 2024-06-28 19:20:25 +12:00

Make param errors consistent

This commit is contained in:
Jake Barnby 2022-10-14 13:18:08 +13:00
parent 64ad2211c7
commit 44e4f1e05b
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
3 changed files with 9 additions and 9 deletions

View file

@ -551,7 +551,7 @@ return [
],
Exception::GRAPHQL_NO_QUERY => [
'name' => Exception::GRAPHQL_NO_QUERY,
'description' => 'No query passed in the request.',
'description' => 'Param "query" is not optional.',
'code' => 400,
],
Exception::GRAPHQL_INVALID_QUERY => [

View file

@ -104,7 +104,7 @@ function executeRequest(
}
foreach ($query as $item) {
if (empty($item['query'])) {
throw new Exception(Exception::GRAPHQL_INVALID_QUERY);
throw new Exception(Exception::GRAPHQL_NO_QUERY);
}
}

View file

@ -162,7 +162,7 @@ class ContentTypeTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()));
$this->assertEquals('No query passed in the request.', $response['body']['message']);
$this->assertEquals('Param "query" is not optional.', $response['body']['message']);
}
public function testPostEmptyBody()
@ -173,7 +173,7 @@ class ContentTypeTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), []);
$this->assertEquals('No query passed in the request.', $response['body']['message']);
$this->assertEquals('Param "query" is not optional.', $response['body']['message']);
}
public function testPostRandomBody()
@ -184,7 +184,7 @@ class ContentTypeTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), ['foo' => 'bar']);
$this->assertEquals('Invalid query.', $response['body']['message']);
$this->assertEquals('Param "query" is not optional.', $response['body']['message']);
}
public function testGetNoQuery()
@ -195,7 +195,7 @@ class ContentTypeTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()));
$this->assertEquals('No query passed in the request.', $response['body']['message']);
$this->assertEquals('Param "query" is not optional.', $response['body']['message']);
}
public function testGetEmptyQuery()
@ -206,17 +206,17 @@ class ContentTypeTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()));
$this->assertEquals('Invalid query.', $response['body']['message']);
$this->assertEquals('Param "query" is not optional.', $response['body']['message']);
}
public function testGetRandomParameters()
{
$projectId = $this->getProject()['$id'];
$response = $this->client->call(Client::METHOD_POST, '/graphql?random=random', \array_merge([
$response = $this->client->call(Client::METHOD_GET, '/graphql?random=random', \array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()));
$this->assertEquals('No query passed in the request.', $response['body']['message']);
$this->assertEquals('Param "query" is not optional.', $response['body']['message']);
}
}