Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/Migration/Sources/Appwrite/Reader/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,11 @@ public function listTables(Database $resource, array $queries = []): array
*/
public function listColumns(Table $resource, array $queries = []): array
{
return \array_map(
fn ($column) => $column->toArray(),
$this->database->listColumns(
$resource->getDatabase()->getId(),
$resource->getId(),
$queries
)->columns
);
return $this->database->listColumns(
$resource->getDatabase()->getId(),
$resource->getId(),
$queries
)->toArray()['columns'];
}

/**
Expand Down
47 changes: 47 additions & 0 deletions tests/Migration/Unit/Sources/AppwriteReaderApiTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Utopia\Tests\Unit\Sources;

use Appwrite\Models\ColumnList;
use Appwrite\Services\TablesDB;
use PHPUnit\Framework\TestCase;
use Utopia\Migration\Resources\Database\Database;
use Utopia\Migration\Resources\Database\Table;
use Utopia\Migration\Sources\Appwrite\Reader\API;

final class AppwriteReaderApiTest extends TestCase
{
public function testListColumnsNormalizesSdkListResponse(): void
{
$columns = [
[
'key' => 'title',
'type' => 'string',
'status' => 'available',
'error' => '',
'required' => true,
'array' => false,
'$createdAt' => '2026-08-12T00:00:00.000+00:00',
'$updatedAt' => '2026-08-12T00:00:00.000+00:00',
'size' => 255,
'default' => null,
'encrypt' => false,
],
];

$database = new Database('database', 'Database');
$table = new Table($database, 'Table', 'table');

$tables = $this->createMock(TablesDB::class);
$tables
->expects($this->once())
->method('listColumns')
->with('database', 'table', [])
->willReturn(ColumnList::from([
'total' => 1,
'columns' => $columns,
]));

$this->assertSame($columns, (new API($tables))->listColumns($table));
}
}
Loading