From bc5767c8bd0aa7b7a5494f707fcc9f6d28d335a1 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 9 Aug 2023 17:11:15 +0100 Subject: [PATCH 1/2] Rename library to Migration --- Dockerfile | 8 +-- README.md | 6 +- composer.json | 10 ++-- docker-compose.yml | 4 +- phpunit.xml | 2 +- playground.php | 20 +++---- src/{Transfer => Migration}/Cache.php | 6 +- src/{Transfer => Migration}/Destination.php | 2 +- .../Destinations/Appwrite.php | 50 ++++++++--------- .../Destinations/Local.php | 12 ++-- src/{Transfer => Migration}/Resource.php | 2 +- .../Resources/Auth/Hash.php | 6 +- .../Resources/Auth/Membership.php | 6 +- .../Resources/Auth/Team.php | 8 +-- .../Resources/Auth/User.php | 6 +- .../Resources/Database/Attribute.php | 6 +- .../Resources/Database/Attributes/Boolean.php | 6 +- .../Database/Attributes/DateTime.php | 6 +- .../Resources/Database/Attributes/Decimal.php | 6 +- .../Resources/Database/Attributes/Email.php | 6 +- .../Resources/Database/Attributes/Enum.php | 6 +- .../Resources/Database/Attributes/IP.php | 6 +- .../Resources/Database/Attributes/Integer.php | 6 +- .../Database/Attributes/Relationship.php | 6 +- .../Resources/Database/Attributes/Text.php | 6 +- .../Resources/Database/Attributes/URL.php | 6 +- .../Resources/Database/Collection.php | 6 +- .../Resources/Database/Database.php | 6 +- .../Resources/Database/Document.php | 6 +- .../Resources/Database/Index.php | 6 +- .../Resources/Functions/Deployment.php | 6 +- .../Resources/Functions/EnvVar.php | 6 +- .../Resources/Functions/Func.php | 6 +- .../Resources/Storage/Bucket.php | 6 +- .../Resources/Storage/File.php | 6 +- src/{Transfer => Migration}/Source.php | 2 +- .../Sources/Appwrite.php | 56 +++++++++---------- .../Sources/Firebase.php | 36 ++++++------ src/{Transfer => Migration}/Sources/NHost.php | 36 ++++++------ .../Sources/Supabase.php | 16 +++--- src/{Transfer => Migration}/Target.php | 2 +- src/{Transfer => Migration}/Transfer.php | 2 +- tests/Transfer/E2E/Adapters/Mock.php | 4 +- tests/Transfer/E2E/Sources/Base.php | 10 ++-- tests/Transfer/E2E/Sources/NHostTest.php | 22 ++++---- tests/Transfer/E2E/Sources/SupabaseTest.php | 24 ++++---- 46 files changed, 239 insertions(+), 239 deletions(-) rename src/{Transfer => Migration}/Cache.php (96%) rename src/{Transfer => Migration}/Destination.php (96%) rename src/{Transfer => Migration}/Destinations/Appwrite.php (96%) rename src/{Transfer => Migration}/Destinations/Local.php (95%) rename src/{Transfer => Migration}/Resource.php (99%) rename src/{Transfer => Migration}/Resources/Auth/Hash.php (97%) rename src/{Transfer => Migration}/Resources/Auth/Membership.php (93%) rename src/{Transfer => Migration}/Resources/Auth/Team.php (91%) rename src/{Transfer => Migration}/Resources/Auth/User.php (98%) rename src/{Transfer => Migration}/Resources/Database/Attribute.php (95%) rename src/{Transfer => Migration}/Resources/Database/Attributes/Boolean.php (84%) rename src/{Transfer => Migration}/Resources/Database/Attributes/DateTime.php (80%) rename src/{Transfer => Migration}/Resources/Database/Attributes/Decimal.php (90%) rename src/{Transfer => Migration}/Resources/Database/Attributes/Email.php (80%) rename src/{Transfer => Migration}/Resources/Database/Attributes/Enum.php (87%) rename src/{Transfer => Migration}/Resources/Database/Attributes/IP.php (80%) rename src/{Transfer => Migration}/Resources/Database/Attributes/Integer.php (90%) rename src/{Transfer => Migration}/Resources/Database/Attributes/Relationship.php (92%) rename src/{Transfer => Migration}/Resources/Database/Attributes/Text.php (86%) rename src/{Transfer => Migration}/Resources/Database/Attributes/URL.php (80%) rename src/{Transfer => Migration}/Resources/Database/Collection.php (94%) rename src/{Transfer => Migration}/Resources/Database/Database.php (92%) rename src/{Transfer => Migration}/Resources/Database/Document.php (93%) rename src/{Transfer => Migration}/Resources/Database/Index.php (95%) rename src/{Transfer => Migration}/Resources/Functions/Deployment.php (95%) rename src/{Transfer => Migration}/Resources/Functions/EnvVar.php (91%) rename src/{Transfer => Migration}/Resources/Functions/Func.php (95%) rename src/{Transfer => Migration}/Resources/Storage/Bucket.php (97%) rename src/{Transfer => Migration}/Resources/Storage/File.php (96%) rename src/{Transfer => Migration}/Source.php (99%) rename src/{Transfer => Migration}/Sources/Appwrite.php (96%) rename src/{Transfer => Migration}/Sources/Firebase.php (95%) rename src/{Transfer => Migration}/Sources/NHost.php (96%) rename src/{Transfer => Migration}/Sources/Supabase.php (98%) rename src/{Transfer => Migration}/Target.php (99%) rename src/{Transfer => Migration}/Transfer.php (99%) diff --git a/Dockerfile b/Dockerfile index dc80ae10..a2b3efd6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ FROM supabase/postgres:15.1.0.96 as supabase-db -COPY ./tests/Transfer/resources/supabase/1_globals.sql /docker-entrypoint-initdb.d/1_globals.sql -COPY ./tests/Transfer/resources/supabase/2_main.sql /docker-entrypoint-initdb.d/2_main.sql +COPY ./tests/Migration/resources/supabase/1_globals.sql /docker-entrypoint-initdb.d/1_globals.sql +COPY ./tests/Migration/resources/supabase/2_main.sql /docker-entrypoint-initdb.d/2_main.sql RUN rm -rf /docker-entrypoint-initdb.d/migrate.sh FROM postgres:alpine3.18 as nhost-db -COPY ./tests/Transfer/resources/nhost/1_globals.sql /docker-entrypoint-initdb.d/1_globals.sql -COPY ./tests/Transfer/resources/nhost/2_main.sql /docker-entrypoint-initdb.d/2_main.sql +COPY ./tests/Migration/resources/nhost/1_globals.sql /docker-entrypoint-initdb.d/1_globals.sql +COPY ./tests/Migration/resources/nhost/2_main.sql /docker-entrypoint-initdb.d/2_main.sql # Use my fork of mockoon while waiting for range headers to be merged FROM node:20.4-alpine3.17 as mock-api diff --git a/README.md b/README.md index b8ed83b3..61aa1a33 100644 --- a/README.md +++ b/README.md @@ -19,9 +19,9 @@ Init in your application: ```php - ./tests/Transfer/E2E + ./tests/Migration/E2E \ No newline at end of file diff --git a/playground.php b/playground.php index 0f533188..52004159 100644 --- a/playground.php +++ b/playground.php @@ -1,21 +1,21 @@ load(); diff --git a/src/Transfer/Cache.php b/src/Migration/Cache.php similarity index 96% rename from src/Transfer/Cache.php rename to src/Migration/Cache.php index 4347a514..b25545da 100644 --- a/src/Transfer/Cache.php +++ b/src/Migration/Cache.php @@ -1,9 +1,9 @@ '3g2', 'video/3gp' => '3gp', diff --git a/src/Transfer/Target.php b/src/Migration/Target.php similarity index 99% rename from src/Transfer/Target.php rename to src/Migration/Target.php index eb52827e..41047158 100644 --- a/src/Transfer/Target.php +++ b/src/Migration/Target.php @@ -1,6 +1,6 @@ createMock(\Utopia\Transfer\Cache::class); + $cache = $this->createMock(\Utopia\Migration\Cache::class); $this->source->registerCache($cache); $this->assertNotNull($this->source->cache); diff --git a/tests/Transfer/E2E/Sources/NHostTest.php b/tests/Transfer/E2E/Sources/NHostTest.php index 62aa586b..410216fa 100644 --- a/tests/Transfer/E2E/Sources/NHostTest.php +++ b/tests/Transfer/E2E/Sources/NHostTest.php @@ -2,12 +2,12 @@ namespace Utopia\Tests\E2E\Sources; +use Utopia\Migration\Destination; +use Utopia\Migration\Resource; +use Utopia\Migration\Source; +use Utopia\Migration\Sources\NHost; +use Utopia\Migration\Transfer; use Utopia\Tests\E2E\Adapters\Mock; -use Utopia\Transfer\Destination; -use Utopia\Transfer\Resource; -use Utopia\Transfer\Source; -use Utopia\Transfer\Sources\NHost; -use Utopia\Transfer\Transfer; class NHostTest extends Base { @@ -139,7 +139,7 @@ public function testValidateUserTransfer($state): void $foundUser = null; foreach ($users as $user) { - /** @var \Utopia\Transfer\Resources\Auth\User $user */ + /** @var \Utopia\Migration\Resources\Auth\User $user */ if ($user->getEmail() === 'test@test.com') { $foundUser = $user; } @@ -170,7 +170,7 @@ public function testValidateDatabaseTransfer($state): void $foundDatabase = null; foreach ($databases as $database) { - /** @var \Utopia\Transfer\Resources\Database $database */ + /** @var \Utopia\Migration\Resources\Database $database */ if ($database->getDBName() === 'public') { $foundDatabase = $database; } @@ -193,7 +193,7 @@ public function testValidateDatabaseTransfer($state): void $foundCollection = null; foreach ($collections as $collection) { - /** @var \Utopia\Transfer\Resources\Database\Collection $collection */ + /** @var \Utopia\Migration\Resources\Database\Collection $collection */ if ($collection->getCollectionName() === 'TestTable') { $foundCollection = $collection; } @@ -223,7 +223,7 @@ public function testValidateStorageTransfer($state): void $foundBucket = null; foreach ($buckets as $bucket) { - /** @var \Utopia\Transfer\Resources\Bucket $bucket */ + /** @var \Utopia\Migration\Resources\Bucket $bucket */ if ($bucket->getId() === 'default') { $foundBucket = $bucket; } @@ -245,7 +245,7 @@ public function testValidateStorageTransfer($state): void $foundFile = null; foreach ($files as $file) { - /** @var \Utopia\Transfer\Resources\File $file */ + /** @var \Utopia\Migration\Resources\File $file */ if ($file->getFileName() === 'tulips.png') { $foundFile = $file; } @@ -258,7 +258,7 @@ public function testValidateStorageTransfer($state): void return; } - /** @var \Utopia\Transfer\Resources\Storage\File $foundFile */ + /** @var \Utopia\Migration\Resources\Storage\File $foundFile */ $this->assertEquals('success', $foundFile->getStatus()); $this->assertEquals('tulips.png', $foundFile->getFileName()); $this->assertEquals('default', $foundFile->getBucket()->getId()); diff --git a/tests/Transfer/E2E/Sources/SupabaseTest.php b/tests/Transfer/E2E/Sources/SupabaseTest.php index 62807f81..832e7835 100644 --- a/tests/Transfer/E2E/Sources/SupabaseTest.php +++ b/tests/Transfer/E2E/Sources/SupabaseTest.php @@ -2,12 +2,12 @@ namespace Utopia\Tests\E2E\Sources; +use Utopia\Migration\Destination; +use Utopia\Migration\Resource; +use Utopia\Migration\Source; +use Utopia\Migration\Sources\Supabase; +use Utopia\Migration\Transfer; use Utopia\Tests\E2E\Adapters\Mock; -use Utopia\Transfer\Destination; -use Utopia\Transfer\Resource; -use Utopia\Transfer\Source; -use Utopia\Transfer\Sources\Supabase; -use Utopia\Transfer\Transfer; class SupabaseTest extends Base { @@ -119,7 +119,7 @@ public function testValidateUserTransfer($state): void $foundUser = null; foreach ($users as $user) { - /** @var \Utopia\Transfer\Resources\Auth\User $user */ + /** @var \Utopia\Migration\Resources\Auth\User $user */ if ($user->getEmail() == 'albert.kihn95@yahoo.com') { $foundUser = $user; @@ -150,7 +150,7 @@ public function testValidateDatabaseTransfer($state): void $foundDatabase = null; foreach ($databases as $database) { - /** @var \Utopia\Transfer\Resources\Database $database */ + /** @var \Utopia\Migration\Resources\Database $database */ if ($database->getDBName() === 'public') { $foundDatabase = $database; } @@ -175,7 +175,7 @@ public function testValidateDatabaseTransfer($state): void $foundCollection = null; foreach ($collections as $collection) { - /** @var \Utopia\Transfer\Resources\Database\Collection $collection */ + /** @var \Utopia\Migration\Resources\Database\Collection $collection */ if ($collection->getDatabase()->getDBName() === 'public' && $collection->getCollectionName() === 'test') { $foundCollection = $collection; @@ -201,7 +201,7 @@ public function testValidateDatabaseTransfer($state): void $foundDocument = null; foreach ($documents as $document) { - /** @var \Utopia\Transfer\Resources\Database\Document $document */ + /** @var \Utopia\Migration\Resources\Database\Document $document */ if ($document->getCollection()->getDatabase()->getDBName() === 'public' && $document->getCollection()->getCollectionName() === 'test') { $foundDocument = $document; } @@ -230,7 +230,7 @@ public function testValidateStorageTransfer($state): void $foundBucket = null; foreach ($buckets as $bucket) { - /** @var \Utopia\Transfer\Resources\Storage\Bucket $bucket */ + /** @var \Utopia\Migration\Resources\Storage\Bucket $bucket */ if ($bucket->getBucketName() === 'Test Bucket 1') { $foundBucket = $bucket; } @@ -253,7 +253,7 @@ public function testValidateStorageTransfer($state): void $foundFile = null; foreach ($files as $file) { - /** @var \Utopia\Transfer\Resources\File $file */ + /** @var \Utopia\Migration\Resources\File $file */ if ($file->getFileName() === 'tulips.png') { $foundFile = $file; } @@ -266,7 +266,7 @@ public function testValidateStorageTransfer($state): void return; } - /** @var \Utopia\Transfer\Resources\Storage\File $foundFile */ + /** @var \Utopia\Migration\Resources\Storage\File $foundFile */ $this->assertEquals('success', $foundFile->getStatus()); $this->assertEquals('tulips.png', $foundFile->getFileName()); $this->assertEquals('image/png', $foundFile->getMimeType()); From 02f6e0a54204f3248eb5ca67d2f58e532e0111a1 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 9 Aug 2023 17:17:16 +0100 Subject: [PATCH 2/2] Update Tests location --- tests/{Transfer => Migration}/E2E/Adapters/Mock.php | 0 tests/{Transfer => Migration}/E2E/Sources/Base.php | 0 .../E2E/Sources/NHostTest.php | 0 .../E2E/Sources/SupabaseTest.php | 0 .../resources/nhost/1_globals.sql | 0 .../resources/nhost/2_main.sql | 0 .../resources/nhost/api.json | 0 .../resources/nhost/tulips.png | Bin .../resources/supabase/1_globals.sql | 0 .../resources/supabase/2_main.sql | 0 .../resources/supabase/api.json | 0 .../resources/supabase/tulips.png | Bin .../resources/updateBackups.sh | 0 13 files changed, 0 insertions(+), 0 deletions(-) rename tests/{Transfer => Migration}/E2E/Adapters/Mock.php (100%) rename tests/{Transfer => Migration}/E2E/Sources/Base.php (100%) rename tests/{Transfer => Migration}/E2E/Sources/NHostTest.php (100%) rename tests/{Transfer => Migration}/E2E/Sources/SupabaseTest.php (100%) rename tests/{Transfer => Migration}/resources/nhost/1_globals.sql (100%) rename tests/{Transfer => Migration}/resources/nhost/2_main.sql (100%) rename tests/{Transfer => Migration}/resources/nhost/api.json (100%) rename tests/{Transfer => Migration}/resources/nhost/tulips.png (100%) rename tests/{Transfer => Migration}/resources/supabase/1_globals.sql (100%) rename tests/{Transfer => Migration}/resources/supabase/2_main.sql (100%) rename tests/{Transfer => Migration}/resources/supabase/api.json (100%) rename tests/{Transfer => Migration}/resources/supabase/tulips.png (100%) rename tests/{Transfer => Migration}/resources/updateBackups.sh (100%) diff --git a/tests/Transfer/E2E/Adapters/Mock.php b/tests/Migration/E2E/Adapters/Mock.php similarity index 100% rename from tests/Transfer/E2E/Adapters/Mock.php rename to tests/Migration/E2E/Adapters/Mock.php diff --git a/tests/Transfer/E2E/Sources/Base.php b/tests/Migration/E2E/Sources/Base.php similarity index 100% rename from tests/Transfer/E2E/Sources/Base.php rename to tests/Migration/E2E/Sources/Base.php diff --git a/tests/Transfer/E2E/Sources/NHostTest.php b/tests/Migration/E2E/Sources/NHostTest.php similarity index 100% rename from tests/Transfer/E2E/Sources/NHostTest.php rename to tests/Migration/E2E/Sources/NHostTest.php diff --git a/tests/Transfer/E2E/Sources/SupabaseTest.php b/tests/Migration/E2E/Sources/SupabaseTest.php similarity index 100% rename from tests/Transfer/E2E/Sources/SupabaseTest.php rename to tests/Migration/E2E/Sources/SupabaseTest.php diff --git a/tests/Transfer/resources/nhost/1_globals.sql b/tests/Migration/resources/nhost/1_globals.sql similarity index 100% rename from tests/Transfer/resources/nhost/1_globals.sql rename to tests/Migration/resources/nhost/1_globals.sql diff --git a/tests/Transfer/resources/nhost/2_main.sql b/tests/Migration/resources/nhost/2_main.sql similarity index 100% rename from tests/Transfer/resources/nhost/2_main.sql rename to tests/Migration/resources/nhost/2_main.sql diff --git a/tests/Transfer/resources/nhost/api.json b/tests/Migration/resources/nhost/api.json similarity index 100% rename from tests/Transfer/resources/nhost/api.json rename to tests/Migration/resources/nhost/api.json diff --git a/tests/Transfer/resources/nhost/tulips.png b/tests/Migration/resources/nhost/tulips.png similarity index 100% rename from tests/Transfer/resources/nhost/tulips.png rename to tests/Migration/resources/nhost/tulips.png diff --git a/tests/Transfer/resources/supabase/1_globals.sql b/tests/Migration/resources/supabase/1_globals.sql similarity index 100% rename from tests/Transfer/resources/supabase/1_globals.sql rename to tests/Migration/resources/supabase/1_globals.sql diff --git a/tests/Transfer/resources/supabase/2_main.sql b/tests/Migration/resources/supabase/2_main.sql similarity index 100% rename from tests/Transfer/resources/supabase/2_main.sql rename to tests/Migration/resources/supabase/2_main.sql diff --git a/tests/Transfer/resources/supabase/api.json b/tests/Migration/resources/supabase/api.json similarity index 100% rename from tests/Transfer/resources/supabase/api.json rename to tests/Migration/resources/supabase/api.json diff --git a/tests/Transfer/resources/supabase/tulips.png b/tests/Migration/resources/supabase/tulips.png similarity index 100% rename from tests/Transfer/resources/supabase/tulips.png rename to tests/Migration/resources/supabase/tulips.png diff --git a/tests/Transfer/resources/updateBackups.sh b/tests/Migration/resources/updateBackups.sh similarity index 100% rename from tests/Transfer/resources/updateBackups.sh rename to tests/Migration/resources/updateBackups.sh