Add datetime attribute test
This commit is contained in:
parent
4d21323001
commit
390453aa9b
2 changed files with 46 additions and 4 deletions
|
@ -25,6 +25,7 @@ trait GraphQLBase
|
||||||
public static string $CREATE_EMAIL_ATTRIBUTE = 'create_email_attribute';
|
public static string $CREATE_EMAIL_ATTRIBUTE = 'create_email_attribute';
|
||||||
public static string $CREATE_IP_ATTRIBUTE = 'create_ip_attribute';
|
public static string $CREATE_IP_ATTRIBUTE = 'create_ip_attribute';
|
||||||
public static string $CREATE_ENUM_ATTRIBUTE = 'create_enum_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_ATTRIBUTES = 'get_attributes';
|
||||||
public static string $GET_ATTRIBUTE = 'get_attribute';
|
public static string $GET_ATTRIBUTE = 'get_attribute';
|
||||||
public static string $DELETE_ATTRIBUTE = 'delete_attribute';
|
public static string $DELETE_ATTRIBUTE = 'delete_attribute';
|
||||||
|
@ -334,6 +335,15 @@ trait GraphQLBase
|
||||||
array
|
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:
|
case self::$CREATE_INDEX:
|
||||||
return 'mutation createIndex($databaseId: String!, $collectionId: String!, $key: String!, $type: String!, $attributes: [String!]!, $orders: [String!]){
|
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) {
|
databasesCreateIndex(databaseId: $databaseId, collectionId: $collectionId, key: $key, type: $type, attributes: $attributes, orders: $orders) {
|
||||||
|
@ -421,8 +431,8 @@ trait GraphQLBase
|
||||||
}
|
}
|
||||||
}';
|
}';
|
||||||
case self::$CREATE_CUSTOM_ENTITY:
|
case self::$CREATE_CUSTOM_ENTITY:
|
||||||
return 'mutation createActor($name: String!, $age: Int!, $alive: Boolean!, $salary: Float, $email: String!, $role: String!, $ip: String, $url: String){
|
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, ip: $ip, url: $url) {
|
actorsCreate(name: $name, age: $age, alive: $alive, salary: $salary, email: $email, role: $role, dob: $dob, ip: $ip, url: $url) {
|
||||||
_id
|
_id
|
||||||
name
|
name
|
||||||
age
|
age
|
||||||
|
@ -464,8 +474,8 @@ trait GraphQLBase
|
||||||
}
|
}
|
||||||
}';
|
}';
|
||||||
case self::$UPDATE_CUSTOM_ENTITY:
|
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){
|
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, ip: $ip, url: $url) {
|
actorsUpdate(id: $id, name: $name, age: $age, alive: $alive, salary: $salary, email: $email, role: $role, dob: $dob, ip: $ip, url: $url) {
|
||||||
name
|
name
|
||||||
age
|
age
|
||||||
alive
|
alive
|
||||||
|
|
|
@ -271,6 +271,36 @@ class GraphQLDatabaseServerTest extends Scope
|
||||||
return $data;
|
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
|
* @depends testCreateCollection
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -399,6 +429,7 @@ class GraphQLDatabaseServerTest extends Scope
|
||||||
'alive' => true,
|
'alive' => true,
|
||||||
'salary' => 9999.9,
|
'salary' => 9999.9,
|
||||||
'role' => 'crew',
|
'role' => 'crew',
|
||||||
|
'dob' => '2000-01-01T00:00:00Z',
|
||||||
],
|
],
|
||||||
'permissions' => [
|
'permissions' => [
|
||||||
Permission::read(Role::any()),
|
Permission::read(Role::any()),
|
||||||
|
@ -448,6 +479,7 @@ class GraphQLDatabaseServerTest extends Scope
|
||||||
'salary' => 9999.9,
|
'salary' => 9999.9,
|
||||||
'email' => 'johndoe@appwrite.io',
|
'email' => 'johndoe@appwrite.io',
|
||||||
'role' => 'crew',
|
'role' => 'crew',
|
||||||
|
'dob' => '2000-01-01T00:00:00Z',
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue