mirror of
https://github.com/nextcloud/tables.git
synced 2025-08-18 08:19:08 +00:00
enh: rename migration
Signed-off-by: Cleopatra Enjeck M <patrathewhiz@gmail.com>
This commit is contained in:

committed by
Julius Härtl

parent
a320fc540e
commit
6968538fdf
@ -16,13 +16,13 @@ class RowCellUsergroupMapper extends RowCellMapperSuper {
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function parseValueIncoming(Column $column, $value): array {
|
||||
return json_decode(json_encode($value), true);
|
||||
return json_decode($value, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function parseValueOutgoing(Column $column, $value, ?int $value_type = null): array {
|
||||
return ['id' => $value, 'type' => $value_type];
|
||||
public function parseValueOutgoing(Column $column, $value, ?int $value_type = null): string {
|
||||
return json_encode(['id' => $value, 'type' => $value_type]);
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use OCP\DB\Types;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\SimpleMigrationStep;
|
||||
|
||||
class Version001000Date20240712000000 extends SimpleMigrationStep {
|
||||
class Version000800Date20240712000000 extends SimpleMigrationStep {
|
||||
/**
|
||||
* @param IOutput $output
|
||||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
|
@ -25,7 +25,7 @@ class UsergroupBusiness extends SuperBusiness implements IColumnTypeBusiness {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $value array{id: string, type: int}
|
||||
* @param string $value json encoded array{id: string, type: int}
|
||||
* @param Column|null $column
|
||||
* @return bool
|
||||
*/
|
||||
@ -39,7 +39,7 @@ class UsergroupBusiness extends SuperBusiness implements IColumnTypeBusiness {
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach ($value as $v) {
|
||||
foreach (json_decode($value, true) as $v) {
|
||||
if((array_key_exists('id', $v) && !is_string($v['id'])) && (array_key_exists('type', $v) && !is_int($v['type']))) {
|
||||
return false;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ Feature: APIv2
|
||||
| title | ug column renamed |
|
||||
| mandatory | 0 |
|
||||
| description | New description |
|
||||
| usergroupDefault | [{"id": "admin", "type": 0}] |
|
||||
| usergroupDefault | [{"id":"admin","type":0}] |
|
||||
Then table has at least following columns
|
||||
| ug column renamed |
|
||||
|
||||
@ -571,20 +571,20 @@ Feature: APIv2
|
||||
|
||||
@api1 @rows
|
||||
Scenario: Create and modify usergroup row via v1
|
||||
Given table "Usergroup row check" with emoji "👨🏻💻" exists for user "participant1" as "base1"
|
||||
Given table "Usergroup row check" with emoji "👋" exists for user "participant1-v2" as "base1" via v2
|
||||
Then column "one" exists with following properties
|
||||
| title | usergroup |
|
||||
| type | usergroup |
|
||||
| mandatory | 0 |
|
||||
| description | New description |
|
||||
| usergroupMultipleItems | true |
|
||||
| usergroupSelectUsers | true |
|
||||
| usergroupSelectGroups | true |
|
||||
Then row exists with following values
|
||||
| one | [{"id": "admin", "type": 0}] |
|
||||
| one | [{"id":"admin","type":0}] |
|
||||
Then set following values for last created row
|
||||
| one | [{"id": "admin", "type": 1}] |
|
||||
| one | [{"id":"admin","type":1}] |
|
||||
Then user deletes last created row
|
||||
Then user "participant1" deletes table with keyword "Usergroup row check"
|
||||
Then user "participant1-v2" deletes table with keyword "Usergroup row check"
|
||||
|
||||
@api2 @rows
|
||||
Scenario: Create rows via v2 and check them
|
||||
|
@ -413,6 +413,7 @@ class FeatureContext implements Context {
|
||||
|
||||
$newColumn = $this->getDataFromResponse($this->response)['ocs']['data'];
|
||||
$this->columnIds[$columnName] = $newColumn['id'];
|
||||
$this->columnId = $newColumn['id'];
|
||||
|
||||
Assert::assertEquals(200, $this->response->getStatusCode());
|
||||
|
||||
@ -1202,7 +1203,14 @@ class FeatureContext implements Context {
|
||||
|
||||
Assert::assertEquals(200, $this->response->getStatusCode());
|
||||
foreach ($props as $key => $value) {
|
||||
Assert::assertEquals($column[$key], $value);
|
||||
if (is_array($column[$key])) {
|
||||
// I am afraid this is usergroupcolumn specific, but not generic
|
||||
$retrieved = json_encode($column[$key], true);
|
||||
} else {
|
||||
$retrieved = $column[$key];
|
||||
}
|
||||
|
||||
Assert::assertEquals($value, $retrieved, 'Failing key: ' . $key);
|
||||
}
|
||||
|
||||
$this->sendRequest(
|
||||
@ -1213,7 +1221,14 @@ class FeatureContext implements Context {
|
||||
$columnToVerify = $this->getDataFromResponse($this->response);
|
||||
Assert::assertEquals(200, $this->response->getStatusCode());
|
||||
foreach ($props as $key => $value) {
|
||||
Assert::assertEquals($columnToVerify[$key], $value);
|
||||
// I am afraid this is usergroupcolumn specific, but not generic
|
||||
if (is_array($columnToVerify[$key])) {
|
||||
$retrieved = json_encode($columnToVerify[$key], true);
|
||||
} else {
|
||||
$retrieved = $columnToVerify[$key];
|
||||
}
|
||||
|
||||
Assert::assertEquals($value, $retrieved, 'Failing key: ' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1253,7 +1268,17 @@ class FeatureContext implements Context {
|
||||
$rowToVerify = $this->getDataFromResponse($this->response);
|
||||
Assert::assertEquals(200, $this->response->getStatusCode());
|
||||
foreach ($rowToVerify['data'] as $cell) {
|
||||
Assert::assertEquals($props[$cell['columnId']], $cell['value']);
|
||||
// I am afraid this is usergroupcolumn specific, but not generic
|
||||
if (is_array($cell['value'])) {
|
||||
$retrieved = json_encode(array_reduce($cell['value'], function (array $carry, string $item): array {
|
||||
$carry[] = json_decode($item, true);
|
||||
return $carry;
|
||||
}, []));
|
||||
} else {
|
||||
$retrieved = $cell['value'];
|
||||
}
|
||||
|
||||
Assert::assertEquals($props[$cell['columnId']], $retrieved);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1429,7 +1454,17 @@ class FeatureContext implements Context {
|
||||
$rowToVerify = $this->getDataFromResponse($this->response);
|
||||
Assert::assertEquals(200, $this->response->getStatusCode());
|
||||
foreach ($rowToVerify['data'] as $cell) {
|
||||
Assert::assertEquals($props[$cell['columnId']], $cell['value']);
|
||||
// I am afraid this is usergroupcolumn specific, but not generic
|
||||
if (is_array($cell['value'])) {
|
||||
$retrieved = json_encode(array_reduce($cell['value'], function (array $carry, string $item): array {
|
||||
$carry[] = json_decode($item, true);
|
||||
return $carry;
|
||||
}, []));
|
||||
} else {
|
||||
$retrieved = $cell['value'];
|
||||
}
|
||||
|
||||
Assert::assertEquals($props[$cell['columnId']], $retrieved);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user