1
0
Fork 0
mirror of synced 2024-08-03 20:42:09 +12:00
appwrite/tests/unit/Migration/MigrationTest.php

51 lines
1.3 KiB
PHP
Raw Normal View History

<?php
2022-08-01 22:22:04 +12:00
namespace Tests\Unit\Migration;
use Appwrite\Migration\Migration;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;
2022-01-19 00:05:04 +13:00
use Utopia\Database\Document;
abstract class MigrationTest extends TestCase
{
/**
* @var Migration
*/
protected Migration $migration;
/**
* @var ReflectionMethod
*/
protected ReflectionMethod $method;
/**
* Runs every document fix twice, to prevent corrupted data on multiple migrations.
2022-02-22 21:55:49 +13:00
*
* @param Document $document
*/
protected function fixDocument(Document $document)
{
return $this->method->invokeArgs($this->migration, [
$this->method->invokeArgs($this->migration, [$document])
]);
}
2021-07-02 21:33:10 +12:00
/**
* Check versions array integrity.
*/
2022-08-01 22:22:04 +12:00
public function testMigrationVersions(): void
2021-07-02 21:33:10 +12:00
{
2022-05-20 00:17:18 +12:00
require_once __DIR__ . '/../../../app/init.php';
2021-07-02 21:33:10 +12:00
2022-01-19 00:05:04 +13:00
foreach (Migration::$versions as $class) {
2022-05-20 00:17:18 +12:00
$this->assertTrue(class_exists('Appwrite\\Migration\\Version\\' . $class));
2021-07-02 21:33:10 +12:00
}
// Test if current version exists
2022-09-01 17:26:16 +12:00
// Only test official releases - skip if latest is release candidate
2022-09-01 17:26:49 +12:00
if (!(\str_contains(APP_VERSION_STABLE, 'RC'))) {
2022-09-01 17:26:16 +12:00
$this->assertArrayHasKey(APP_VERSION_STABLE, Migration::$versions);
}
2022-05-20 00:17:18 +12:00
}
}