Skip to content
Open
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
6 changes: 6 additions & 0 deletions src/Appwrite/Utopia/Response/Model/MigrationReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public function __construct()
'default' => 0,
'example' => 20,
])
->addRule(Resource::TYPE_MEMBERSHIP, [
'type' => self::TYPE_INTEGER,
'description' => 'Number of memberships to be migrated.',
'default' => 0,
'example' => 20,
])
->addRule(Resource::TYPE_DATABASE, [
'type' => self::TYPE_INTEGER,
'description' => 'Number of databases to be migrated.',
Expand Down
48 changes: 48 additions & 0 deletions tests/unit/Utopia/Response/Model/MigrationReportTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

declare(strict_types=1);

namespace Tests\Unit\Utopia\Response\Model;

use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model\MigrationReport;
use PHPUnit\Framework\TestCase;
use Swoole\Http\Response as SwooleResponse;
use Utopia\Database\Document;
use Utopia\Migration\Resource;

final class MigrationReportTest extends TestCase
{
protected Response $response;

public function setUp(): void
{
$this->response = new Response(new SwooleResponse());
$this->response->setModel(new MigrationReport());
}

/**
* The Appwrite source counts memberships per team while building a report.
* The count used to be computed and then dropped on the way out, leaving a
* report that showed teams with nothing behind them.
*/
public function testReportsMembershipCounts(): void
{
$output = $this->response->output(new Document([
Resource::TYPE_TEAM => 2,
Resource::TYPE_MEMBERSHIP => 3,
]), Response::MODEL_MIGRATION_REPORT);

$this->assertSame(3, $output[Resource::TYPE_MEMBERSHIP]);
}

public function testReportsNoMembershipsAsZero(): void
{
$output = $this->response->output(
new Document([Resource::TYPE_TEAM => 2]),
Response::MODEL_MIGRATION_REPORT
);

$this->assertSame(0, $output[Resource::TYPE_MEMBERSHIP]);
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.
}
Loading