1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00

Clean up code

This commit is contained in:
kodumbeats 2021-08-27 19:45:18 -04:00
parent ed70582945
commit c3534b4383
2 changed files with 5 additions and 19 deletions

View file

@ -846,7 +846,6 @@ App::get('/v1/database/collections/:collectionId/attributes/:attributeId')
// Select response model based on type and format
$type = $attribute->getAttribute('type');
$format = $attribute->getAttribute('format');
$formatOptions = $attribute->getAttribute('formatOptions');
$model = match($type) {
Database::VAR_BOOLEAN => Response::MODEL_ATTRIBUTE_BOOLEAN,
@ -861,14 +860,6 @@ App::get('/v1/database/collections/:collectionId/attributes/:attributeId')
default => Response::MODEL_ATTRIBUTE,
};
// Format response
// TODO@kodumbeats test if this is necessary with range filter
if ($model === Response::MODEL_ATTRIBUTE_INTEGER || $model === Response::MODEL_ATTRIBUTE_FLOAT)
{
$attribute->setAttribute('min', $formatOptions['min']);
$attribute->setAttribute('max', $formatOptions['max']);
}
$response->dynamic($attribute, $model);
});

View file

@ -100,11 +100,10 @@ trait DatabaseBase
return $data;
}
// /**
// * @depends testCreateAttributes
// */
// public function testAttributeResponseModels(array $data): array
public function testAttributeResponseModels()
/**
* @depends testCreateAttributes
*/
public function testAttributeResponseModels(array $data): array
{
$collection= $this->client->call(Client::METHOD_POST, '/database/collections', array_merge([
'content-type' => 'application/json',
@ -448,8 +447,6 @@ trait DatabaseBase
'x-appwrite-key' => $this->getProject()['apiKey']
]));
// var_dump($collection);
$this->assertEquals(200, $collection['headers']['status-code']);
$attributes = $collection['body']['attributes'];
@ -457,8 +454,6 @@ trait DatabaseBase
$this->assertIsArray($attributes);
$this->assertCount(7, $attributes);
var_dump($attributes);
$this->assertEquals($stringResponse['body']['key'], $attributes[0]['key']);
$this->assertEquals($stringResponse['body']['type'], $attributes[0]['type']);
$this->assertEquals($stringResponse['body']['status'], $attributes[0]['status']);
@ -516,7 +511,7 @@ trait DatabaseBase
$this->assertEquals($booleanResponse['body']['array'], $attributes[6]['array']);
$this->assertEquals($booleanResponse['body']['default'], $attributes[6]['default']);
// return $data;
return $data;
}
/**