1
0
Fork 0
mirror of synced 2024-07-06 23:21:05 +12:00

Add datetime attribute test

This commit is contained in:
Jake Barnby 2022-09-21 21:08:20 +12:00
parent 4d21323001
commit 390453aa9b
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 46 additions and 4 deletions

View file

@ -25,6 +25,7 @@ trait GraphQLBase
public static string $CREATE_EMAIL_ATTRIBUTE = 'create_email_attribute';
public static string $CREATE_IP_ATTRIBUTE = 'create_ip_attribute';
public static string $CREATE_ENUM_ATTRIBUTE = 'create_enum_attribute';
public static string $CREATE_DATETIME_ATTRIBUTE = 'create_datetime_attribute';
public static string $GET_ATTRIBUTES = 'get_attributes';
public static string $GET_ATTRIBUTE = 'get_attribute';
public static string $DELETE_ATTRIBUTE = 'delete_attribute';
@ -334,6 +335,15 @@ trait GraphQLBase
array
}
}';
case self::$CREATE_DATETIME_ATTRIBUTE:
return 'mutation createDatetimeAttribute($databaseId: String!, $collectionId: String!, $key: String!, $required: Boolean!, $default: String, $array: Boolean){
databasesCreateDatetimeAttribute(databaseId: $databaseId, collectionId: $collectionId, key: $key, required: $required, default: $default, array: $array) {
key
required
default
array
}
}';
case self::$CREATE_INDEX:
return 'mutation createIndex($databaseId: String!, $collectionId: String!, $key: String!, $type: String!, $attributes: [String!]!, $orders: [String!]){
databasesCreateIndex(databaseId: $databaseId, collectionId: $collectionId, key: $key, type: $type, attributes: $attributes, orders: $orders) {
@ -421,8 +431,8 @@ trait GraphQLBase
}
}';
case self::$CREATE_CUSTOM_ENTITY:
return 'mutation createActor($name: String!, $age: Int!, $alive: Boolean!, $salary: Float, $email: String!, $role: String!, $ip: String, $url: String){
actorsCreate(name: $name, age: $age, alive: $alive, salary: $salary, email: $email, role: $role, ip: $ip, url: $url) {
return 'mutation createActor($name: String!, $age: Int!, $alive: Boolean!, $salary: Float, $email: String!, $role: String!, $dob: String!, $ip: String, $url: String){
actorsCreate(name: $name, age: $age, alive: $alive, salary: $salary, email: $email, role: $role, dob: $dob, ip: $ip, url: $url) {
_id
name
age
@ -464,8 +474,8 @@ trait GraphQLBase
}
}';
case self::$UPDATE_CUSTOM_ENTITY:
return 'mutation updateCustomEntity($id: String!, $name: String!, $age: Int!, $alive: Boolean!, $salary: Float, $email: String!, $role: String!, $ip: String, $url: String){
actorsUpdate(id: $id, name: $name, age: $age, alive: $alive, salary: $salary, email: $email, role: $role, ip: $ip, url: $url) {
return 'mutation updateCustomEntity($id: String!, $name: String, $age: Int, $alive: Boolean, $salary: Float, $email: String, $role: String, $dob: String, $ip: String, $url: String){
actorsUpdate(id: $id, name: $name, age: $age, alive: $alive, salary: $salary, email: $email, role: $role, dob: $dob, ip: $ip, url: $url) {
name
age
alive

View file

@ -271,6 +271,36 @@ class GraphQLDatabaseServerTest extends Scope
return $data;
}
/**
* @depends testCreateCollection
* @throws Exception
*/
public function testCreateDatetimeAttribute($data): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$CREATE_DATETIME_ATTRIBUTE);
$gqlPayload = [
'query' => $query,
'variables' => [
'databaseId' => $data['database']['_id'],
'collectionId' => $data['collection']['_id'],
'key' => 'dob',
'required' => true,
]
];
$attribute = $this->client->call(Client::METHOD_POST, '/graphql', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
$this->assertArrayNotHasKey('errors', $attribute['body']);
$this->assertIsArray($attribute['body']['data']);
$this->assertIsArray($attribute['body']['data']['databasesCreateDatetimeAttribute']);
return $data;
}
/**
* @depends testCreateCollection
* @throws Exception
@ -399,6 +429,7 @@ class GraphQLDatabaseServerTest extends Scope
'alive' => true,
'salary' => 9999.9,
'role' => 'crew',
'dob' => '2000-01-01T00:00:00Z',
],
'permissions' => [
Permission::read(Role::any()),
@ -448,6 +479,7 @@ class GraphQLDatabaseServerTest extends Scope
'salary' => 9999.9,
'email' => 'johndoe@appwrite.io',
'role' => 'crew',
'dob' => '2000-01-01T00:00:00Z',
]
];