Merge remote-tracking branch 'origin/test-update-attributes' into feat-relations-2

# Conflicts:
#	app/controllers/api/databases.php
This commit is contained in:
Jake Barnby 2023-04-03 16:10:09 +12:00
commit 6664377fb8
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -1426,6 +1426,17 @@ class DatabasesCustomServerTest extends Scope
$this->assertFalse($new['body']['required']);
$this->assertEquals('lorem', $new['body']['default']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals('lorem', $attribute['default']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/string/' . $key, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -1557,6 +1568,17 @@ class DatabasesCustomServerTest extends Scope
$this->assertFalse($new['body']['required']);
$this->assertEquals('torsten@appwrite.io', $new['body']['default']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals('torsten@appwrite.io', $attribute['default']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/email/' . $key, array_merge([
'content-type' => 'application/json',
@ -1689,6 +1711,17 @@ class DatabasesCustomServerTest extends Scope
$this->assertFalse($new['body']['required']);
$this->assertEquals('127.0.0.1', $new['body']['default']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals('127.0.0.1', $attribute['default']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/ip/' . $key, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -1820,6 +1853,17 @@ class DatabasesCustomServerTest extends Scope
$this->assertFalse($new['body']['required']);
$this->assertEquals('http://appwrite.io', $new['body']['default']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals('http://appwrite.io', $attribute['default']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/url/' . $key, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -1955,6 +1999,19 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals(0, $new['body']['min']);
$this->assertEquals(1000, $new['body']['max']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals(123, $attribute['default']);
$this->assertEquals(0, $attribute['min']);
$this->assertEquals(1000, $attribute['max']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/integer/' . $key, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -2205,6 +2262,19 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals(0, $new['body']['min']);
$this->assertEquals(1000, $new['body']['max']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals(123.456, $attribute['default']);
$this->assertEquals(0, $attribute['min']);
$this->assertEquals(1000, $attribute['max']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/float/' . $key, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -2451,6 +2521,17 @@ class DatabasesCustomServerTest extends Scope
$this->assertFalse($new['body']['required']);
$this->assertEquals(true, $new['body']['default']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals(true, $attribute['default']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/boolean/' . $key, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -2582,6 +2663,17 @@ class DatabasesCustomServerTest extends Scope
$this->assertFalse($new['body']['required']);
$this->assertEquals('1975-06-12 14:12:55+02:00', $new['body']['default']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals('1975-06-12 14:12:55+02:00', $attribute['default']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/datetime/' . $key, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
@ -2718,6 +2810,21 @@ class DatabasesCustomServerTest extends Scope
$this->assertContains('ipsum', $new['body']['elements']);
$this->assertContains('dolor', $new['body']['elements']);
$new = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]));
$attribute = array_values(array_filter($new['body']['attributes'], fn (array $a) => $a['key'] === $key))[0] ?? null;
$this->assertNotNull($attribute);
$this->assertFalse($attribute['required']);
$this->assertEquals('lorem', $attribute['default']);
$this->assertCount(3, $attribute['elements']);
$this->assertContains('lorem', $attribute['elements']);
$this->assertContains('ipsum', $attribute['elements']);
$this->assertContains('dolor', $attribute['elements']);
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/enum/' . $key, array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],