1
0
Fork 0
mirror of synced 2024-09-15 17:09:18 +12:00
appwrite/tests/unit/Migration/MigrationV12Test.php

80 lines
2.4 KiB
PHP
Raw Normal View History

2022-01-19 00:05:04 +13:00
<?php
2022-08-01 22:22:04 +12:00
namespace Tests\Unit\Migration;
2022-01-19 00:05:04 +13:00
use ReflectionClass;
use Appwrite\Migration\Version\V12;
use Utopia\Database\Document;
2022-08-14 22:33:36 +12:00
use Utopia\Database\ID;
2022-01-19 00:05:04 +13:00
class MigrationV12Test extends MigrationTest
{
public function setUp(): void
{
$this->migration = new V12();
$reflector = new ReflectionClass('Appwrite\Migration\Version\V12');
$this->method = $reflector->getMethod('fixDocument');
$this->method->setAccessible(true);
}
2022-08-01 22:22:04 +12:00
public function testMigrationProjects(): void
2022-01-19 00:05:04 +13:00
{
$document = $this->fixDocument(new Document([
2022-08-14 22:33:36 +12:00
'$id' => ID::custom('project'),
'$collection' => ID::custom('projects'),
'name' => 'Appwrite',
'version' => '0.12.0',
'search' => ''
2022-01-19 00:05:04 +13:00
]));
$this->assertEquals($document->getAttribute('version'), '0.13.0');
$this->assertEquals($document->getAttribute('search'), 'project Appwrite');
}
2022-08-01 22:22:04 +12:00
public function testMigrationUsers(): void
{
$document = $this->fixDocument(new Document([
2022-08-14 22:33:36 +12:00
'$id' => ID::custom('user'),
'$collection' => ID::custom('users'),
'email' => 'test@appwrite.io',
'name' => 'Torsten Dittmann'
]));
$this->assertEquals($document->getAttribute('search'), 'user test@appwrite.io Torsten Dittmann');
}
2022-08-01 22:22:04 +12:00
public function testMigrationTeams(): void
{
$document = $this->fixDocument(new Document([
2022-08-14 22:33:36 +12:00
'$id' => ID::custom('team'),
'$collection' => ID::custom('teams'),
'name' => 'Appwrite'
]));
$this->assertEquals($document->getAttribute('search'), 'team Appwrite');
}
2022-08-01 22:22:04 +12:00
public function testMigrationFunctions(): void
{
$document = $this->fixDocument(new Document([
2022-08-14 22:33:36 +12:00
'$id' => ID::custom('function'),
'$collection' => ID::custom('functions'),
'name' => 'My Function',
'runtime' => 'php-8.0'
]));
$this->assertEquals($document->getAttribute('search'), 'function My Function php-8.0');
}
2022-08-01 22:22:04 +12:00
public function testMigrationExecutions(): void
{
$document = $this->fixDocument(new Document([
2022-08-14 22:33:36 +12:00
'$id' => ID::custom('execution'),
'$collection' => ID::custom('executions'),
'functionId' => ID::custom('function')
]));
$this->assertEquals($document->getAttribute('search'), 'execution function');
2022-01-19 00:05:04 +13:00
}
}