From fee8e6c1e7d4a2e4627d8e2f842397d77182a6bc Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Feb 2026 12:06:01 +0000 Subject: [PATCH 1/3] Add array-based enum parameters --- .gitignore | 2 + CHANGELOG.md | 4 + LICENSE | 2 +- README.md | 4 +- composer.json | 6 +- docs/account.md | 6 + docs/examples/account/create-jwt.md | 4 +- docs/examples/avatars/get-screenshot.md | 11 +- docs/examples/databases/create-index.md | 3 +- docs/examples/databases/update-collection.md | 2 +- docs/examples/databases/update-document.md | 8 +- docs/examples/databases/update-documents.md | 8 +- docs/examples/databases/update.md | 2 +- docs/examples/databases/upsert-document.md | 8 +- docs/examples/functions/create.md | 3 +- docs/examples/functions/update.md | 3 +- docs/examples/health/get-queue-audits.md | 15 + docs/examples/tablesdb/create-index.md | 3 +- docs/examples/tablesdb/update-row.md | 8 +- docs/examples/tablesdb/update-rows.md | 8 +- docs/examples/tablesdb/update-table.md | 2 +- docs/examples/tablesdb/update.md | 2 +- docs/examples/tablesdb/upsert-row.md | 8 +- docs/examples/teams/create-membership.md | 3 +- docs/examples/teams/update-membership.md | 3 +- docs/health.md | 13 + docs/storage.md | 12 +- src/Appwrite/Client.php | 75 ++- src/Appwrite/Enums/BrowserPermission.php | 187 ++++++++ src/Appwrite/Enums/DeploymentStatus.php | 8 + src/Appwrite/Enums/Name.php | 8 + src/Appwrite/Enums/OAuthProvider.php | 8 - src/Appwrite/Enums/OrderBy.php | 43 ++ src/Appwrite/Enums/Output.php | 83 ---- src/Appwrite/Enums/Roles.php | 51 ++ src/Appwrite/Enums/Scopes.php | 467 +++++++++++++++++++ src/Appwrite/Query.php | 50 ++ src/Appwrite/Services/Account.php | 7 +- src/Appwrite/Services/Avatars.php | 7 +- src/Appwrite/Services/Databases.php | 28 +- src/Appwrite/Services/Functions.php | 5 +- src/Appwrite/Services/Health.php | 32 ++ src/Appwrite/Services/Sites.php | 4 +- src/Appwrite/Services/Storage.php | 7 +- src/Appwrite/Services/TablesDB.php | 19 +- src/Appwrite/Services/Teams.php | 1 + tests/Appwrite/IDTest.php | 3 +- tests/Appwrite/QueryTest.php | 235 +++++++--- tests/Appwrite/Services/AccountTest.php | 140 ++---- tests/Appwrite/Services/AvatarsTest.php | 21 +- tests/Appwrite/Services/DatabasesTest.php | 195 +++----- tests/Appwrite/Services/FunctionsTest.php | 80 ++-- tests/Appwrite/Services/GraphqlTest.php | 2 - tests/Appwrite/Services/HealthTest.php | 93 ++-- tests/Appwrite/Services/LocaleTest.php | 24 +- tests/Appwrite/Services/MessagingTest.php | 138 ++---- tests/Appwrite/Services/SitesTest.php | 81 ++-- tests/Appwrite/Services/StorageTest.php | 41 +- tests/Appwrite/Services/TablesDBTest.php | 192 +++----- tests/Appwrite/Services/TeamsTest.php | 36 +- tests/Appwrite/Services/TokensTest.php | 13 +- tests/Appwrite/Services/UsersTest.php | 117 ++--- 62 files changed, 1701 insertions(+), 953 deletions(-) create mode 100644 .gitignore create mode 100644 docs/examples/health/get-queue-audits.md create mode 100644 src/Appwrite/Enums/BrowserPermission.php create mode 100644 src/Appwrite/Enums/OrderBy.php delete mode 100644 src/Appwrite/Enums/Output.php create mode 100644 src/Appwrite/Enums/Roles.php create mode 100644 src/Appwrite/Enums/Scopes.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1502b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +vendor/ +composer.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index b94ebcc..14cf753 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 20.0.0 + +* Add array-based enum parameters (e.g., `permissions: array`). + ## 19.1.0 * Added ability to create columns and indexes synchronously while creating a table diff --git a/LICENSE b/LICENSE index c1602fc..6f8702b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2025 Appwrite (https://appwrite.io) and individual contributors. +Copyright (c) 2026 Appwrite (https://appwrite.io) and individual contributors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/README.md b/README.md index 3fc6168..9713e5d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.8.1-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) **This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** -Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) +Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) ![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png) diff --git a/composer.json b/composer.json index 83f2bc0..6d9446d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "appwrite/appwrite", - "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", + "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", "type": "library", "license": "BSD-3-Clause", "support": { @@ -16,13 +16,13 @@ } }, "require": { - "php": ">=7.1.0", + "php": ">=8.0.0", "ext-curl": "*", "ext-json": "*" }, "require-dev": { "phpunit/phpunit": "^10", - "mockery/mockery": "^1.6.12" + "mockery/mockery": "1.6.12" }, "minimum-stability": "dev" } \ No newline at end of file diff --git a/docs/account.md b/docs/account.md index f7c0724..8c7314f 100644 --- a/docs/account.md +++ b/docs/account.md @@ -73,6 +73,12 @@ POST https://cloud.appwrite.io/v1/account/jwts ** Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. ** +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| duration | integer | Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds. | 900 | + ```http request GET https://cloud.appwrite.io/v1/account/logs diff --git a/docs/examples/account/create-jwt.md b/docs/examples/account/create-jwt.md index 458405e..4031c64 100644 --- a/docs/examples/account/create-jwt.md +++ b/docs/examples/account/create-jwt.md @@ -10,4 +10,6 @@ $client = (new Client()) $account = new Account($client); -$result = $account->createJWT(); +$result = $account->createJWT( + duration: 0 // optional +); \ No newline at end of file diff --git a/docs/examples/avatars/get-screenshot.md b/docs/examples/avatars/get-screenshot.md index 9f91a3f..24c3aaa 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -4,7 +4,8 @@ use Appwrite\Client; use Appwrite\Services\Avatars; use Appwrite\Enums\Theme; use Appwrite\Enums\Timezone; -use Appwrite\Enums\Output; +use Appwrite\Enums\BrowserPermission; +use Appwrite\Enums\ImageFormat; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -22,19 +23,19 @@ $result = $avatars->getScreenshot( viewportWidth: 1920, // optional viewportHeight: 1080, // optional scale: 2, // optional - theme: Theme::LIGHT(), // optional + theme: Theme::DARK(), // optional userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15', // optional fullpage: true, // optional locale: 'en-US', // optional - timezone: Timezone::AFRICAABIDJAN(), // optional + timezone: Timezone::AMERICANEWYORK(), // optional latitude: 37.7749, // optional longitude: -122.4194, // optional accuracy: 100, // optional touch: true, // optional - permissions: ["geolocation","notifications"], // optional + permissions: [BrowserPermission::GEOLOCATION(), BrowserPermission::NOTIFICATIONS()], // optional sleep: 3, // optional width: 800, // optional height: 600, // optional quality: 85, // optional - output: Output::JPG() // optional + output: ImageFormat::JPEG() // optional ); \ No newline at end of file diff --git a/docs/examples/databases/create-index.md b/docs/examples/databases/create-index.md index 9e8a221..8dc2c88 100644 --- a/docs/examples/databases/create-index.md +++ b/docs/examples/databases/create-index.md @@ -3,6 +3,7 @@ use Appwrite\Client; use Appwrite\Services\Databases; use Appwrite\Enums\IndexType; +use Appwrite\Enums\OrderBy; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,6 +18,6 @@ $result = $databases->createIndex( key: '', type: IndexType::KEY(), attributes: [], - orders: [], // optional + orders: [OrderBy::ASC()], // optional lengths: [] // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update-collection.md b/docs/examples/databases/update-collection.md index d37f6e2..78e0dfe 100644 --- a/docs/examples/databases/update-collection.md +++ b/docs/examples/databases/update-collection.md @@ -15,7 +15,7 @@ $databases = new Databases($client); $result = $databases->updateCollection( databaseId: '', collectionId: '', - name: '', + name: '', // optional permissions: [Permission::read(Role::any())], // optional documentSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md index 2aaada2..5037d4b 100644 --- a/docs/examples/databases/update-document.md +++ b/docs/examples/databases/update-document.md @@ -16,7 +16,13 @@ $result = $databases->updateDocument( databaseId: '', collectionId: '', documentId: '', - data: [], // optional + data: [ + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O'Brien', + 'age' => 33, + 'isAdmin' => false + ], // optional permissions: [Permission::read(Role::any())], // optional transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update-documents.md b/docs/examples/databases/update-documents.md index 7263246..3a4aaad 100644 --- a/docs/examples/databases/update-documents.md +++ b/docs/examples/databases/update-documents.md @@ -13,7 +13,13 @@ $databases = new Databases($client); $result = $databases->updateDocuments( databaseId: '', collectionId: '', - data: [], // optional + data: [ + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O'Brien', + 'age' => 33, + 'isAdmin' => false + ], // optional queries: [], // optional transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update.md b/docs/examples/databases/update.md index 9b0b078..06a92b3 100644 --- a/docs/examples/databases/update.md +++ b/docs/examples/databases/update.md @@ -12,6 +12,6 @@ $databases = new Databases($client); $result = $databases->update( databaseId: '', - name: '', + name: '', // optional enabled: false // optional ); \ No newline at end of file diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 8e9d2c9..c4cee07 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -16,7 +16,13 @@ $result = $databases->upsertDocument( databaseId: '', collectionId: '', documentId: '', - data: [], + data: [ + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O'Brien', + 'age' => 30, + 'isAdmin' => false + ], // optional permissions: [Permission::read(Role::any())], // optional transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/functions/create.md b/docs/examples/functions/create.md index f717687..0504e73 100644 --- a/docs/examples/functions/create.md +++ b/docs/examples/functions/create.md @@ -3,6 +3,7 @@ use Appwrite\Client; use Appwrite\Services\Functions; use Appwrite\Enums\Runtime; +use Appwrite\Enums\Scopes; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -23,7 +24,7 @@ $result = $functions->create( logging: false, // optional entrypoint: '', // optional commands: '', // optional - scopes: [], // optional + scopes: [Scopes::SESSIONSWRITE()], // optional installationId: '', // optional providerRepositoryId: '', // optional providerBranch: '', // optional diff --git a/docs/examples/functions/update.md b/docs/examples/functions/update.md index da5ee88..1c3ff54 100644 --- a/docs/examples/functions/update.md +++ b/docs/examples/functions/update.md @@ -3,6 +3,7 @@ use Appwrite\Client; use Appwrite\Services\Functions; use Appwrite\Enums\Runtime; +use Appwrite\Enums\Scopes; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -23,7 +24,7 @@ $result = $functions->update( logging: false, // optional entrypoint: '', // optional commands: '', // optional - scopes: [], // optional + scopes: [Scopes::SESSIONSWRITE()], // optional installationId: '', // optional providerRepositoryId: '', // optional providerBranch: '', // optional diff --git a/docs/examples/health/get-queue-audits.md b/docs/examples/health/get-queue-audits.md new file mode 100644 index 0000000..cd51345 --- /dev/null +++ b/docs/examples/health/get-queue-audits.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$health = new Health($client); + +$result = $health->getQueueAudits( + threshold: null // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-index.md b/docs/examples/tablesdb/create-index.md index 1a3fd13..b56f503 100644 --- a/docs/examples/tablesdb/create-index.md +++ b/docs/examples/tablesdb/create-index.md @@ -3,6 +3,7 @@ use Appwrite\Client; use Appwrite\Services\TablesDB; use Appwrite\Enums\IndexType; +use Appwrite\Enums\OrderBy; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -17,6 +18,6 @@ $result = $tablesDB->createIndex( key: '', type: IndexType::KEY(), columns: [], - orders: [], // optional + orders: [OrderBy::ASC()], // optional lengths: [] // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md index d92ab78..71916cd 100644 --- a/docs/examples/tablesdb/update-row.md +++ b/docs/examples/tablesdb/update-row.md @@ -16,7 +16,13 @@ $result = $tablesDB->updateRow( databaseId: '', tableId: '', rowId: '', - data: [], // optional + data: [ + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O'Brien', + 'age' => 33, + 'isAdmin' => false + ], // optional permissions: [Permission::read(Role::any())], // optional transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-rows.md b/docs/examples/tablesdb/update-rows.md index 681a9f0..a6892f8 100644 --- a/docs/examples/tablesdb/update-rows.md +++ b/docs/examples/tablesdb/update-rows.md @@ -13,7 +13,13 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->updateRows( databaseId: '', tableId: '', - data: [], // optional + data: [ + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O'Brien', + 'age' => 33, + 'isAdmin' => false + ], // optional queries: [], // optional transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-table.md b/docs/examples/tablesdb/update-table.md index 22f1523..dc09f5f 100644 --- a/docs/examples/tablesdb/update-table.md +++ b/docs/examples/tablesdb/update-table.md @@ -15,7 +15,7 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->updateTable( databaseId: '', tableId: '', - name: '', + name: '', // optional permissions: [Permission::read(Role::any())], // optional rowSecurity: false, // optional enabled: false // optional diff --git a/docs/examples/tablesdb/update.md b/docs/examples/tablesdb/update.md index 106b75e..0dcd049 100644 --- a/docs/examples/tablesdb/update.md +++ b/docs/examples/tablesdb/update.md @@ -12,6 +12,6 @@ $tablesDB = new TablesDB($client); $result = $tablesDB->update( databaseId: '', - name: '', + name: '', // optional enabled: false // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md index 192463e..e26c825 100644 --- a/docs/examples/tablesdb/upsert-row.md +++ b/docs/examples/tablesdb/upsert-row.md @@ -16,7 +16,13 @@ $result = $tablesDB->upsertRow( databaseId: '', tableId: '', rowId: '', - data: [], // optional + data: [ + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O'Brien', + 'age' => 33, + 'isAdmin' => false + ], // optional permissions: [Permission::read(Role::any())], // optional transactionId: '' // optional ); \ No newline at end of file diff --git a/docs/examples/teams/create-membership.md b/docs/examples/teams/create-membership.md index 285368f..53fb6ef 100644 --- a/docs/examples/teams/create-membership.md +++ b/docs/examples/teams/create-membership.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Teams; +use Appwrite\Enums\Roles; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -12,7 +13,7 @@ $teams = new Teams($client); $result = $teams->createMembership( teamId: '', - roles: [], + roles: [Roles::ADMIN()], email: 'email@example.com', // optional userId: '', // optional phone: '+12065550100', // optional diff --git a/docs/examples/teams/update-membership.md b/docs/examples/teams/update-membership.md index 10f135b..0cdd13e 100644 --- a/docs/examples/teams/update-membership.md +++ b/docs/examples/teams/update-membership.md @@ -2,6 +2,7 @@ use Appwrite\Client; use Appwrite\Services\Teams; +use Appwrite\Enums\Roles; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -13,5 +14,5 @@ $teams = new Teams($client); $result = $teams->updateMembership( teamId: '', membershipId: '', - roles: [] + roles: [Roles::ADMIN()] ); \ No newline at end of file diff --git a/docs/health.md b/docs/health.md index dc19294..a381890 100644 --- a/docs/health.md +++ b/docs/health.md @@ -49,6 +49,19 @@ GET https://cloud.appwrite.io/v1/health/pubsub ** Check the Appwrite pub-sub servers are up and connection is successful. ** +```http request +GET https://cloud.appwrite.io/v1/health/queue/audits +``` + +** Get the number of audit logs that are waiting to be processed in the Appwrite internal queue server. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| threshold | integer | Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000. | 5000 | + + ```http request GET https://cloud.appwrite.io/v1/health/queue/builds ``` diff --git a/docs/storage.md b/docs/storage.md index 8654029..74960e3 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -33,7 +33,7 @@ POST https://cloud.appwrite.io/v1/storage/buckets | enabled | boolean | Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. | 1 | | maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 30MB. | [] | | allowedFileExtensions | array | Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. | [] | -| compression | string | Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | +| compression | string | Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | | encryption | boolean | Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled | 1 | | antivirus | boolean | Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled | 1 | | transformations | boolean | Are image transformations enabled? | 1 | @@ -69,7 +69,7 @@ PUT https://cloud.appwrite.io/v1/storage/buckets/{bucketId} | enabled | boolean | Is bucket enabled? When set to 'disabled', users cannot access the files in this bucket but Server SDKs with and API key can still access the bucket. No files are lost when this is toggled. | 1 | | maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 30MB. | [] | | allowedFileExtensions | array | Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long. | [] | -| compression | string | Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | +| compression | string | Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled | none | | encryption | boolean | Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled | 1 | | antivirus | boolean | Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled | 1 | | transformations | boolean | Are image transformations enabled? | 1 | @@ -151,10 +151,10 @@ PUT https://cloud.appwrite.io/v1/storage/buckets/{bucketId}/files/{fileId} | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| bucketId | string | **Required** Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket). | | -| fileId | string | **Required** File unique ID. | | -| name | string | Name of the file | | -| permissions | array | An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| bucketId | string | **Required** Bucket unique ID. | | +| fileId | string | **Required** File ID. | | +| name | string | File name. | | +| permissions | array | An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 9ade612..8d8d89e 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,13 +37,27 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/19.1.0 ()', + 'user-agent' => 'AppwritePHPSDK/20.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '19.1.0', + 'x-sdk-version'=> '20.0.0', ]; + /** + * Timeout in seconds + * + * @var int|null + */ + protected ?int $timeout = null; + + /** + * Connect timeout in seconds + * + * @var int|null + */ + protected ?int $connectTimeout = null; + /** * Client constructor. */ @@ -173,6 +187,30 @@ public function setEndpoint(string $endpoint): Client return $this; } + /** + * Set Timeout + * + * @param int $timeout Timeout in seconds + * @return Client + */ + public function setTimeout(int $timeout): Client + { + $this->timeout = $timeout; + return $this; + } + + /** + * Set Connect Timeout + * + * @param int $connectTimeout Connect timeout in seconds + * @return Client + */ + public function setConnectTimeout(int $connectTimeout): Client + { + $this->connectTimeout = $connectTimeout; + return $this; + } + /** * @param $key * @param $value @@ -180,7 +218,7 @@ public function setEndpoint(string $endpoint): Client public function addHeader(string $key, string $value): Client { $this->headers[strtolower($key)] = $value; - + return $this; } @@ -210,7 +248,7 @@ public function call( switch ($headers['content-type']) { case 'application/json': - $query = json_encode($params); + $query = json_encode($this->prepareParams($params)); break; case 'multipart/form-data': @@ -255,6 +293,16 @@ public function call( curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); } + // Set timeout if configured + if($this->timeout !== null) { + curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); + } + + // Set connect timeout if configured + if($this->connectTimeout !== null) { + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->connectTimeout); + } + $responseBody = curl_exec($ch); $contentType = $responseHeaders['content-type'] ?? ''; $responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); @@ -316,4 +364,23 @@ protected function flatten(array $data, string $prefix = ''): array { return $output; } + + /** + * Prepare params for JSON encoding by converting model objects to arrays + * + * @param mixed $data + * @return mixed + */ + protected function prepareParams($data) + { + if (is_array($data)) { + return array_map([$this, 'prepareParams'], $data); + } + + if (is_object($data) && method_exists($data, 'toArray')) { + return $data->toArray(); + } + + return $data; + } } diff --git a/src/Appwrite/Enums/BrowserPermission.php b/src/Appwrite/Enums/BrowserPermission.php new file mode 100644 index 0000000..30a13a1 --- /dev/null +++ b/src/Appwrite/Enums/BrowserPermission.php @@ -0,0 +1,187 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function GEOLOCATION(): BrowserPermission + { + if (!isset(self::$GEOLOCATION)) { + self::$GEOLOCATION = new BrowserPermission('geolocation'); + } + return self::$GEOLOCATION; + } + public static function CAMERA(): BrowserPermission + { + if (!isset(self::$CAMERA)) { + self::$CAMERA = new BrowserPermission('camera'); + } + return self::$CAMERA; + } + public static function MICROPHONE(): BrowserPermission + { + if (!isset(self::$MICROPHONE)) { + self::$MICROPHONE = new BrowserPermission('microphone'); + } + return self::$MICROPHONE; + } + public static function NOTIFICATIONS(): BrowserPermission + { + if (!isset(self::$NOTIFICATIONS)) { + self::$NOTIFICATIONS = new BrowserPermission('notifications'); + } + return self::$NOTIFICATIONS; + } + public static function MIDI(): BrowserPermission + { + if (!isset(self::$MIDI)) { + self::$MIDI = new BrowserPermission('midi'); + } + return self::$MIDI; + } + public static function PUSH(): BrowserPermission + { + if (!isset(self::$PUSH)) { + self::$PUSH = new BrowserPermission('push'); + } + return self::$PUSH; + } + public static function CLIPBOARDREAD(): BrowserPermission + { + if (!isset(self::$CLIPBOARDREAD)) { + self::$CLIPBOARDREAD = new BrowserPermission('clipboard-read'); + } + return self::$CLIPBOARDREAD; + } + public static function CLIPBOARDWRITE(): BrowserPermission + { + if (!isset(self::$CLIPBOARDWRITE)) { + self::$CLIPBOARDWRITE = new BrowserPermission('clipboard-write'); + } + return self::$CLIPBOARDWRITE; + } + public static function PAYMENTHANDLER(): BrowserPermission + { + if (!isset(self::$PAYMENTHANDLER)) { + self::$PAYMENTHANDLER = new BrowserPermission('payment-handler'); + } + return self::$PAYMENTHANDLER; + } + public static function USB(): BrowserPermission + { + if (!isset(self::$USB)) { + self::$USB = new BrowserPermission('usb'); + } + return self::$USB; + } + public static function BLUETOOTH(): BrowserPermission + { + if (!isset(self::$BLUETOOTH)) { + self::$BLUETOOTH = new BrowserPermission('bluetooth'); + } + return self::$BLUETOOTH; + } + public static function ACCELEROMETER(): BrowserPermission + { + if (!isset(self::$ACCELEROMETER)) { + self::$ACCELEROMETER = new BrowserPermission('accelerometer'); + } + return self::$ACCELEROMETER; + } + public static function GYROSCOPE(): BrowserPermission + { + if (!isset(self::$GYROSCOPE)) { + self::$GYROSCOPE = new BrowserPermission('gyroscope'); + } + return self::$GYROSCOPE; + } + public static function MAGNETOMETER(): BrowserPermission + { + if (!isset(self::$MAGNETOMETER)) { + self::$MAGNETOMETER = new BrowserPermission('magnetometer'); + } + return self::$MAGNETOMETER; + } + public static function AMBIENTLIGHTSENSOR(): BrowserPermission + { + if (!isset(self::$AMBIENTLIGHTSENSOR)) { + self::$AMBIENTLIGHTSENSOR = new BrowserPermission('ambient-light-sensor'); + } + return self::$AMBIENTLIGHTSENSOR; + } + public static function BACKGROUNDSYNC(): BrowserPermission + { + if (!isset(self::$BACKGROUNDSYNC)) { + self::$BACKGROUNDSYNC = new BrowserPermission('background-sync'); + } + return self::$BACKGROUNDSYNC; + } + public static function PERSISTENTSTORAGE(): BrowserPermission + { + if (!isset(self::$PERSISTENTSTORAGE)) { + self::$PERSISTENTSTORAGE = new BrowserPermission('persistent-storage'); + } + return self::$PERSISTENTSTORAGE; + } + public static function SCREENWAKELOCK(): BrowserPermission + { + if (!isset(self::$SCREENWAKELOCK)) { + self::$SCREENWAKELOCK = new BrowserPermission('screen-wake-lock'); + } + return self::$SCREENWAKELOCK; + } + public static function WEBSHARE(): BrowserPermission + { + if (!isset(self::$WEBSHARE)) { + self::$WEBSHARE = new BrowserPermission('web-share'); + } + return self::$WEBSHARE; + } + public static function XRSPATIALTRACKING(): BrowserPermission + { + if (!isset(self::$XRSPATIALTRACKING)) { + self::$XRSPATIALTRACKING = new BrowserPermission('xr-spatial-tracking'); + } + return self::$XRSPATIALTRACKING; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/DeploymentStatus.php b/src/Appwrite/Enums/DeploymentStatus.php index 7d53c88..1cc26b6 100644 --- a/src/Appwrite/Enums/DeploymentStatus.php +++ b/src/Appwrite/Enums/DeploymentStatus.php @@ -10,6 +10,7 @@ class DeploymentStatus implements JsonSerializable private static DeploymentStatus $PROCESSING; private static DeploymentStatus $BUILDING; private static DeploymentStatus $READY; + private static DeploymentStatus $CANCELED; private static DeploymentStatus $FAILED; private string $value; @@ -57,6 +58,13 @@ public static function READY(): DeploymentStatus } return self::$READY; } + public static function CANCELED(): DeploymentStatus + { + if (!isset(self::$CANCELED)) { + self::$CANCELED = new DeploymentStatus('canceled'); + } + return self::$CANCELED; + } public static function FAILED(): DeploymentStatus { if (!isset(self::$FAILED)) { diff --git a/src/Appwrite/Enums/Name.php b/src/Appwrite/Enums/Name.php index bcf9dc5..7407769 100644 --- a/src/Appwrite/Enums/Name.php +++ b/src/Appwrite/Enums/Name.php @@ -16,6 +16,7 @@ class Name implements JsonSerializable private static Name $V1WEBHOOKS; private static Name $V1CERTIFICATES; private static Name $V1BUILDS; + private static Name $V1SCREENSHOTS; private static Name $V1MESSAGING; private static Name $V1MIGRATIONS; @@ -106,6 +107,13 @@ public static function V1BUILDS(): Name } return self::$V1BUILDS; } + public static function V1SCREENSHOTS(): Name + { + if (!isset(self::$V1SCREENSHOTS)) { + self::$V1SCREENSHOTS = new Name('v1-screenshots'); + } + return self::$V1SCREENSHOTS; + } public static function V1MESSAGING(): Name { if (!isset(self::$V1MESSAGING)) { diff --git a/src/Appwrite/Enums/OAuthProvider.php b/src/Appwrite/Enums/OAuthProvider.php index 4763c9c..9e12b9a 100644 --- a/src/Appwrite/Enums/OAuthProvider.php +++ b/src/Appwrite/Enums/OAuthProvider.php @@ -45,7 +45,6 @@ class OAuthProvider implements JsonSerializable private static OAuthProvider $YANDEX; private static OAuthProvider $ZOHO; private static OAuthProvider $ZOOM; - private static OAuthProvider $MOCK; private string $value; @@ -337,11 +336,4 @@ public static function ZOOM(): OAuthProvider } return self::$ZOOM; } - public static function MOCK(): OAuthProvider - { - if (!isset(self::$MOCK)) { - self::$MOCK = new OAuthProvider('mock'); - } - return self::$MOCK; - } } \ No newline at end of file diff --git a/src/Appwrite/Enums/OrderBy.php b/src/Appwrite/Enums/OrderBy.php new file mode 100644 index 0000000..457dd7a --- /dev/null +++ b/src/Appwrite/Enums/OrderBy.php @@ -0,0 +1,43 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function ASC(): OrderBy + { + if (!isset(self::$ASC)) { + self::$ASC = new OrderBy('asc'); + } + return self::$ASC; + } + public static function DESC(): OrderBy + { + if (!isset(self::$DESC)) { + self::$DESC = new OrderBy('desc'); + } + return self::$DESC; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/Output.php b/src/Appwrite/Enums/Output.php deleted file mode 100644 index 45c0675..0000000 --- a/src/Appwrite/Enums/Output.php +++ /dev/null @@ -1,83 +0,0 @@ -value = $value; - } - - public function __toString(): string - { - return $this->value; - } - - public function jsonSerialize(): string - { - return $this->value; - } - - public static function JPG(): Output - { - if (!isset(self::$JPG)) { - self::$JPG = new Output('jpg'); - } - return self::$JPG; - } - public static function JPEG(): Output - { - if (!isset(self::$JPEG)) { - self::$JPEG = new Output('jpeg'); - } - return self::$JPEG; - } - public static function PNG(): Output - { - if (!isset(self::$PNG)) { - self::$PNG = new Output('png'); - } - return self::$PNG; - } - public static function WEBP(): Output - { - if (!isset(self::$WEBP)) { - self::$WEBP = new Output('webp'); - } - return self::$WEBP; - } - public static function HEIC(): Output - { - if (!isset(self::$HEIC)) { - self::$HEIC = new Output('heic'); - } - return self::$HEIC; - } - public static function AVIF(): Output - { - if (!isset(self::$AVIF)) { - self::$AVIF = new Output('avif'); - } - return self::$AVIF; - } - public static function GIF(): Output - { - if (!isset(self::$GIF)) { - self::$GIF = new Output('gif'); - } - return self::$GIF; - } -} \ No newline at end of file diff --git a/src/Appwrite/Enums/Roles.php b/src/Appwrite/Enums/Roles.php new file mode 100644 index 0000000..635c725 --- /dev/null +++ b/src/Appwrite/Enums/Roles.php @@ -0,0 +1,51 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function ADMIN(): Roles + { + if (!isset(self::$ADMIN)) { + self::$ADMIN = new Roles('admin'); + } + return self::$ADMIN; + } + public static function DEVELOPER(): Roles + { + if (!isset(self::$DEVELOPER)) { + self::$DEVELOPER = new Roles('developer'); + } + return self::$DEVELOPER; + } + public static function OWNER(): Roles + { + if (!isset(self::$OWNER)) { + self::$OWNER = new Roles('owner'); + } + return self::$OWNER; + } +} \ No newline at end of file diff --git a/src/Appwrite/Enums/Scopes.php b/src/Appwrite/Enums/Scopes.php new file mode 100644 index 0000000..aa82645 --- /dev/null +++ b/src/Appwrite/Enums/Scopes.php @@ -0,0 +1,467 @@ +value = $value; + } + + public function __toString(): string + { + return $this->value; + } + + public function jsonSerialize(): string + { + return $this->value; + } + + public static function SESSIONSWRITE(): Scopes + { + if (!isset(self::$SESSIONSWRITE)) { + self::$SESSIONSWRITE = new Scopes('sessions.write'); + } + return self::$SESSIONSWRITE; + } + public static function USERSREAD(): Scopes + { + if (!isset(self::$USERSREAD)) { + self::$USERSREAD = new Scopes('users.read'); + } + return self::$USERSREAD; + } + public static function USERSWRITE(): Scopes + { + if (!isset(self::$USERSWRITE)) { + self::$USERSWRITE = new Scopes('users.write'); + } + return self::$USERSWRITE; + } + public static function TEAMSREAD(): Scopes + { + if (!isset(self::$TEAMSREAD)) { + self::$TEAMSREAD = new Scopes('teams.read'); + } + return self::$TEAMSREAD; + } + public static function TEAMSWRITE(): Scopes + { + if (!isset(self::$TEAMSWRITE)) { + self::$TEAMSWRITE = new Scopes('teams.write'); + } + return self::$TEAMSWRITE; + } + public static function DATABASESREAD(): Scopes + { + if (!isset(self::$DATABASESREAD)) { + self::$DATABASESREAD = new Scopes('databases.read'); + } + return self::$DATABASESREAD; + } + public static function DATABASESWRITE(): Scopes + { + if (!isset(self::$DATABASESWRITE)) { + self::$DATABASESWRITE = new Scopes('databases.write'); + } + return self::$DATABASESWRITE; + } + public static function COLLECTIONSREAD(): Scopes + { + if (!isset(self::$COLLECTIONSREAD)) { + self::$COLLECTIONSREAD = new Scopes('collections.read'); + } + return self::$COLLECTIONSREAD; + } + public static function COLLECTIONSWRITE(): Scopes + { + if (!isset(self::$COLLECTIONSWRITE)) { + self::$COLLECTIONSWRITE = new Scopes('collections.write'); + } + return self::$COLLECTIONSWRITE; + } + public static function TABLESREAD(): Scopes + { + if (!isset(self::$TABLESREAD)) { + self::$TABLESREAD = new Scopes('tables.read'); + } + return self::$TABLESREAD; + } + public static function TABLESWRITE(): Scopes + { + if (!isset(self::$TABLESWRITE)) { + self::$TABLESWRITE = new Scopes('tables.write'); + } + return self::$TABLESWRITE; + } + public static function ATTRIBUTESREAD(): Scopes + { + if (!isset(self::$ATTRIBUTESREAD)) { + self::$ATTRIBUTESREAD = new Scopes('attributes.read'); + } + return self::$ATTRIBUTESREAD; + } + public static function ATTRIBUTESWRITE(): Scopes + { + if (!isset(self::$ATTRIBUTESWRITE)) { + self::$ATTRIBUTESWRITE = new Scopes('attributes.write'); + } + return self::$ATTRIBUTESWRITE; + } + public static function COLUMNSREAD(): Scopes + { + if (!isset(self::$COLUMNSREAD)) { + self::$COLUMNSREAD = new Scopes('columns.read'); + } + return self::$COLUMNSREAD; + } + public static function COLUMNSWRITE(): Scopes + { + if (!isset(self::$COLUMNSWRITE)) { + self::$COLUMNSWRITE = new Scopes('columns.write'); + } + return self::$COLUMNSWRITE; + } + public static function INDEXESREAD(): Scopes + { + if (!isset(self::$INDEXESREAD)) { + self::$INDEXESREAD = new Scopes('indexes.read'); + } + return self::$INDEXESREAD; + } + public static function INDEXESWRITE(): Scopes + { + if (!isset(self::$INDEXESWRITE)) { + self::$INDEXESWRITE = new Scopes('indexes.write'); + } + return self::$INDEXESWRITE; + } + public static function DOCUMENTSREAD(): Scopes + { + if (!isset(self::$DOCUMENTSREAD)) { + self::$DOCUMENTSREAD = new Scopes('documents.read'); + } + return self::$DOCUMENTSREAD; + } + public static function DOCUMENTSWRITE(): Scopes + { + if (!isset(self::$DOCUMENTSWRITE)) { + self::$DOCUMENTSWRITE = new Scopes('documents.write'); + } + return self::$DOCUMENTSWRITE; + } + public static function ROWSREAD(): Scopes + { + if (!isset(self::$ROWSREAD)) { + self::$ROWSREAD = new Scopes('rows.read'); + } + return self::$ROWSREAD; + } + public static function ROWSWRITE(): Scopes + { + if (!isset(self::$ROWSWRITE)) { + self::$ROWSWRITE = new Scopes('rows.write'); + } + return self::$ROWSWRITE; + } + public static function FILESREAD(): Scopes + { + if (!isset(self::$FILESREAD)) { + self::$FILESREAD = new Scopes('files.read'); + } + return self::$FILESREAD; + } + public static function FILESWRITE(): Scopes + { + if (!isset(self::$FILESWRITE)) { + self::$FILESWRITE = new Scopes('files.write'); + } + return self::$FILESWRITE; + } + public static function BUCKETSREAD(): Scopes + { + if (!isset(self::$BUCKETSREAD)) { + self::$BUCKETSREAD = new Scopes('buckets.read'); + } + return self::$BUCKETSREAD; + } + public static function BUCKETSWRITE(): Scopes + { + if (!isset(self::$BUCKETSWRITE)) { + self::$BUCKETSWRITE = new Scopes('buckets.write'); + } + return self::$BUCKETSWRITE; + } + public static function FUNCTIONSREAD(): Scopes + { + if (!isset(self::$FUNCTIONSREAD)) { + self::$FUNCTIONSREAD = new Scopes('functions.read'); + } + return self::$FUNCTIONSREAD; + } + public static function FUNCTIONSWRITE(): Scopes + { + if (!isset(self::$FUNCTIONSWRITE)) { + self::$FUNCTIONSWRITE = new Scopes('functions.write'); + } + return self::$FUNCTIONSWRITE; + } + public static function SITESREAD(): Scopes + { + if (!isset(self::$SITESREAD)) { + self::$SITESREAD = new Scopes('sites.read'); + } + return self::$SITESREAD; + } + public static function SITESWRITE(): Scopes + { + if (!isset(self::$SITESWRITE)) { + self::$SITESWRITE = new Scopes('sites.write'); + } + return self::$SITESWRITE; + } + public static function LOGREAD(): Scopes + { + if (!isset(self::$LOGREAD)) { + self::$LOGREAD = new Scopes('log.read'); + } + return self::$LOGREAD; + } + public static function LOGWRITE(): Scopes + { + if (!isset(self::$LOGWRITE)) { + self::$LOGWRITE = new Scopes('log.write'); + } + return self::$LOGWRITE; + } + public static function EXECUTIONREAD(): Scopes + { + if (!isset(self::$EXECUTIONREAD)) { + self::$EXECUTIONREAD = new Scopes('execution.read'); + } + return self::$EXECUTIONREAD; + } + public static function EXECUTIONWRITE(): Scopes + { + if (!isset(self::$EXECUTIONWRITE)) { + self::$EXECUTIONWRITE = new Scopes('execution.write'); + } + return self::$EXECUTIONWRITE; + } + public static function LOCALEREAD(): Scopes + { + if (!isset(self::$LOCALEREAD)) { + self::$LOCALEREAD = new Scopes('locale.read'); + } + return self::$LOCALEREAD; + } + public static function AVATARSREAD(): Scopes + { + if (!isset(self::$AVATARSREAD)) { + self::$AVATARSREAD = new Scopes('avatars.read'); + } + return self::$AVATARSREAD; + } + public static function HEALTHREAD(): Scopes + { + if (!isset(self::$HEALTHREAD)) { + self::$HEALTHREAD = new Scopes('health.read'); + } + return self::$HEALTHREAD; + } + public static function PROVIDERSREAD(): Scopes + { + if (!isset(self::$PROVIDERSREAD)) { + self::$PROVIDERSREAD = new Scopes('providers.read'); + } + return self::$PROVIDERSREAD; + } + public static function PROVIDERSWRITE(): Scopes + { + if (!isset(self::$PROVIDERSWRITE)) { + self::$PROVIDERSWRITE = new Scopes('providers.write'); + } + return self::$PROVIDERSWRITE; + } + public static function MESSAGESREAD(): Scopes + { + if (!isset(self::$MESSAGESREAD)) { + self::$MESSAGESREAD = new Scopes('messages.read'); + } + return self::$MESSAGESREAD; + } + public static function MESSAGESWRITE(): Scopes + { + if (!isset(self::$MESSAGESWRITE)) { + self::$MESSAGESWRITE = new Scopes('messages.write'); + } + return self::$MESSAGESWRITE; + } + public static function TOPICSREAD(): Scopes + { + if (!isset(self::$TOPICSREAD)) { + self::$TOPICSREAD = new Scopes('topics.read'); + } + return self::$TOPICSREAD; + } + public static function TOPICSWRITE(): Scopes + { + if (!isset(self::$TOPICSWRITE)) { + self::$TOPICSWRITE = new Scopes('topics.write'); + } + return self::$TOPICSWRITE; + } + public static function SUBSCRIBERSREAD(): Scopes + { + if (!isset(self::$SUBSCRIBERSREAD)) { + self::$SUBSCRIBERSREAD = new Scopes('subscribers.read'); + } + return self::$SUBSCRIBERSREAD; + } + public static function SUBSCRIBERSWRITE(): Scopes + { + if (!isset(self::$SUBSCRIBERSWRITE)) { + self::$SUBSCRIBERSWRITE = new Scopes('subscribers.write'); + } + return self::$SUBSCRIBERSWRITE; + } + public static function TARGETSREAD(): Scopes + { + if (!isset(self::$TARGETSREAD)) { + self::$TARGETSREAD = new Scopes('targets.read'); + } + return self::$TARGETSREAD; + } + public static function TARGETSWRITE(): Scopes + { + if (!isset(self::$TARGETSWRITE)) { + self::$TARGETSWRITE = new Scopes('targets.write'); + } + return self::$TARGETSWRITE; + } + public static function RULESREAD(): Scopes + { + if (!isset(self::$RULESREAD)) { + self::$RULESREAD = new Scopes('rules.read'); + } + return self::$RULESREAD; + } + public static function RULESWRITE(): Scopes + { + if (!isset(self::$RULESWRITE)) { + self::$RULESWRITE = new Scopes('rules.write'); + } + return self::$RULESWRITE; + } + public static function MIGRATIONSREAD(): Scopes + { + if (!isset(self::$MIGRATIONSREAD)) { + self::$MIGRATIONSREAD = new Scopes('migrations.read'); + } + return self::$MIGRATIONSREAD; + } + public static function MIGRATIONSWRITE(): Scopes + { + if (!isset(self::$MIGRATIONSWRITE)) { + self::$MIGRATIONSWRITE = new Scopes('migrations.write'); + } + return self::$MIGRATIONSWRITE; + } + public static function VCSREAD(): Scopes + { + if (!isset(self::$VCSREAD)) { + self::$VCSREAD = new Scopes('vcs.read'); + } + return self::$VCSREAD; + } + public static function VCSWRITE(): Scopes + { + if (!isset(self::$VCSWRITE)) { + self::$VCSWRITE = new Scopes('vcs.write'); + } + return self::$VCSWRITE; + } + public static function ASSISTANTREAD(): Scopes + { + if (!isset(self::$ASSISTANTREAD)) { + self::$ASSISTANTREAD = new Scopes('assistant.read'); + } + return self::$ASSISTANTREAD; + } + public static function TOKENSREAD(): Scopes + { + if (!isset(self::$TOKENSREAD)) { + self::$TOKENSREAD = new Scopes('tokens.read'); + } + return self::$TOKENSREAD; + } + public static function TOKENSWRITE(): Scopes + { + if (!isset(self::$TOKENSWRITE)) { + self::$TOKENSWRITE = new Scopes('tokens.write'); + } + return self::$TOKENSWRITE; + } +} \ No newline at end of file diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index cb1b838..75586e6 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -338,6 +338,40 @@ public static function notEndsWith(string $attribute, string $value): string return (new Query('notEndsWith', $attribute, $value))->__toString(); } + /** + * Filter resources where attribute matches a regular expression pattern. + * + * @param string $attribute The attribute to filter on. + * @param string $pattern The regular expression pattern to match. + * @return string + */ + public static function regex(string $attribute, string $pattern): string + { + return (new Query('regex', $attribute, $pattern))->__toString(); + } + + /** + * Filter resources where the specified attributes exist. + * + * @param array $attributes The list of attributes that must exist. + * @return string + */ + public static function exists(array $attributes): string + { + return (new Query('exists', null, $attributes))->__toString(); + } + + /** + * Filter resources where the specified attributes do not exist. + * + * @param array $attributes The list of attributes that must not exist. + * @return string + */ + public static function notExists(array $attributes): string + { + return (new Query('notExists', null, $attributes))->__toString(); + } + /** * Created Before * @@ -434,6 +468,22 @@ public static function and(array $queries): string return (new Query('and', null, $queries))->__toString(); } + /** + * Filter array elements where at least one element matches all the specified queries. + * + * @param string $attribute The attribute containing the array to filter on. + * @param array $queries The list of query strings to match against array elements. + * @return string + */ + public static function elemMatch(string $attribute, array $queries): string + { + foreach ($queries as &$query) { + $query = \json_decode($query, true); + } + + return (new Query('elemMatch', $attribute, $queries))->__toString(); + } + /** * Distance Equal * diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index cfb1b34..c9d6b77 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -197,10 +197,11 @@ public function deleteIdentity(string $identityId): string * from its creation and will be invalid if the user will logout in that time * frame. * + * @param ?int $duration * @throws AppwriteException * @return array */ - public function createJWT(): array + public function createJWT(?int $duration = null): array { $apiPath = str_replace( [], @@ -210,6 +211,10 @@ public function createJWT(): array $apiParams = []; + if (!is_null($duration)) { + $apiParams['duration'] = $duration; + } + $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; diff --git a/src/Appwrite/Services/Avatars.php b/src/Appwrite/Services/Avatars.php index 4b5dfb7..86e29d9 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -11,7 +11,8 @@ use Appwrite\Enums\Flag; use Appwrite\Enums\Theme; use Appwrite\Enums\Timezone; -use Appwrite\Enums\Output; +use Appwrite\Enums\BrowserPermission; +use Appwrite\Enums\ImageFormat; class Avatars extends Service { @@ -391,11 +392,11 @@ public function getQR(string $text, ?int $size = null, ?int $margin = null, ?boo * @param ?int $width * @param ?int $height * @param ?int $quality - * @param ?Output $output + * @param ?ImageFormat $output * @throws AppwriteException * @return string */ - public function getScreenshot(string $url, ?array $headers = null, ?int $viewportWidth = null, ?int $viewportHeight = null, ?float $scale = null, ?Theme $theme = null, ?string $userAgent = null, ?bool $fullpage = null, ?string $locale = null, ?Timezone $timezone = null, ?float $latitude = null, ?float $longitude = null, ?float $accuracy = null, ?bool $touch = null, ?array $permissions = null, ?int $sleep = null, ?int $width = null, ?int $height = null, ?int $quality = null, ?Output $output = null): string + public function getScreenshot(string $url, ?array $headers = null, ?int $viewportWidth = null, ?int $viewportHeight = null, ?float $scale = null, ?Theme $theme = null, ?string $userAgent = null, ?bool $fullpage = null, ?string $locale = null, ?Timezone $timezone = null, ?float $latitude = null, ?float $longitude = null, ?float $accuracy = null, ?bool $touch = null, ?array $permissions = null, ?int $sleep = null, ?int $width = null, ?int $height = null, ?int $quality = null, ?ImageFormat $output = null): string { $apiPath = str_replace( [], diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index e9796fa..770d786 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -9,6 +9,7 @@ use Appwrite\Enums\RelationshipType; use Appwrite\Enums\RelationMutate; use Appwrite\Enums\IndexType; +use Appwrite\Enums\OrderBy; class Databases extends Service { @@ -331,7 +332,7 @@ public function get(string $databaseId): array * Update a database by its unique ID. * * @param string $databaseId - * @param string $name + * @param ?string $name * @param ?bool $enabled * @throws AppwriteException * @return array @@ -339,7 +340,7 @@ public function get(string $databaseId): array * @deprecated This API has been deprecated since 1.8.0. Please use `update` instead. * @see TablesDB::update */ - public function update(string $databaseId, string $name, ?bool $enabled = null): array + public function update(string $databaseId, ?string $name = null, ?bool $enabled = null): array { $apiPath = str_replace( ['{databaseId}'], @@ -349,7 +350,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null): $apiParams = []; $apiParams['databaseId'] = $databaseId; - $apiParams['name'] = $name; + + if (!is_null($name)) { + $apiParams['name'] = $name; + } if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; @@ -546,7 +550,7 @@ public function getCollection(string $databaseId, string $collectionId): array * * @param string $databaseId * @param string $collectionId - * @param string $name + * @param ?string $name * @param ?array $permissions * @param ?bool $documentSecurity * @param ?bool $enabled @@ -556,7 +560,7 @@ public function getCollection(string $databaseId, string $collectionId): array * @deprecated This API has been deprecated since 1.8.0. Please use `updateTable` instead. * @see TablesDB::updateTable */ - public function updateCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): array + public function updateCollection(string $databaseId, string $collectionId, ?string $name = null, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -567,7 +571,10 @@ public function updateCollection(string $databaseId, string $collectionId, strin $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['collectionId'] = $collectionId; - $apiParams['name'] = $name; + + if (!is_null($name)) { + $apiParams['name'] = $name; + } $apiParams['permissions'] = $permissions; if (!is_null($documentSecurity)) { @@ -2244,7 +2251,7 @@ public function getDocument(string $databaseId, string $collectionId, string $do * @param string $databaseId * @param string $collectionId * @param string $documentId - * @param array $data + * @param ?array $data * @param ?array $permissions * @param ?string $transactionId * @throws AppwriteException @@ -2253,7 +2260,7 @@ public function getDocument(string $databaseId, string $collectionId, string $do * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRow` instead. * @see TablesDB::upsertRow */ - public function upsertDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null, ?string $transactionId = null): array + public function upsertDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null, ?string $transactionId = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], @@ -2265,7 +2272,10 @@ public function upsertDocument(string $databaseId, string $collectionId, string $apiParams['databaseId'] = $databaseId; $apiParams['collectionId'] = $collectionId; $apiParams['documentId'] = $documentId; - $apiParams['data'] = $data; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } $apiParams['permissions'] = $permissions; $apiParams['transactionId'] = $transactionId; diff --git a/src/Appwrite/Services/Functions.php b/src/Appwrite/Services/Functions.php index 0279cb7..561adab 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -7,6 +7,7 @@ use Appwrite\Service; use Appwrite\InputFile; use Appwrite\Enums\Runtime; +use Appwrite\Enums\Scopes; use Appwrite\Enums\TemplateReferenceType; use Appwrite\Enums\VCSReferenceType; use Appwrite\Enums\DeploymentDownloadType; @@ -485,7 +486,7 @@ public function listDeployments(string $functionId, ?array $queries = null, ?str * @throws AppwriteException * @return array */ - public function createDeployment(string $functionId, InputFile $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, callable $onProgress = null): array + public function createDeployment(string $functionId, InputFile $code, bool $activate, ?string $entrypoint = null, ?string $commands = null, ?callable $onProgress = null): array { $apiPath = str_replace( ['{functionId}'], @@ -552,7 +553,7 @@ public function createDeployment(string $functionId, InputFile $code, bool $acti fseek($handle, $start); $chunk = @fread($handle, Client::CHUNK_SIZE); } else { - $chunk = substr($file->getData(), $start, Client::CHUNK_SIZE); + $chunk = substr($code->getData(), $start, Client::CHUNK_SIZE); } $apiParams['code'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($chunk), $mimeType, $postedName); $apiHeaders['content-range'] = 'bytes ' . ($counter * Client::CHUNK_SIZE) . '-' . min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE) - 1), $size - 1) . '/' . $size; diff --git a/src/Appwrite/Services/Health.php b/src/Appwrite/Services/Health.php index 86183b4..c4a694b 100644 --- a/src/Appwrite/Services/Health.php +++ b/src/Appwrite/Services/Health.php @@ -177,6 +177,38 @@ public function getPubSub(): array ); } + /** + * Get the number of audit logs that are waiting to be processed in the + * Appwrite internal queue server. + * + * @param ?int $threshold + * @throws AppwriteException + * @return array + */ + public function getQueueAudits(?int $threshold = null): array + { + $apiPath = str_replace( + [], + [], + '/health/queue/audits' + ); + + $apiParams = []; + + if (!is_null($threshold)) { + $apiParams['threshold'] = $threshold; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get the number of builds that are waiting to be processed in the Appwrite * internal queue server. diff --git a/src/Appwrite/Services/Sites.php b/src/Appwrite/Services/Sites.php index cabd1a6..50788f9 100644 --- a/src/Appwrite/Services/Sites.php +++ b/src/Appwrite/Services/Sites.php @@ -475,7 +475,7 @@ public function listDeployments(string $siteId, ?array $queries = null, ?string * @throws AppwriteException * @return array */ - public function createDeployment(string $siteId, InputFile $code, bool $activate, ?string $installCommand = null, ?string $buildCommand = null, ?string $outputDirectory = null, callable $onProgress = null): array + public function createDeployment(string $siteId, InputFile $code, bool $activate, ?string $installCommand = null, ?string $buildCommand = null, ?string $outputDirectory = null, ?callable $onProgress = null): array { $apiPath = str_replace( ['{siteId}'], @@ -546,7 +546,7 @@ public function createDeployment(string $siteId, InputFile $code, bool $activate fseek($handle, $start); $chunk = @fread($handle, Client::CHUNK_SIZE); } else { - $chunk = substr($file->getData(), $start, Client::CHUNK_SIZE); + $chunk = substr($code->getData(), $start, Client::CHUNK_SIZE); } $apiParams['code'] = new \CURLFile('data://' . $mimeType . ';base64,' . base64_encode($chunk), $mimeType, $postedName); $apiHeaders['content-range'] = 'bytes ' . ($counter * Client::CHUNK_SIZE) . '-' . min(((($counter * Client::CHUNK_SIZE) + Client::CHUNK_SIZE) - 1), $size - 1) . '/' . $size; diff --git a/src/Appwrite/Services/Storage.php b/src/Appwrite/Services/Storage.php index 67a7611..199cd61 100644 --- a/src/Appwrite/Services/Storage.php +++ b/src/Appwrite/Services/Storage.php @@ -334,7 +334,7 @@ public function listFiles(string $bucketId, ?array $queries = null, ?string $sea * @throws AppwriteException * @return array */ - public function createFile(string $bucketId, string $fileId, InputFile $file, ?array $permissions = null, callable $onProgress = null): array + public function createFile(string $bucketId, string $fileId, InputFile $file, ?array $permissions = null, ?callable $onProgress = null): array { $apiPath = str_replace( ['{bucketId}'], @@ -485,7 +485,10 @@ public function updateFile(string $bucketId, string $fileId, ?string $name = nul $apiParams = []; $apiParams['bucketId'] = $bucketId; $apiParams['fileId'] = $fileId; - $apiParams['name'] = $name; + + if (!is_null($name)) { + $apiParams['name'] = $name; + } $apiParams['permissions'] = $permissions; $apiHeaders = []; diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php index a7fd576..e5799e1 100644 --- a/src/Appwrite/Services/TablesDB.php +++ b/src/Appwrite/Services/TablesDB.php @@ -9,6 +9,7 @@ use Appwrite\Enums\RelationshipType; use Appwrite\Enums\RelationMutate; use Appwrite\Enums\IndexType; +use Appwrite\Enums\OrderBy; class TablesDB extends Service { @@ -322,12 +323,12 @@ public function get(string $databaseId): array * Update a database by its unique ID. * * @param string $databaseId - * @param string $name + * @param ?string $name * @param ?bool $enabled * @throws AppwriteException * @return array */ - public function update(string $databaseId, string $name, ?bool $enabled = null): array + public function update(string $databaseId, ?string $name = null, ?bool $enabled = null): array { $apiPath = str_replace( ['{databaseId}'], @@ -337,7 +338,10 @@ public function update(string $databaseId, string $name, ?bool $enabled = null): $apiParams = []; $apiParams['databaseId'] = $databaseId; - $apiParams['name'] = $name; + + if (!is_null($name)) { + $apiParams['name'] = $name; + } if (!is_null($enabled)) { $apiParams['enabled'] = $enabled; @@ -522,14 +526,14 @@ public function getTable(string $databaseId, string $tableId): array * * @param string $databaseId * @param string $tableId - * @param string $name + * @param ?string $name * @param ?array $permissions * @param ?bool $rowSecurity * @param ?bool $enabled * @throws AppwriteException * @return array */ - public function updateTable(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array + public function updateTable(string $databaseId, string $tableId, ?string $name = null, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -540,7 +544,10 @@ public function updateTable(string $databaseId, string $tableId, string $name, ? $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['tableId'] = $tableId; - $apiParams['name'] = $name; + + if (!is_null($name)) { + $apiParams['name'] = $name; + } $apiParams['permissions'] = $permissions; if (!is_null($rowSecurity)) { diff --git a/src/Appwrite/Services/Teams.php b/src/Appwrite/Services/Teams.php index 3f3480e..99c5226 100644 --- a/src/Appwrite/Services/Teams.php +++ b/src/Appwrite/Services/Teams.php @@ -6,6 +6,7 @@ use Appwrite\Client; use Appwrite\Service; use Appwrite\InputFile; +use Appwrite\Enums\Roles; class Teams extends Service { diff --git a/tests/Appwrite/IDTest.php b/tests/Appwrite/IDTest.php index 4914377..b12e817 100644 --- a/tests/Appwrite/IDTest.php +++ b/tests/Appwrite/IDTest.php @@ -6,7 +6,8 @@ final class IDTest extends TestCase { public function testUnique(): void { - $this->assertSame('unique()', ID::unique()); + $id = ID::unique(); + $this->assertSame(20, strlen($id)); } public function testCustom(): void { diff --git a/tests/Appwrite/QueryTest.php b/tests/Appwrite/QueryTest.php index 283a867..6b4cd6c 100644 --- a/tests/Appwrite/QueryTest.php +++ b/tests/Appwrite/QueryTest.php @@ -37,169 +37,290 @@ function __construct(string $name) public function testBasicFilterEqual(): void { foreach($this->tests as $test) { - $this->assertSame( - "equal(\"attr\", $test->expectedValues)", - Query::equal('attr', $test->value), - $test->description, - ); + $query = json_decode(Query::equal('attr', $test->value), true); + $expected = json_decode($test->expectedValues, true); + $this->assertSame('attr', $query['attribute'], $test->description); + $this->assertSame($expected, $query['values'], $test->description); + $this->assertSame('equal', $query['method'], $test->description); } } public function testBasicFilterNotEqual(): void { foreach($this->tests as $test) { - $this->assertSame( - "notEqual(\"attr\", $test->expectedValues)", - Query::notEqual('attr', $test->value), - $test->description, - ); + $query = json_decode(Query::notEqual('attr', $test->value), true); + $expected = json_decode($test->expectedValues, true); + $this->assertSame('attr', $query['attribute'], $test->description); + $this->assertSame($expected, $query['values'], $test->description); + $this->assertSame('notEqual', $query['method'], $test->description); } } public function testBasicFilterLessThan(): void { foreach($this->tests as $test) { - $this->assertSame( - "lessThan(\"attr\", $test->expectedValues)", - Query::lessThan('attr', $test->value), - $test->description, - ); + $query = json_decode(Query::lessThan('attr', $test->value), true); + $expected = json_decode($test->expectedValues, true); + $this->assertSame('attr', $query['attribute'], $test->description); + $this->assertSame($expected, $query['values'], $test->description); + $this->assertSame('lessThan', $query['method'], $test->description); } } public function testBasicFilterLessThanEqual(): void { foreach($this->tests as $test) { - $this->assertSame( - "lessThanEqual(\"attr\", $test->expectedValues)", - Query::lessThanEqual('attr', $test->value), - $test->description, - ); + $query = json_decode(Query::lessThanEqual('attr', $test->value), true); + $expected = json_decode($test->expectedValues, true); + $this->assertSame('attr', $query['attribute'], $test->description); + $this->assertSame($expected, $query['values'], $test->description); + $this->assertSame('lessThanEqual', $query['method'], $test->description); } } public function testBasicFilterGreaterThan(): void { foreach($this->tests as $test) { - $this->assertSame( - "greaterThan(\"attr\", $test->expectedValues)", - Query::greaterThan('attr', $test->value), - $test->description, - ); + $query = json_decode(Query::greaterThan('attr', $test->value), true); + $expected = json_decode($test->expectedValues, true); + $this->assertSame('attr', $query['attribute'], $test->description); + $this->assertSame($expected, $query['values'], $test->description); + $this->assertSame('greaterThan', $query['method'], $test->description); } } public function testBasicFilterGreaterThanEqual(): void { foreach($this->tests as $test) { - $this->assertSame( - "greaterThanEqual(\"attr\", $test->expectedValues)", - Query::greaterThanEqual('attr', $test->value), - $test->description, - ); + $query = json_decode(Query::greaterThanEqual('attr', $test->value), true); + $expected = json_decode($test->expectedValues, true); + $this->assertSame('attr', $query['attribute'], $test->description); + $this->assertSame($expected, $query['values'], $test->description); + $this->assertSame('greaterThanEqual', $query['method'], $test->description); } } public function testSearch(): void { - $this->assertSame('search("attr", ["keyword1 keyword2"])', Query::search('attr', 'keyword1 keyword2')); + $query = json_decode(Query::search('attr', 'keyword1 keyword2'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame(['keyword1 keyword2'], $query['values']); + $this->assertSame('search', $query['method']); } public function testIsNull(): void { - $this->assertSame('isNull("attr")', Query::isNull('attr')); + $query = json_decode(Query::isNull('attr'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertNull($query['values'] ?? null); + $this->assertSame('isNull', $query['method']); } public function testIsNotNull(): void { - $this->assertSame('isNotNull("attr")', Query::isNotNull('attr')); + $query = json_decode(Query::isNotNull('attr'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertNull($query['values'] ?? null); + $this->assertSame('isNotNull', $query['method']); } public function testBetweenWithIntegers(): void { - $this->assertSame('between("attr", 1, 2)', Query::between('attr', 1, 2)); + $query = json_decode(Query::between('attr', 1, 2), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame([1, 2], $query['values']); + $this->assertSame('between', $query['method']); } public function testBetweenWithDoubles(): void { - $this->assertSame('between("attr", 1, 2)', Query::between('attr', 1.0, 2.0)); + $query = json_decode(Query::between('attr', 1.0, 2.0), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame([1, 2], $query['values']); + $this->assertSame('between', $query['method']); } public function testBetweenWithStrings(): void { - $this->assertSame('between("attr", "a", "z")', Query::between('attr', 'a', 'z')); + $query = json_decode(Query::between('attr', 'a', 'z'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame(['a', 'z'], $query['values']); + $this->assertSame('between', $query['method']); } public function testSelect(): void { - $this->assertSame('select(["attr1","attr2"])', Query::select(['attr1', 'attr2'])); + $query = json_decode(Query::select(['attr1', 'attr2']), true); + $this->assertNull($query['attribute'] ?? null); + $this->assertSame(['attr1', 'attr2'], $query['values']); + $this->assertSame('select', $query['method']); } public function testOrderAsc(): void { - $this->assertSame('orderAsc("attr")', Query::orderAsc('attr')); + $query = json_decode(Query::orderAsc('attr'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertNull($query['values'] ?? null); + $this->assertSame('orderAsc', $query['method']); } public function testOrderDesc(): void { - $this->assertSame('orderDesc("attr")', Query::orderDesc('attr')); + $query = json_decode(Query::orderDesc('attr'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertNull($query['values'] ?? null); + $this->assertSame('orderDesc', $query['method']); } public function testOrderRandom(): void { - $this->assertSame('{"method":"orderRandom"}', Query::orderRandom()); + $query = json_decode(Query::orderRandom(), true); + $this->assertNull($query['attribute'] ?? null); + $this->assertNull($query['values'] ?? null); + $this->assertSame('orderRandom', $query['method']); } public function testCursorBefore(): void { - $this->assertSame('cursorBefore("attr")', Query::cursorBefore('attr')); + $query = json_decode(Query::cursorBefore('attr'), true); + $this->assertNull($query['attribute'] ?? null); + $this->assertSame(['attr'], $query['values']); + $this->assertSame('cursorBefore', $query['method']); } public function testCursorAfter(): void { - $this->assertSame('cursorAfter("attr")', Query::cursorAfter('attr')); + $query = json_decode(Query::cursorAfter('attr'), true); + $this->assertNull($query['attribute'] ?? null); + $this->assertSame(['attr'], $query['values']); + $this->assertSame('cursorAfter', $query['method']); } public function testLimit(): void { - $this->assertSame('limit(1)', Query::limit(1)); + $query = json_decode(Query::limit(1), true); + $this->assertNull($query['attribute'] ?? null); + $this->assertSame([1], $query['values']); + $this->assertSame('limit', $query['method']); } public function testOffset(): void { - $this->assertSame('offset(1)', Query::offset(1)); + $query = json_decode(Query::offset(1), true); + $this->assertNull($query['attribute'] ?? null); + $this->assertSame([1], $query['values']); + $this->assertSame('offset', $query['method']); } public function testNotContains(): void { - $this->assertSame('notContains("attr", ["value"])', Query::notContains('attr', 'value')); + $query = json_decode(Query::notContains('attr', 'value'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame(['value'], $query['values']); + $this->assertSame('notContains', $query['method']); } public function testNotSearch(): void { - $this->assertSame('notSearch("attr", ["keyword1 keyword2"])', Query::notSearch('attr', 'keyword1 keyword2')); + $query = json_decode(Query::notSearch('attr', 'keyword1 keyword2'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame(['keyword1 keyword2'], $query['values']); + $this->assertSame('notSearch', $query['method']); } public function testNotBetweenWithIntegers(): void { - $this->assertSame('notBetween("attr", 1, 2)', Query::notBetween('attr', 1, 2)); + $query = json_decode(Query::notBetween('attr', 1, 2), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame([1, 2], $query['values']); + $this->assertSame('notBetween', $query['method']); } public function testNotBetweenWithDoubles(): void { - $this->assertSame('notBetween("attr", 1, 2)', Query::notBetween('attr', 1.0, 2.0)); + $query = json_decode(Query::notBetween('attr', 1.0, 2.0), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame([1, 2], $query['values']); + $this->assertSame('notBetween', $query['method']); } public function testNotBetweenWithStrings(): void { - $this->assertSame('notBetween("attr", "a", "z")', Query::notBetween('attr', 'a', 'z')); + $query = json_decode(Query::notBetween('attr', 'a', 'z'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame(['a', 'z'], $query['values']); + $this->assertSame('notBetween', $query['method']); } public function testNotStartsWith(): void { - $this->assertSame('notStartsWith("attr", ["prefix"])', Query::notStartsWith('attr', 'prefix')); + $query = json_decode(Query::notStartsWith('attr', 'prefix'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame(['prefix'], $query['values']); + $this->assertSame('notStartsWith', $query['method']); } public function testNotEndsWith(): void { - $this->assertSame('notEndsWith("attr", ["suffix"])', Query::notEndsWith('attr', 'suffix')); + $query = json_decode(Query::notEndsWith('attr', 'suffix'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame(['suffix'], $query['values']); + $this->assertSame('notEndsWith', $query['method']); + } + + public function testRegex(): void { + $query = json_decode(Query::regex('attr', 'pattern.*'), true); + $this->assertSame('attr', $query['attribute']); + $this->assertSame(['pattern.*'], $query['values']); + $this->assertSame('regex', $query['method']); + } + + public function testExists(): void { + $query = json_decode(Query::exists(['attr1', 'attr2']), true); + $this->assertNull($query['attribute'] ?? null); + $this->assertSame(['attr1', 'attr2'], $query['values']); + $this->assertSame('exists', $query['method']); + } + + public function testNotExists(): void { + $query = json_decode(Query::notExists(['attr1', 'attr2']), true); + $this->assertNull($query['attribute'] ?? null); + $this->assertSame(['attr1', 'attr2'], $query['values']); + $this->assertSame('notExists', $query['method']); + } + + public function testElemMatch(): void { + $inner1 = Query::equal('name', 'Alice'); + $inner2 = Query::greaterThan('age', 18); + + $query = json_decode(Query::elemMatch('friends', [$inner1, $inner2]), true); + + $this->assertSame('friends', $query['attribute']); + $this->assertSame('elemMatch', $query['method']); + $this->assertCount(2, $query['values']); + + $this->assertSame('equal', $query['values'][0]['method']); + $this->assertSame('name', $query['values'][0]['attribute']); + $this->assertSame(['Alice'], $query['values'][0]['values']); + + $this->assertSame('greaterThan', $query['values'][1]['method']); + $this->assertSame('age', $query['values'][1]['attribute']); + $this->assertSame([18], $query['values'][1]['values']); } public function testCreatedBefore(): void { - $this->assertSame('lessThan("$createdAt", ["2023-01-01"])', Query::createdBefore('2023-01-01')); + $query = json_decode(Query::createdBefore('2023-01-01'), true); + $this->assertSame('$createdAt', $query['attribute']); + $this->assertSame(['2023-01-01'], $query['values']); + $this->assertSame('lessThan', $query['method']); } public function testCreatedAfter(): void { - $this->assertSame('greaterThan("$createdAt", ["2023-01-01"])', Query::createdAfter('2023-01-01')); + $query = json_decode(Query::createdAfter('2023-01-01'), true); + $this->assertSame('$createdAt', $query['attribute']); + $this->assertSame(['2023-01-01'], $query['values']); + $this->assertSame('greaterThan', $query['method']); } public function testCreatedBetween(): void { - $this->assertSame('between("$createdAt", ["2023-01-01","2023-12-31"])', Query::createdBetween('2023-01-01', '2023-12-31')); + $query = json_decode(Query::createdBetween('2023-01-01', '2023-12-31'), true); + $this->assertSame('$createdAt', $query['attribute']); + $this->assertSame(['2023-01-01', '2023-12-31'], $query['values']); + $this->assertSame('between', $query['method']); } public function testUpdatedBefore(): void { - $this->assertSame('lessThan("$updatedAt", ["2023-01-01"])', Query::updatedBefore('2023-01-01')); + $query = json_decode(Query::updatedBefore('2023-01-01'), true); + $this->assertSame('$updatedAt', $query['attribute']); + $this->assertSame(['2023-01-01'], $query['values']); + $this->assertSame('lessThan', $query['method']); } public function testUpdatedAfter(): void { - $this->assertSame('greaterThan("$updatedAt", ["2023-01-01"])', Query::updatedAfter('2023-01-01')); + $query = json_decode(Query::updatedAfter('2023-01-01'), true); + $this->assertSame('$updatedAt', $query['attribute']); + $this->assertSame(['2023-01-01'], $query['values']); + $this->assertSame('greaterThan', $query['method']); } public function testUpdatedBetween(): void { - $this->assertSame('between("$updatedAt", ["2023-01-01","2023-12-31"])', Query::updatedBetween('2023-01-01', '2023-12-31')); + $query = json_decode(Query::updatedBetween('2023-01-01', '2023-12-31'), true); + $this->assertSame('$updatedAt', $query['attribute']); + $this->assertSame(['2023-01-01', '2023-12-31'], $query['values']); + $this->assertSame('between', $query['method']); } } diff --git a/tests/Appwrite/Services/AccountTest.php b/tests/Appwrite/Services/AccountTest.php index 28ced55..d38511b 100644 --- a/tests/Appwrite/Services/AccountTest.php +++ b/tests/Appwrite/Services/AccountTest.php @@ -6,6 +6,9 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\AuthenticatorType; +use Appwrite\Enums\AuthenticationFactor; +use Appwrite\Enums\OAuthProvider; final class AccountTest extends TestCase { private $client; @@ -34,8 +37,7 @@ public function testMethodGet(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -65,8 +67,7 @@ public function testMethodCreate(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -99,8 +100,7 @@ public function testMethodUpdateEmail(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -118,8 +118,7 @@ public function testMethodListIdentities(): void { $data = array( "total" => 5, - "identities" => array(),); - + "identities" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -135,7 +134,6 @@ public function testMethodDeleteIdentity(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -150,8 +148,7 @@ public function testMethodDeleteIdentity(): void { public function testMethodCreateJWT(): void { $data = array( - "jwt" => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",); - + "jwt" => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -167,8 +164,7 @@ public function testMethodListLogs(): void { $data = array( "total" => 5, - "logs" => array(),); - + "logs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -198,8 +194,7 @@ public function testMethodUpdateMFA(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -216,15 +211,14 @@ public function testMethodCreateMFAAuthenticator(): void { $data = array( "secret" => "1", - "uri" => "1",); - + "uri" => "1"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->account->createMFAAuthenticator( - "totp" + AuthenticatorType::TOTP() ); $this->assertSame($data, $response); @@ -248,15 +242,14 @@ public function testMethodUpdateMFAAuthenticator(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->account->updateMFAAuthenticator( - "totp", + AuthenticatorType::TOTP(), "" ); @@ -267,13 +260,12 @@ public function testMethodDeleteMFAAuthenticator(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->account->deleteMFAAuthenticator( - "totp" + AuthenticatorType::TOTP() ); $this->assertSame($data, $response); @@ -285,15 +277,14 @@ public function testMethodCreateMFAChallenge(): void { "\$id" => "bb8ea5c16897e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "userId" => "5e5ea5c168bb8", - "expire" => "2020-10-15T06:38:00.000+00:00",); - + "expire" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->account->createMFAChallenge( - "email" + AuthenticationFactor::EMAIL() ); $this->assertSame($data, $response); @@ -330,8 +321,7 @@ public function testMethodUpdateMFAChallenge(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -351,8 +341,7 @@ public function testMethodListMFAFactors(): void { "totp" => true, "phone" => true, "email" => true, - "recoveryCode" => true,); - + "recoveryCode" => true); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -367,8 +356,7 @@ public function testMethodListMFAFactors(): void { public function testMethodGetMFARecoveryCodes(): void { $data = array( - "recoveryCodes" => array(),); - + "recoveryCodes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -383,8 +371,7 @@ public function testMethodGetMFARecoveryCodes(): void { public function testMethodCreateMFARecoveryCodes(): void { $data = array( - "recoveryCodes" => array(),); - + "recoveryCodes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -399,8 +386,7 @@ public function testMethodCreateMFARecoveryCodes(): void { public function testMethodUpdateMFARecoveryCodes(): void { $data = array( - "recoveryCodes" => array(),); - + "recoveryCodes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -430,8 +416,7 @@ public function testMethodUpdateName(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -462,8 +447,7 @@ public function testMethodUpdatePassword(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -494,8 +478,7 @@ public function testMethodUpdatePhone(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -513,7 +496,6 @@ public function testMethodGetPrefs(): void { $data = array(); - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -542,8 +524,7 @@ public function testMethodUpdatePrefs(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -564,8 +545,7 @@ public function testMethodCreateRecovery(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -587,8 +567,7 @@ public function testMethodUpdateRecovery(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -607,8 +586,7 @@ public function testMethodListSessions(): void { $data = array( "total" => 5, - "sessions" => array(),); - + "sessions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -624,7 +602,6 @@ public function testMethodDeleteSessions(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -666,8 +643,7 @@ public function testMethodCreateAnonymousSession(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -710,8 +686,7 @@ public function testMethodCreateEmailPasswordSession(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -756,8 +731,7 @@ public function testMethodUpdateMagicURLSession(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -802,8 +776,7 @@ public function testMethodUpdatePhoneSession(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -848,8 +821,7 @@ public function testMethodCreateSession(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -894,8 +866,7 @@ public function testMethodGetSession(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -939,8 +910,7 @@ public function testMethodUpdateSession(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -957,7 +927,6 @@ public function testMethodDeleteSession(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -987,8 +956,7 @@ public function testMethodUpdateStatus(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1008,8 +976,7 @@ public function testMethodCreateEmailToken(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1031,8 +998,7 @@ public function testMethodCreateMagicURLToken(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1048,15 +1014,14 @@ public function testMethodCreateMagicURLToken(): void { public function testMethodCreateOAuth2Token(): void { - $data = array(); - + $data = ''; $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->account->createOAuth2Token( - "amazon" + OAuthProvider::AMAZON() ); $this->assertSame($data, $response); @@ -1070,8 +1035,7 @@ public function testMethodCreatePhoneToken(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1093,8 +1057,7 @@ public function testMethodCreateEmailVerification(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1115,8 +1078,7 @@ public function testMethodCreateVerification(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1137,8 +1099,7 @@ public function testMethodUpdateEmailVerification(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1160,8 +1121,7 @@ public function testMethodUpdateVerification(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1183,8 +1143,7 @@ public function testMethodCreatePhoneVerification(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1204,8 +1163,7 @@ public function testMethodUpdatePhoneVerification(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) diff --git a/tests/Appwrite/Services/AvatarsTest.php b/tests/Appwrite/Services/AvatarsTest.php index ece3c24..4b75f42 100644 --- a/tests/Appwrite/Services/AvatarsTest.php +++ b/tests/Appwrite/Services/AvatarsTest.php @@ -6,6 +6,13 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\Browser; +use Appwrite\Enums\CreditCard; +use Appwrite\Enums\Flag; +use Appwrite\Enums\Theme; +use Appwrite\Enums\Timezone; +use Appwrite\Enums\BrowserPermission; +use Appwrite\Enums\ImageFormat; final class AvatarsTest extends TestCase { private $client; @@ -20,13 +27,12 @@ public function testMethodGetBrowser(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->avatars->getBrowser( - "aa" + Browser::AVANTBROWSER() ); $this->assertSame($data, $response); @@ -36,13 +42,12 @@ public function testMethodGetCreditCard(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->avatars->getCreditCard( - "amex" + CreditCard::AMERICANEXPRESS() ); $this->assertSame($data, $response); @@ -52,7 +57,6 @@ public function testMethodGetFavicon(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -68,13 +72,12 @@ public function testMethodGetFlag(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->avatars->getFlag( - "af" + Flag::AFGHANISTAN() ); $this->assertSame($data, $response); @@ -84,7 +87,6 @@ public function testMethodGetImage(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -100,7 +102,6 @@ public function testMethodGetInitials(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -115,7 +116,6 @@ public function testMethodGetQR(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -131,7 +131,6 @@ public function testMethodGetScreenshot(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index 8aa6a6b..53c64b6 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -6,6 +6,10 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\RelationshipType; +use Appwrite\Enums\RelationMutate; +use Appwrite\Enums\IndexType; +use Appwrite\Enums\OrderBy; final class DatabasesTest extends TestCase { private $client; @@ -20,8 +24,7 @@ public function testMethodList(): void { $data = array( "total" => 5, - "databases" => array(),); - + "databases" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -41,8 +44,7 @@ public function testMethodCreate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy",); - + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -60,8 +62,7 @@ public function testMethodListTransactions(): void { $data = array( "total" => 5, - "transactions" => array(),); - + "transactions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -81,8 +82,7 @@ public function testMethodCreateTransaction(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "status" => "pending", "operations" => 5, - "expiresAt" => "2020-10-15T06:38:00.000+00:00",); - + "expiresAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -102,8 +102,7 @@ public function testMethodGetTransaction(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "status" => "pending", "operations" => 5, - "expiresAt" => "2020-10-15T06:38:00.000+00:00",); - + "expiresAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -124,8 +123,7 @@ public function testMethodUpdateTransaction(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "status" => "pending", "operations" => 5, - "expiresAt" => "2020-10-15T06:38:00.000+00:00",); - + "expiresAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -142,7 +140,6 @@ public function testMethodDeleteTransaction(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -162,8 +159,7 @@ public function testMethodCreateOperations(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "status" => "pending", "operations" => 5, - "expiresAt" => "2020-10-15T06:38:00.000+00:00",); - + "expiresAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -184,8 +180,7 @@ public function testMethodGet(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy",); - + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -206,16 +201,14 @@ public function testMethodUpdate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy",); - + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->databases->update( - "", - "" + "" ); $this->assertSame($data, $response); @@ -225,7 +218,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -241,8 +233,7 @@ public function testMethodListCollections(): void { $data = array( "total" => 5, - "collections" => array(),); - + "collections" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -267,8 +258,7 @@ public function testMethodCreateCollection(): void { "enabled" => true, "documentSecurity" => true, "attributes" => array(), - "indexes" => array(),); - + "indexes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -295,8 +285,7 @@ public function testMethodGetCollection(): void { "enabled" => true, "documentSecurity" => true, "attributes" => array(), - "indexes" => array(),); - + "indexes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -322,8 +311,7 @@ public function testMethodUpdateCollection(): void { "enabled" => true, "documentSecurity" => true, "attributes" => array(), - "indexes" => array(),); - + "indexes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -331,8 +319,7 @@ public function testMethodUpdateCollection(): void { $response = $this->databases->updateCollection( "", - "", - "" + "" ); $this->assertSame($data, $response); @@ -342,7 +329,6 @@ public function testMethodDeleteCollection(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -359,8 +345,7 @@ public function testMethodListAttributes(): void { $data = array( "total" => 5, - "attributes" => array(),); - + "attributes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -383,8 +368,7 @@ public function testMethodCreateBooleanAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -409,8 +393,7 @@ public function testMethodUpdateBooleanAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -437,8 +420,7 @@ public function testMethodCreateDatetimeAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "datetime",); - + "format" => "datetime"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -464,8 +446,7 @@ public function testMethodUpdateDatetimeAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "datetime",); - + "format" => "datetime"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -492,8 +473,7 @@ public function testMethodCreateEmailAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "email",); - + "format" => "email"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -519,8 +499,7 @@ public function testMethodUpdateEmailAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "email",); - + "format" => "email"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -548,8 +527,7 @@ public function testMethodCreateEnumAttribute(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "elements" => array(), - "format" => "enum",); - + "format" => "enum"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -577,8 +555,7 @@ public function testMethodUpdateEnumAttribute(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "elements" => array(), - "format" => "enum",); - + "format" => "enum"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -605,8 +582,7 @@ public function testMethodCreateFloatAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -631,8 +607,7 @@ public function testMethodUpdateFloatAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -658,8 +633,7 @@ public function testMethodCreateIntegerAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -684,8 +658,7 @@ public function testMethodUpdateIntegerAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -712,8 +685,7 @@ public function testMethodCreateIpAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "ip",); - + "format" => "ip"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -739,8 +711,7 @@ public function testMethodUpdateIpAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "ip",); - + "format" => "ip"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -766,8 +737,7 @@ public function testMethodCreateLineAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -792,8 +762,7 @@ public function testMethodUpdateLineAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -818,8 +787,7 @@ public function testMethodCreatePointAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -844,8 +812,7 @@ public function testMethodUpdatePointAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -870,8 +837,7 @@ public function testMethodCreatePolygonAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -896,8 +862,7 @@ public function testMethodUpdatePolygonAttribute(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -928,8 +893,7 @@ public function testMethodCreateRelationshipAttribute(): void { "twoWay" => true, "twoWayKey" => "string", "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child",); - + "side" => "parent|child"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -939,7 +903,7 @@ public function testMethodCreateRelationshipAttribute(): void { "", "", "", - "oneToOne" + RelationshipType::ONETOONE() ); $this->assertSame($data, $response); @@ -955,8 +919,7 @@ public function testMethodCreateStringAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "size" => 128,); - + "size" => 128); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -983,8 +946,7 @@ public function testMethodUpdateStringAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "size" => 128,); - + "size" => 128); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1011,8 +973,7 @@ public function testMethodCreateUrlAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "url",); - + "format" => "url"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1038,8 +999,7 @@ public function testMethodUpdateUrlAttribute(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "url",); - + "format" => "url"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1058,8 +1018,14 @@ public function testMethodUpdateUrlAttribute(): void { public function testMethodGetAttribute(): void { - $data = ''; - + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1078,7 +1044,6 @@ public function testMethodDeleteAttribute(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1107,8 +1072,7 @@ public function testMethodUpdateRelationshipAttribute(): void { "twoWay" => true, "twoWayKey" => "string", "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child",); - + "side" => "parent|child"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1127,8 +1091,7 @@ public function testMethodListDocuments(): void { $data = array( "total" => 5, - "documents" => array(),); - + "documents" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1151,8 +1114,7 @@ public function testMethodCreateDocument(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1172,8 +1134,7 @@ public function testMethodCreateDocuments(): void { $data = array( "total" => 5, - "documents" => array(),); - + "documents" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1192,8 +1153,7 @@ public function testMethodUpsertDocuments(): void { $data = array( "total" => 5, - "documents" => array(),); - + "documents" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1212,8 +1172,7 @@ public function testMethodUpdateDocuments(): void { $data = array( "total" => 5, - "documents" => array(),); - + "documents" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1231,8 +1190,7 @@ public function testMethodDeleteDocuments(): void { $data = array( "total" => 5, - "documents" => array(),); - + "documents" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1255,8 +1213,7 @@ public function testMethodGetDocument(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1280,8 +1237,7 @@ public function testMethodUpsertDocument(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1290,8 +1246,7 @@ public function testMethodUpsertDocument(): void { $response = $this->databases->upsertDocument( "", "", - "", - array() + "" ); $this->assertSame($data, $response); @@ -1306,8 +1261,7 @@ public function testMethodUpdateDocument(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1326,7 +1280,6 @@ public function testMethodDeleteDocument(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1349,8 +1302,7 @@ public function testMethodDecrementDocumentAttribute(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1375,8 +1327,7 @@ public function testMethodIncrementDocumentAttribute(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1396,8 +1347,7 @@ public function testMethodListIndexes(): void { $data = array( "total" => 5, - "indexes" => array(),); - + "indexes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1422,8 +1372,7 @@ public function testMethodCreateIndex(): void { "status" => "available", "error" => "string", "attributes" => array(), - "lengths" => array(),); - + "lengths" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1433,7 +1382,7 @@ public function testMethodCreateIndex(): void { "", "", "", - "key", + IndexType::KEY(), array() ); @@ -1451,8 +1400,7 @@ public function testMethodGetIndex(): void { "status" => "available", "error" => "string", "attributes" => array(), - "lengths" => array(),); - + "lengths" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1471,7 +1419,6 @@ public function testMethodDeleteIndex(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index 9d034cf..9d468cd 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -6,6 +6,12 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\Runtime; +use Appwrite\Enums\Scopes; +use Appwrite\Enums\TemplateReferenceType; +use Appwrite\Enums\VCSReferenceType; +use Appwrite\Enums\DeploymentDownloadType; +use Appwrite\Enums\ExecutionMethod; final class FunctionsTest extends TestCase { private $client; @@ -20,8 +26,7 @@ public function testMethodList(): void { $data = array( "total" => 5, - "functions" => array(),); - + "functions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -63,8 +68,7 @@ public function testMethodCreate(): void { "providerBranch" => "main", "providerRootDirectory" => "functions/helloWorld", "providerSilentMode" => true, - "specification" => "s-1vcpu-512mb",); - + "specification" => "s-1vcpu-512mb"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -73,7 +77,7 @@ public function testMethodCreate(): void { $response = $this->functions->create( "", "", - "node-14.5" + Runtime::NODE145() ); $this->assertSame($data, $response); @@ -83,8 +87,7 @@ public function testMethodListRuntimes(): void { $data = array( "total" => 5, - "runtimes" => array(),); - + "runtimes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -100,8 +103,7 @@ public function testMethodListSpecifications(): void { $data = array( "total" => 5, - "specifications" => array(),); - + "specifications" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -143,8 +145,7 @@ public function testMethodGet(): void { "providerBranch" => "main", "providerRootDirectory" => "functions/helloWorld", "providerSilentMode" => true, - "specification" => "s-1vcpu-512mb",); - + "specification" => "s-1vcpu-512mb"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -187,8 +188,7 @@ public function testMethodUpdate(): void { "providerBranch" => "main", "providerRootDirectory" => "functions/helloWorld", "providerSilentMode" => true, - "specification" => "s-1vcpu-512mb",); - + "specification" => "s-1vcpu-512mb"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -206,7 +206,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -248,8 +247,7 @@ public function testMethodUpdateFunctionDeployment(): void { "providerBranch" => "main", "providerRootDirectory" => "functions/helloWorld", "providerSilentMode" => true, - "specification" => "s-1vcpu-512mb",); - + "specification" => "s-1vcpu-512mb"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -267,8 +265,7 @@ public function testMethodListDeployments(): void { $data = array( "total" => 5, - "deployments" => array(),); - + "deployments" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -310,8 +307,7 @@ public function testMethodCreateDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -355,8 +351,7 @@ public function testMethodCreateDuplicateDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -399,8 +394,7 @@ public function testMethodCreateTemplateDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -411,7 +405,7 @@ public function testMethodCreateTemplateDeployment(): void { "", "", "", - "commit", + TemplateReferenceType::COMMIT(), "" ); @@ -447,8 +441,7 @@ public function testMethodCreateVcsDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -456,7 +449,7 @@ public function testMethodCreateVcsDeployment(): void { $response = $this->functions->createVcsDeployment( "", - "branch", + VCSReferenceType::BRANCH(), "" ); @@ -492,8 +485,7 @@ public function testMethodGetDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -511,7 +503,6 @@ public function testMethodDeleteDeployment(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -528,7 +519,6 @@ public function testMethodGetDeploymentDownload(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -570,8 +560,7 @@ public function testMethodUpdateDeploymentStatus(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -589,8 +578,7 @@ public function testMethodListExecutions(): void { $data = array( "total" => 5, - "executions" => array(),); - + "executions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -622,8 +610,7 @@ public function testMethodCreateExecution(): void { "responseHeaders" => array(), "logs" => "", "errors" => "", - "duration" => 0.4,); - + "duration" => 0.4); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -655,8 +642,7 @@ public function testMethodGetExecution(): void { "responseHeaders" => array(), "logs" => "", "errors" => "", - "duration" => 0.4,); - + "duration" => 0.4); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -674,7 +660,6 @@ public function testMethodDeleteExecution(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -691,8 +676,7 @@ public function testMethodListVariables(): void { $data = array( "total" => 5, - "variables" => array(),); - + "variables" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -715,8 +699,7 @@ public function testMethodCreateVariable(): void { "value" => "myPa\$\$word1", "secret" => true, "resourceType" => "function", - "resourceId" => "myAwesomeFunction",); - + "resourceId" => "myAwesomeFunction"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -741,8 +724,7 @@ public function testMethodGetVariable(): void { "value" => "myPa\$\$word1", "secret" => true, "resourceType" => "function", - "resourceId" => "myAwesomeFunction",); - + "resourceId" => "myAwesomeFunction"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -766,8 +748,7 @@ public function testMethodUpdateVariable(): void { "value" => "myPa\$\$word1", "secret" => true, "resourceType" => "function", - "resourceId" => "myAwesomeFunction",); - + "resourceId" => "myAwesomeFunction"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -786,7 +767,6 @@ public function testMethodDeleteVariable(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/GraphqlTest.php b/tests/Appwrite/Services/GraphqlTest.php index 6c587b8..669edf9 100644 --- a/tests/Appwrite/Services/GraphqlTest.php +++ b/tests/Appwrite/Services/GraphqlTest.php @@ -20,7 +20,6 @@ public function testMethodQuery(): void { $data = array(); - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -36,7 +35,6 @@ public function testMethodMutation(): void { $data = array(); - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/HealthTest.php b/tests/Appwrite/Services/HealthTest.php index cf0f754..28c637c 100644 --- a/tests/Appwrite/Services/HealthTest.php +++ b/tests/Appwrite/Services/HealthTest.php @@ -6,6 +6,7 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\Name; final class HealthTest extends TestCase { private $client; @@ -21,8 +22,7 @@ public function testMethodGet(): void { $data = array( "name" => "database", "ping" => 128, - "status" => "pass",); - + "status" => "pass"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -38,8 +38,7 @@ public function testMethodGetAntivirus(): void { $data = array( "version" => "1.0.0", - "status" => "online",); - + "status" => "online"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -54,10 +53,8 @@ public function testMethodGetAntivirus(): void { public function testMethodGetCache(): void { $data = array( - "name" => "database", - "ping" => 128, - "status" => "pass",); - + "total" => 5, + "statuses" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -77,8 +74,7 @@ public function testMethodGetCertificate(): void { "issuerOrganisation" => "", "validFrom" => "1704200998", "validTo" => "1711458597", - "signatureTypeSN" => "RSA-SHA256",); - + "signatureTypeSN" => "RSA-SHA256"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -93,10 +89,8 @@ public function testMethodGetCertificate(): void { public function testMethodGetDB(): void { $data = array( - "name" => "database", - "ping" => 128, - "status" => "pass",); - + "total" => 5, + "statuses" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -111,10 +105,8 @@ public function testMethodGetDB(): void { public function testMethodGetPubSub(): void { $data = array( - "name" => "database", - "ping" => 128, - "status" => "pass",); - + "total" => 5, + "statuses" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -126,11 +118,25 @@ public function testMethodGetPubSub(): void { $this->assertSame($data, $response); } - public function testMethodGetQueueBuilds(): void { + public function testMethodGetQueueAudits(): void { $data = array( - "size" => 8,); + "size" => 8); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->health->getQueueAudits( + ); + + $this->assertSame($data, $response); + } + public function testMethodGetQueueBuilds(): void { + + $data = array( + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -145,8 +151,7 @@ public function testMethodGetQueueBuilds(): void { public function testMethodGetQueueCertificates(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -161,8 +166,7 @@ public function testMethodGetQueueCertificates(): void { public function testMethodGetQueueDatabases(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -177,8 +181,7 @@ public function testMethodGetQueueDatabases(): void { public function testMethodGetQueueDeletes(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -193,15 +196,14 @@ public function testMethodGetQueueDeletes(): void { public function testMethodGetFailedJobs(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->health->getFailedJobs( - "v1-database" + Name::V1DATABASE() ); $this->assertSame($data, $response); @@ -210,8 +212,7 @@ public function testMethodGetFailedJobs(): void { public function testMethodGetQueueFunctions(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -226,8 +227,7 @@ public function testMethodGetQueueFunctions(): void { public function testMethodGetQueueLogs(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -242,8 +242,7 @@ public function testMethodGetQueueLogs(): void { public function testMethodGetQueueMails(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -258,8 +257,7 @@ public function testMethodGetQueueMails(): void { public function testMethodGetQueueMessaging(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -274,8 +272,7 @@ public function testMethodGetQueueMessaging(): void { public function testMethodGetQueueMigrations(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -290,8 +287,7 @@ public function testMethodGetQueueMigrations(): void { public function testMethodGetQueueStatsResources(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -306,8 +302,7 @@ public function testMethodGetQueueStatsResources(): void { public function testMethodGetQueueUsage(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -322,8 +317,7 @@ public function testMethodGetQueueUsage(): void { public function testMethodGetQueueWebhooks(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -340,8 +334,7 @@ public function testMethodGetStorage(): void { $data = array( "name" => "database", "ping" => 128, - "status" => "pass",); - + "status" => "pass"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -358,8 +351,7 @@ public function testMethodGetStorageLocal(): void { $data = array( "name" => "database", "ping" => 128, - "status" => "pass",); - + "status" => "pass"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -376,8 +368,7 @@ public function testMethodGetTime(): void { $data = array( "remoteTime" => 1639490751, "localTime" => 1639490844, - "diff" => 93,); - + "diff" => 93); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) diff --git a/tests/Appwrite/Services/LocaleTest.php b/tests/Appwrite/Services/LocaleTest.php index 6e8f9db..88af7d5 100644 --- a/tests/Appwrite/Services/LocaleTest.php +++ b/tests/Appwrite/Services/LocaleTest.php @@ -25,8 +25,7 @@ public function testMethodGet(): void { "continentCode" => "NA", "continent" => "North America", "eu" => true, - "currency" => "USD",); - + "currency" => "USD"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -42,8 +41,7 @@ public function testMethodListCodes(): void { $data = array( "total" => 5, - "localeCodes" => array(),); - + "localeCodes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -59,8 +57,7 @@ public function testMethodListContinents(): void { $data = array( "total" => 5, - "continents" => array(),); - + "continents" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -76,8 +73,7 @@ public function testMethodListCountries(): void { $data = array( "total" => 5, - "countries" => array(),); - + "countries" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -93,8 +89,7 @@ public function testMethodListCountriesEU(): void { $data = array( "total" => 5, - "countries" => array(),); - + "countries" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -110,8 +105,7 @@ public function testMethodListCountriesPhones(): void { $data = array( "total" => 5, - "phones" => array(),); - + "phones" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -127,8 +121,7 @@ public function testMethodListCurrencies(): void { $data = array( "total" => 5, - "currencies" => array(),); - + "currencies" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -144,8 +137,7 @@ public function testMethodListLanguages(): void { $data = array( "total" => 5, - "languages" => array(),); - + "languages" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) diff --git a/tests/Appwrite/Services/MessagingTest.php b/tests/Appwrite/Services/MessagingTest.php index ad2aab3..3bc8e69 100644 --- a/tests/Appwrite/Services/MessagingTest.php +++ b/tests/Appwrite/Services/MessagingTest.php @@ -6,6 +6,8 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\MessagePriority; +use Appwrite\Enums\SmtpEncryption; final class MessagingTest extends TestCase { private $client; @@ -20,8 +22,7 @@ public function testMethodListMessages(): void { $data = array( "total" => 5, - "messages" => array(),); - + "messages" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -45,8 +46,7 @@ public function testMethodCreateEmail(): void { "targets" => array(), "deliveredTotal" => 1, "data" => array(), - "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); - + "status" => "processing"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -73,8 +73,7 @@ public function testMethodUpdateEmail(): void { "targets" => array(), "deliveredTotal" => 1, "data" => array(), - "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); - + "status" => "processing"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -99,8 +98,7 @@ public function testMethodCreatePush(): void { "targets" => array(), "deliveredTotal" => 1, "data" => array(), - "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); - + "status" => "processing"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -125,8 +123,7 @@ public function testMethodUpdatePush(): void { "targets" => array(), "deliveredTotal" => 1, "data" => array(), - "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); - + "status" => "processing"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -151,8 +148,7 @@ public function testMethodCreateSMS(): void { "targets" => array(), "deliveredTotal" => 1, "data" => array(), - "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); - + "status" => "processing"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -178,8 +174,7 @@ public function testMethodUpdateSMS(): void { "targets" => array(), "deliveredTotal" => 1, "data" => array(), - "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); - + "status" => "processing"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -204,8 +199,7 @@ public function testMethodGetMessage(): void { "targets" => array(), "deliveredTotal" => 1, "data" => array(), - "status" => "Message status can be one of the following: draft, processing, scheduled, sent, or failed.",); - + "status" => "processing"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -222,7 +216,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -238,8 +231,7 @@ public function testMethodListMessageLogs(): void { $data = array( "total" => 5, - "logs" => array(),); - + "logs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -256,8 +248,7 @@ public function testMethodListTargets(): void { $data = array( "total" => 5, - "targets" => array(),); - + "targets" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -274,8 +265,7 @@ public function testMethodListProviders(): void { $data = array( "total" => 5, - "providers" => array(),); - + "providers" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -297,8 +287,7 @@ public function testMethodCreateAPNSProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -322,8 +311,7 @@ public function testMethodUpdateAPNSProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -346,8 +334,7 @@ public function testMethodCreateFCMProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -371,8 +358,7 @@ public function testMethodUpdateFCMProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -395,8 +381,7 @@ public function testMethodCreateMailgunProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -420,8 +405,7 @@ public function testMethodUpdateMailgunProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -444,8 +428,7 @@ public function testMethodCreateMsg91Provider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -469,8 +452,7 @@ public function testMethodUpdateMsg91Provider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -493,8 +475,7 @@ public function testMethodCreateResendProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -518,8 +499,7 @@ public function testMethodUpdateResendProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -542,8 +522,7 @@ public function testMethodCreateSendgridProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -567,8 +546,7 @@ public function testMethodUpdateSendgridProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -591,8 +569,7 @@ public function testMethodCreateSMTPProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -617,8 +594,7 @@ public function testMethodUpdateSMTPProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -641,8 +617,7 @@ public function testMethodCreateTelesignProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -666,8 +641,7 @@ public function testMethodUpdateTelesignProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -690,8 +664,7 @@ public function testMethodCreateTextmagicProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -715,8 +688,7 @@ public function testMethodUpdateTextmagicProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -739,8 +711,7 @@ public function testMethodCreateTwilioProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -764,8 +735,7 @@ public function testMethodUpdateTwilioProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -788,8 +758,7 @@ public function testMethodCreateVonageProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -813,8 +782,7 @@ public function testMethodUpdateVonageProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -837,8 +805,7 @@ public function testMethodGetProvider(): void { "provider" => "mailgun", "enabled" => true, "type" => "sms", - "credentials" => array(),); - + "credentials" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -855,7 +822,6 @@ public function testMethodDeleteProvider(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -871,8 +837,7 @@ public function testMethodListProviderLogs(): void { $data = array( "total" => 5, - "logs" => array(),); - + "logs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -889,8 +854,7 @@ public function testMethodListSubscriberLogs(): void { $data = array( "total" => 5, - "logs" => array(),); - + "logs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -907,8 +871,7 @@ public function testMethodListTopics(): void { $data = array( "total" => 5, - "topics" => array(),); - + "topics" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -930,8 +893,7 @@ public function testMethodCreateTopic(): void { "emailTotal" => 100, "smsTotal" => 100, "pushTotal" => 100, - "subscribe" => array(),); - + "subscribe" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -955,8 +917,7 @@ public function testMethodGetTopic(): void { "emailTotal" => 100, "smsTotal" => 100, "pushTotal" => 100, - "subscribe" => array(),); - + "subscribe" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -979,8 +940,7 @@ public function testMethodUpdateTopic(): void { "emailTotal" => 100, "smsTotal" => 100, "pushTotal" => 100, - "subscribe" => array(),); - + "subscribe" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -997,7 +957,6 @@ public function testMethodDeleteTopic(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1013,8 +972,7 @@ public function testMethodListTopicLogs(): void { $data = array( "total" => 5, - "logs" => array(),); - + "logs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1031,8 +989,7 @@ public function testMethodListSubscribers(): void { $data = array( "total" => 5, - "subscribers" => array(),); - + "subscribers" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1056,8 +1013,7 @@ public function testMethodCreateSubscriber(): void { "userId" => "5e5ea5c16897e", "userName" => "Aegon Targaryen", "topicId" => "259125845563242502", - "providerType" => "email",); - + "providerType" => "email"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1083,8 +1039,7 @@ public function testMethodGetSubscriber(): void { "userId" => "5e5ea5c16897e", "userName" => "Aegon Targaryen", "topicId" => "259125845563242502", - "providerType" => "email",); - + "providerType" => "email"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1102,7 +1057,6 @@ public function testMethodDeleteSubscriber(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/SitesTest.php b/tests/Appwrite/Services/SitesTest.php index 831d7bb..2d3a2bc 100644 --- a/tests/Appwrite/Services/SitesTest.php +++ b/tests/Appwrite/Services/SitesTest.php @@ -6,6 +6,12 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\Framework; +use Appwrite\Enums\BuildRuntime; +use Appwrite\Enums\Adapter; +use Appwrite\Enums\TemplateReferenceType; +use Appwrite\Enums\VCSReferenceType; +use Appwrite\Enums\DeploymentDownloadType; final class SitesTest extends TestCase { private $client; @@ -20,8 +26,7 @@ public function testMethodList(): void { $data = array( "total" => 5, - "sites" => array(),); - + "sites" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -64,8 +69,7 @@ public function testMethodCreate(): void { "specification" => "s-1vcpu-512mb", "buildRuntime" => "node-22", "adapter" => "static", - "fallbackFile" => "index.html",); - + "fallbackFile" => "index.html"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -74,8 +78,8 @@ public function testMethodCreate(): void { $response = $this->sites->create( "", "", - "analog", - "node-14.5" + Framework::ANALOG(), + BuildRuntime::NODE145() ); $this->assertSame($data, $response); @@ -85,8 +89,7 @@ public function testMethodListFrameworks(): void { $data = array( "total" => 5, - "frameworks" => array(),); - + "frameworks" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -102,8 +105,7 @@ public function testMethodListSpecifications(): void { $data = array( "total" => 5, - "specifications" => array(),); - + "specifications" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -146,8 +148,7 @@ public function testMethodGet(): void { "specification" => "s-1vcpu-512mb", "buildRuntime" => "node-22", "adapter" => "static", - "fallbackFile" => "index.html",); - + "fallbackFile" => "index.html"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -191,8 +192,7 @@ public function testMethodUpdate(): void { "specification" => "s-1vcpu-512mb", "buildRuntime" => "node-22", "adapter" => "static", - "fallbackFile" => "index.html",); - + "fallbackFile" => "index.html"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -201,7 +201,7 @@ public function testMethodUpdate(): void { $response = $this->sites->update( "", "", - "analog" + Framework::ANALOG() ); $this->assertSame($data, $response); @@ -211,7 +211,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -254,8 +253,7 @@ public function testMethodUpdateSiteDeployment(): void { "specification" => "s-1vcpu-512mb", "buildRuntime" => "node-22", "adapter" => "static", - "fallbackFile" => "index.html",); - + "fallbackFile" => "index.html"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -273,8 +271,7 @@ public function testMethodListDeployments(): void { $data = array( "total" => 5, - "deployments" => array(),); - + "deployments" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -316,8 +313,7 @@ public function testMethodCreateDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -361,8 +357,7 @@ public function testMethodCreateDuplicateDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -405,8 +400,7 @@ public function testMethodCreateTemplateDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -417,7 +411,7 @@ public function testMethodCreateTemplateDeployment(): void { "", "", "", - "branch", + TemplateReferenceType::BRANCH(), "" ); @@ -453,8 +447,7 @@ public function testMethodCreateVcsDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -462,7 +455,7 @@ public function testMethodCreateVcsDeployment(): void { $response = $this->sites->createVcsDeployment( "", - "branch", + VCSReferenceType::BRANCH(), "" ); @@ -498,8 +491,7 @@ public function testMethodGetDeployment(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -517,7 +509,6 @@ public function testMethodDeleteDeployment(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -534,7 +525,6 @@ public function testMethodGetDeploymentDownload(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -576,8 +566,7 @@ public function testMethodUpdateDeploymentStatus(): void { "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", "providerBranch" => "0.7.x", - "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); - + "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -595,8 +584,7 @@ public function testMethodListLogs(): void { $data = array( "total" => 5, - "executions" => array(),); - + "executions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -628,8 +616,7 @@ public function testMethodGetLog(): void { "responseHeaders" => array(), "logs" => "", "errors" => "", - "duration" => 0.4,); - + "duration" => 0.4); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -647,7 +634,6 @@ public function testMethodDeleteLog(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -664,8 +650,7 @@ public function testMethodListVariables(): void { $data = array( "total" => 5, - "variables" => array(),); - + "variables" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -688,8 +673,7 @@ public function testMethodCreateVariable(): void { "value" => "myPa\$\$word1", "secret" => true, "resourceType" => "function", - "resourceId" => "myAwesomeFunction",); - + "resourceId" => "myAwesomeFunction"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -714,8 +698,7 @@ public function testMethodGetVariable(): void { "value" => "myPa\$\$word1", "secret" => true, "resourceType" => "function", - "resourceId" => "myAwesomeFunction",); - + "resourceId" => "myAwesomeFunction"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -739,8 +722,7 @@ public function testMethodUpdateVariable(): void { "value" => "myPa\$\$word1", "secret" => true, "resourceType" => "function", - "resourceId" => "myAwesomeFunction",); - + "resourceId" => "myAwesomeFunction"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -759,7 +741,6 @@ public function testMethodDeleteVariable(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/StorageTest.php b/tests/Appwrite/Services/StorageTest.php index 0f2ce53..4d01dae 100644 --- a/tests/Appwrite/Services/StorageTest.php +++ b/tests/Appwrite/Services/StorageTest.php @@ -6,6 +6,9 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\Compression; +use Appwrite\Enums\ImageGravity; +use Appwrite\Enums\ImageFormat; final class StorageTest extends TestCase { private $client; @@ -20,8 +23,7 @@ public function testMethodListBuckets(): void { $data = array( "total" => 5, - "buckets" => array(),); - + "buckets" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -48,8 +50,8 @@ public function testMethodCreateBucket(): void { "compression" => "gzip", "encryption" => true, "antivirus" => true, - "transformations" => true,); - + "transformations" => true, + "totalSize" => 128); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -78,8 +80,8 @@ public function testMethodGetBucket(): void { "compression" => "gzip", "encryption" => true, "antivirus" => true, - "transformations" => true,); - + "transformations" => true, + "totalSize" => 128); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -107,8 +109,8 @@ public function testMethodUpdateBucket(): void { "compression" => "gzip", "encryption" => true, "antivirus" => true, - "transformations" => true,); - + "transformations" => true, + "totalSize" => 128); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -126,7 +128,6 @@ public function testMethodDeleteBucket(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -142,8 +143,7 @@ public function testMethodListFiles(): void { $data = array( "total" => 5, - "files" => array(),); - + "files" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -169,8 +169,9 @@ public function testMethodCreateFile(): void { "mimeType" => "image/png", "sizeOriginal" => 17890, "chunksTotal" => 17890, - "chunksUploaded" => 17890,); - + "chunksUploaded" => 17890, + "encryption" => true, + "compression" => "gzip"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -198,8 +199,9 @@ public function testMethodGetFile(): void { "mimeType" => "image/png", "sizeOriginal" => 17890, "chunksTotal" => 17890, - "chunksUploaded" => 17890,); - + "chunksUploaded" => 17890, + "encryption" => true, + "compression" => "gzip"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -226,8 +228,9 @@ public function testMethodUpdateFile(): void { "mimeType" => "image/png", "sizeOriginal" => 17890, "chunksTotal" => 17890, - "chunksUploaded" => 17890,); - + "chunksUploaded" => 17890, + "encryption" => true, + "compression" => "gzip"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -245,7 +248,6 @@ public function testMethodDeleteFile(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -262,7 +264,6 @@ public function testMethodGetFileDownload(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -279,7 +280,6 @@ public function testMethodGetFilePreview(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -296,7 +296,6 @@ public function testMethodGetFileView(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php index 5b5d008..93b330d 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -6,6 +6,10 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\RelationshipType; +use Appwrite\Enums\RelationMutate; +use Appwrite\Enums\IndexType; +use Appwrite\Enums\OrderBy; final class TablesDBTest extends TestCase { private $client; @@ -20,8 +24,7 @@ public function testMethodList(): void { $data = array( "total" => 5, - "databases" => array(),); - + "databases" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -41,8 +44,7 @@ public function testMethodCreate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy",); - + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -60,8 +62,7 @@ public function testMethodListTransactions(): void { $data = array( "total" => 5, - "transactions" => array(),); - + "transactions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -81,8 +82,7 @@ public function testMethodCreateTransaction(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "status" => "pending", "operations" => 5, - "expiresAt" => "2020-10-15T06:38:00.000+00:00",); - + "expiresAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -102,8 +102,7 @@ public function testMethodGetTransaction(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "status" => "pending", "operations" => 5, - "expiresAt" => "2020-10-15T06:38:00.000+00:00",); - + "expiresAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -124,8 +123,7 @@ public function testMethodUpdateTransaction(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "status" => "pending", "operations" => 5, - "expiresAt" => "2020-10-15T06:38:00.000+00:00",); - + "expiresAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -142,7 +140,6 @@ public function testMethodDeleteTransaction(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -162,8 +159,7 @@ public function testMethodCreateOperations(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "status" => "pending", "operations" => 5, - "expiresAt" => "2020-10-15T06:38:00.000+00:00",); - + "expiresAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -184,8 +180,7 @@ public function testMethodGet(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy",); - + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -206,16 +201,14 @@ public function testMethodUpdate(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "enabled" => true, - "type" => "legacy",); - + "type" => "legacy"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->tablesDB->update( - "", - "" + "" ); $this->assertSame($data, $response); @@ -225,7 +218,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -241,8 +233,7 @@ public function testMethodListTables(): void { $data = array( "total" => 5, - "tables" => array(),); - + "tables" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -267,8 +258,7 @@ public function testMethodCreateTable(): void { "enabled" => true, "rowSecurity" => true, "columns" => array(), - "indexes" => array(),); - + "indexes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -295,8 +285,7 @@ public function testMethodGetTable(): void { "enabled" => true, "rowSecurity" => true, "columns" => array(), - "indexes" => array(),); - + "indexes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -322,8 +311,7 @@ public function testMethodUpdateTable(): void { "enabled" => true, "rowSecurity" => true, "columns" => array(), - "indexes" => array(),); - + "indexes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -331,8 +319,7 @@ public function testMethodUpdateTable(): void { $response = $this->tablesDB->updateTable( "", - "", - "" + "" ); $this->assertSame($data, $response); @@ -342,7 +329,6 @@ public function testMethodDeleteTable(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -359,8 +345,7 @@ public function testMethodListColumns(): void { $data = array( "total" => 5, - "columns" => array(),); - + "columns" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -383,8 +368,7 @@ public function testMethodCreateBooleanColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -409,8 +393,7 @@ public function testMethodUpdateBooleanColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -437,8 +420,7 @@ public function testMethodCreateDatetimeColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "datetime",); - + "format" => "datetime"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -464,8 +446,7 @@ public function testMethodUpdateDatetimeColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "datetime",); - + "format" => "datetime"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -492,8 +473,7 @@ public function testMethodCreateEmailColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "email",); - + "format" => "email"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -519,8 +499,7 @@ public function testMethodUpdateEmailColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "email",); - + "format" => "email"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -548,8 +527,7 @@ public function testMethodCreateEnumColumn(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "elements" => array(), - "format" => "enum",); - + "format" => "enum"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -577,8 +555,7 @@ public function testMethodUpdateEnumColumn(): void { "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "elements" => array(), - "format" => "enum",); - + "format" => "enum"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -605,8 +582,7 @@ public function testMethodCreateFloatColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -631,8 +607,7 @@ public function testMethodUpdateFloatColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -658,8 +633,7 @@ public function testMethodCreateIntegerColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -684,8 +658,7 @@ public function testMethodUpdateIntegerColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -712,8 +685,7 @@ public function testMethodCreateIpColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "ip",); - + "format" => "ip"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -739,8 +711,7 @@ public function testMethodUpdateIpColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "ip",); - + "format" => "ip"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -766,8 +737,7 @@ public function testMethodCreateLineColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -792,8 +762,7 @@ public function testMethodUpdateLineColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -818,8 +787,7 @@ public function testMethodCreatePointColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -844,8 +812,7 @@ public function testMethodUpdatePointColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -870,8 +837,7 @@ public function testMethodCreatePolygonColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -896,8 +862,7 @@ public function testMethodUpdatePolygonColumn(): void { "error" => "string", "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -928,8 +893,7 @@ public function testMethodCreateRelationshipColumn(): void { "twoWay" => true, "twoWayKey" => "string", "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child",); - + "side" => "parent|child"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -939,7 +903,7 @@ public function testMethodCreateRelationshipColumn(): void { "", "", "", - "oneToOne" + RelationshipType::ONETOONE() ); $this->assertSame($data, $response); @@ -955,8 +919,7 @@ public function testMethodCreateStringColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "size" => 128,); - + "size" => 128); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -983,8 +946,7 @@ public function testMethodUpdateStringColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "size" => 128,); - + "size" => 128); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1011,8 +973,7 @@ public function testMethodCreateUrlColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "url",); - + "format" => "url"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1038,8 +999,7 @@ public function testMethodUpdateUrlColumn(): void { "required" => true, "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "url",); - + "format" => "url"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1058,8 +1018,14 @@ public function testMethodUpdateUrlColumn(): void { public function testMethodGetColumn(): void { - $data = ''; - + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1078,7 +1044,6 @@ public function testMethodDeleteColumn(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1107,8 +1072,7 @@ public function testMethodUpdateRelationshipColumn(): void { "twoWay" => true, "twoWayKey" => "string", "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child",); - + "side" => "parent|child"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1127,8 +1091,7 @@ public function testMethodListIndexes(): void { $data = array( "total" => 5, - "indexes" => array(),); - + "indexes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1153,8 +1116,7 @@ public function testMethodCreateIndex(): void { "status" => "available", "error" => "string", "columns" => array(), - "lengths" => array(),); - + "lengths" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1164,7 +1126,7 @@ public function testMethodCreateIndex(): void { "", "", "", - "key", + IndexType::KEY(), array() ); @@ -1182,8 +1144,7 @@ public function testMethodGetIndex(): void { "status" => "available", "error" => "string", "columns" => array(), - "lengths" => array(),); - + "lengths" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1202,7 +1163,6 @@ public function testMethodDeleteIndex(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1220,8 +1180,7 @@ public function testMethodListRows(): void { $data = array( "total" => 5, - "rows" => array(),); - + "rows" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1244,8 +1203,7 @@ public function testMethodCreateRow(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1265,8 +1223,7 @@ public function testMethodCreateRows(): void { $data = array( "total" => 5, - "rows" => array(),); - + "rows" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1285,8 +1242,7 @@ public function testMethodUpsertRows(): void { $data = array( "total" => 5, - "rows" => array(),); - + "rows" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1305,8 +1261,7 @@ public function testMethodUpdateRows(): void { $data = array( "total" => 5, - "rows" => array(),); - + "rows" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1324,8 +1279,7 @@ public function testMethodDeleteRows(): void { $data = array( "total" => 5, - "rows" => array(),); - + "rows" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1348,8 +1302,7 @@ public function testMethodGetRow(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1373,8 +1326,7 @@ public function testMethodUpsertRow(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1398,8 +1350,7 @@ public function testMethodUpdateRow(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1418,7 +1369,6 @@ public function testMethodDeleteRow(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1441,8 +1391,7 @@ public function testMethodDecrementRowColumn(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1467,8 +1416,7 @@ public function testMethodIncrementRowColumn(): void { "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - + "\$permissions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) diff --git a/tests/Appwrite/Services/TeamsTest.php b/tests/Appwrite/Services/TeamsTest.php index d77d0de..f9438d5 100644 --- a/tests/Appwrite/Services/TeamsTest.php +++ b/tests/Appwrite/Services/TeamsTest.php @@ -6,6 +6,7 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\Roles; final class TeamsTest extends TestCase { private $client; @@ -20,8 +21,7 @@ public function testMethodList(): void { $data = array( "total" => 5, - "teams" => array(),); - + "teams" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -41,8 +41,7 @@ public function testMethodCreate(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "VIP", "total" => 7, - "prefs" => array(),); - + "prefs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -64,8 +63,7 @@ public function testMethodGet(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "VIP", "total" => 7, - "prefs" => array(),); - + "prefs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -86,8 +84,7 @@ public function testMethodUpdateName(): void { "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", "name" => "VIP", "total" => 7, - "prefs" => array(),); - + "prefs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -105,7 +102,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -121,8 +117,7 @@ public function testMethodListMemberships(): void { $data = array( "total" => 5, - "memberships" => array(),); - + "memberships" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -150,8 +145,7 @@ public function testMethodCreateMembership(): void { "joined" => "2020-10-15T06:38:00.000+00:00", "confirm" => true, "mfa" => true, - "roles" => array(),); - + "roles" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -159,7 +153,7 @@ public function testMethodCreateMembership(): void { $response = $this->teams->createMembership( "", - array() + array(Roles::ADMIN()) ); $this->assertSame($data, $response); @@ -180,8 +174,7 @@ public function testMethodGetMembership(): void { "joined" => "2020-10-15T06:38:00.000+00:00", "confirm" => true, "mfa" => true, - "roles" => array(),); - + "roles" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -210,8 +203,7 @@ public function testMethodUpdateMembership(): void { "joined" => "2020-10-15T06:38:00.000+00:00", "confirm" => true, "mfa" => true, - "roles" => array(),); - + "roles" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -220,7 +212,7 @@ public function testMethodUpdateMembership(): void { $response = $this->teams->updateMembership( "", "", - array() + array(Roles::ADMIN()) ); $this->assertSame($data, $response); @@ -230,7 +222,6 @@ public function testMethodDeleteMembership(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -258,8 +249,7 @@ public function testMethodUpdateMembershipStatus(): void { "joined" => "2020-10-15T06:38:00.000+00:00", "confirm" => true, "mfa" => true, - "roles" => array(),); - + "roles" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -279,7 +269,6 @@ public function testMethodGetPrefs(): void { $data = array(); - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -295,7 +284,6 @@ public function testMethodUpdatePrefs(): void { $data = array(); - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/TokensTest.php b/tests/Appwrite/Services/TokensTest.php index 550b608..59dff5a 100644 --- a/tests/Appwrite/Services/TokensTest.php +++ b/tests/Appwrite/Services/TokensTest.php @@ -20,8 +20,7 @@ public function testMethodList(): void { $data = array( "total" => 5, - "tokens" => array(),); - + "tokens" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -44,8 +43,7 @@ public function testMethodCreateFileToken(): void { "resourceType" => "files", "expire" => "2020-10-15T06:38:00.000+00:00", "secret" => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -68,8 +66,7 @@ public function testMethodGet(): void { "resourceType" => "files", "expire" => "2020-10-15T06:38:00.000+00:00", "secret" => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -91,8 +88,7 @@ public function testMethodUpdate(): void { "resourceType" => "files", "expire" => "2020-10-15T06:38:00.000+00:00", "secret" => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -109,7 +105,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); diff --git a/tests/Appwrite/Services/UsersTest.php b/tests/Appwrite/Services/UsersTest.php index 101d1af..83d2bbc 100644 --- a/tests/Appwrite/Services/UsersTest.php +++ b/tests/Appwrite/Services/UsersTest.php @@ -6,6 +6,9 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\PasswordHash; +use Appwrite\Enums\AuthenticatorType; +use Appwrite\Enums\MessagingProviderType; final class UsersTest extends TestCase { private $client; @@ -20,8 +23,7 @@ public function testMethodList(): void { $data = array( "total" => 5, - "users" => array(),); - + "users" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -51,8 +53,7 @@ public function testMethodCreate(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -83,8 +84,7 @@ public function testMethodCreateArgon2User(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -117,8 +117,7 @@ public function testMethodCreateBcryptUser(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -137,8 +136,7 @@ public function testMethodListIdentities(): void { $data = array( "total" => 5, - "identities" => array(),); - + "identities" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -154,7 +152,6 @@ public function testMethodDeleteIdentity(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -184,8 +181,7 @@ public function testMethodCreateMD5User(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -218,8 +214,7 @@ public function testMethodCreatePHPassUser(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -252,8 +247,7 @@ public function testMethodCreateScryptUser(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -291,8 +285,7 @@ public function testMethodCreateScryptModifiedUser(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -328,8 +321,7 @@ public function testMethodCreateSHAUser(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -362,8 +354,7 @@ public function testMethodGet(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -380,7 +371,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -410,8 +400,7 @@ public function testMethodUpdateEmail(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -428,8 +417,7 @@ public function testMethodUpdateEmail(): void { public function testMethodCreateJWT(): void { $data = array( - "jwt" => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",); - + "jwt" => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -460,8 +448,7 @@ public function testMethodUpdateLabels(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -479,8 +466,7 @@ public function testMethodListLogs(): void { $data = array( "total" => 5, - "logs" => array(),); - + "logs" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -497,8 +483,7 @@ public function testMethodListMemberships(): void { $data = array( "total" => 5, - "memberships" => array(),); - + "memberships" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -529,8 +514,7 @@ public function testMethodUpdateMFA(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -548,14 +532,13 @@ public function testMethodDeleteMFAAuthenticator(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); $response = $this->users->deleteMFAAuthenticator( "", - "totp" + AuthenticatorType::TOTP() ); $this->assertSame($data, $response); @@ -567,8 +550,7 @@ public function testMethodListMFAFactors(): void { "totp" => true, "phone" => true, "email" => true, - "recoveryCode" => true,); - + "recoveryCode" => true); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -584,8 +566,7 @@ public function testMethodListMFAFactors(): void { public function testMethodGetMFARecoveryCodes(): void { $data = array( - "recoveryCodes" => array(),); - + "recoveryCodes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -601,8 +582,7 @@ public function testMethodGetMFARecoveryCodes(): void { public function testMethodUpdateMFARecoveryCodes(): void { $data = array( - "recoveryCodes" => array(),); - + "recoveryCodes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -618,8 +598,7 @@ public function testMethodUpdateMFARecoveryCodes(): void { public function testMethodCreateMFARecoveryCodes(): void { $data = array( - "recoveryCodes" => array(),); - + "recoveryCodes" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -650,8 +629,7 @@ public function testMethodUpdateName(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -683,8 +661,7 @@ public function testMethodUpdatePassword(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -716,8 +693,7 @@ public function testMethodUpdatePhone(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -735,7 +711,6 @@ public function testMethodGetPrefs(): void { $data = array(); - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -751,7 +726,6 @@ public function testMethodUpdatePrefs(): void { $data = array(); - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -768,8 +742,7 @@ public function testMethodListSessions(): void { $data = array( "total" => 5, - "sessions" => array(),); - + "sessions" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -813,8 +786,7 @@ public function testMethodCreateSession(): void { "current" => true, "factors" => array(), "secret" => "5e5bb8c16897e", - "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00",); - + "mfaUpdatedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -831,7 +803,6 @@ public function testMethodDeleteSessions(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -847,7 +818,6 @@ public function testMethodDeleteSession(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -878,8 +848,7 @@ public function testMethodUpdateStatus(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -897,8 +866,7 @@ public function testMethodListTargets(): void { $data = array( "total" => 5, - "targets" => array(),); - + "targets" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -921,8 +889,7 @@ public function testMethodCreateTarget(): void { "userId" => "259125845563242502", "providerType" => "email", "identifier" => "token", - "expired" => true,); - + "expired" => true); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -931,7 +898,7 @@ public function testMethodCreateTarget(): void { $response = $this->users->createTarget( "", "", - "email", + MessagingProviderType::EMAIL(), "" ); @@ -948,8 +915,7 @@ public function testMethodGetTarget(): void { "userId" => "259125845563242502", "providerType" => "email", "identifier" => "token", - "expired" => true,); - + "expired" => true); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -973,8 +939,7 @@ public function testMethodUpdateTarget(): void { "userId" => "259125845563242502", "providerType" => "email", "identifier" => "token", - "expired" => true,); - + "expired" => true); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -992,7 +957,6 @@ public function testMethodDeleteTarget(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1013,8 +977,7 @@ public function testMethodCreateToken(): void { "userId" => "5e5ea5c168bb8", "secret" => "", "expire" => "2020-10-15T06:38:00.000+00:00", - "phrase" => "Golden Fox",); - + "phrase" => "Golden Fox"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1045,8 +1008,7 @@ public function testMethodUpdateEmailVerification(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -1078,8 +1040,7 @@ public function testMethodUpdatePhoneVerification(): void { "mfa" => true, "prefs" => array(), "targets" => array(), - "accessedAt" => "2020-10-15T06:38:00.000+00:00",); - + "accessedAt" => "2020-10-15T06:38:00.000+00:00"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) From 986a604a8c609853da9da531236a74fd2c71566c Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Feb 2026 12:30:35 +0000 Subject: [PATCH 2/3] update changelog etc --- CHANGELOG.md | 2 + docs/databases.md | 154 ++++++++ .../databases/create-longtext-attribute.md | 20 + .../databases/create-mediumtext-attribute.md | 20 + .../databases/create-text-attribute.md | 20 + .../databases/create-varchar-attribute.md | 21 ++ .../databases/update-longtext-attribute.md | 20 + .../databases/update-mediumtext-attribute.md | 20 + .../databases/update-text-attribute.md | 20 + .../databases/update-varchar-attribute.md | 21 ++ .../tablesdb/create-longtext-column.md | 20 + .../tablesdb/create-mediumtext-column.md | 20 + docs/examples/tablesdb/create-text-column.md | 20 + .../tablesdb/create-varchar-column.md | 21 ++ .../tablesdb/update-longtext-column.md | 20 + .../tablesdb/update-mediumtext-column.md | 20 + docs/examples/tablesdb/update-text-column.md | 20 + .../tablesdb/update-varchar-column.md | 21 ++ docs/tablesdb.md | 154 ++++++++ src/Appwrite/Services/Databases.php | 340 +++++++++++++++++ src/Appwrite/Services/TablesDB.php | 346 ++++++++++++++++++ tests/Appwrite/Services/DatabasesTest.php | 207 +++++++++++ tests/Appwrite/Services/TablesDBTest.php | 207 +++++++++++ 23 files changed, 1734 insertions(+) create mode 100644 docs/examples/databases/create-longtext-attribute.md create mode 100644 docs/examples/databases/create-mediumtext-attribute.md create mode 100644 docs/examples/databases/create-text-attribute.md create mode 100644 docs/examples/databases/create-varchar-attribute.md create mode 100644 docs/examples/databases/update-longtext-attribute.md create mode 100644 docs/examples/databases/update-mediumtext-attribute.md create mode 100644 docs/examples/databases/update-text-attribute.md create mode 100644 docs/examples/databases/update-varchar-attribute.md create mode 100644 docs/examples/tablesdb/create-longtext-column.md create mode 100644 docs/examples/tablesdb/create-mediumtext-column.md create mode 100644 docs/examples/tablesdb/create-text-column.md create mode 100644 docs/examples/tablesdb/create-varchar-column.md create mode 100644 docs/examples/tablesdb/update-longtext-column.md create mode 100644 docs/examples/tablesdb/update-mediumtext-column.md create mode 100644 docs/examples/tablesdb/update-text-column.md create mode 100644 docs/examples/tablesdb/update-varchar-column.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 14cf753..f91f69d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ ## 20.0.0 * Add array-based enum parameters (e.g., `permissions: array`). +* Breaking change: `Output` enum has been removed; use `ImageFormat` instead. +* Add `getQueueAudits` support to `Health` service. ## 19.1.0 diff --git a/docs/databases.md b/docs/databases.md index 25ccef6..b719a18 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -560,6 +560,82 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | newKey | string | New attribute key. | | +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/longtext +``` + +** Create a longtext attribute. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| array | boolean | Is attribute an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key} +``` + +** Update a longtext attribute. Changing the `default` value will not update already existing documents. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | **Required** Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| newKey | string | New Attribute Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext +``` + +** Create a mediumtext attribute. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| array | boolean | Is attribute an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key} +``` + +** Update a mediumtext attribute. Changing the `default` value will not update already existing documents. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | **Required** Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| newKey | string | New Attribute Key. | | + + ```http request POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/point ``` @@ -692,6 +768,44 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | newKey | string | New Attribute Key. | | +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/text +``` + +** Create a text attribute. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| array | boolean | Is attribute an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/text/{key} +``` + +** Update a text attribute. Changing the `default` value will not update already existing documents. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | **Required** Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| newKey | string | New Attribute Key. | | + + ```http request POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/url ``` @@ -730,6 +844,46 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | newKey | string | New Attribute Key. | | +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/varchar +``` + +** Create a varchar attribute. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | Attribute Key. | | +| size | integer | Attribute size for varchar attributes, in number of characters. Maximum size is 16381. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| array | boolean | Is attribute an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key} +``` + +** Update a varchar attribute. Changing the `default` value will not update already existing documents. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| key | string | **Required** Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| size | integer | Maximum size of the varchar attribute. | | +| newKey | string | New Attribute Key. | | + + ```http request GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/{key} ``` diff --git a/docs/examples/databases/create-longtext-attribute.md b/docs/examples/databases/create-longtext-attribute.md new file mode 100644 index 0000000..bb97b18 --- /dev/null +++ b/docs/examples/databases/create-longtext-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createLongtextAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-mediumtext-attribute.md b/docs/examples/databases/create-mediumtext-attribute.md new file mode 100644 index 0000000..d225d95 --- /dev/null +++ b/docs/examples/databases/create-mediumtext-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createMediumtextAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-text-attribute.md b/docs/examples/databases/create-text-attribute.md new file mode 100644 index 0000000..3b1316f --- /dev/null +++ b/docs/examples/databases/create-text-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createTextAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-varchar-attribute.md b/docs/examples/databases/create-varchar-attribute.md new file mode 100644 index 0000000..811e47b --- /dev/null +++ b/docs/examples/databases/create-varchar-attribute.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createVarcharAttribute( + databaseId: '', + collectionId: '', + key: '', + size: 1, + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-longtext-attribute.md b/docs/examples/databases/update-longtext-attribute.md new file mode 100644 index 0000000..6d5ade2 --- /dev/null +++ b/docs/examples/databases/update-longtext-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->updateLongtextAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-mediumtext-attribute.md b/docs/examples/databases/update-mediumtext-attribute.md new file mode 100644 index 0000000..7671c55 --- /dev/null +++ b/docs/examples/databases/update-mediumtext-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->updateMediumtextAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-text-attribute.md b/docs/examples/databases/update-text-attribute.md new file mode 100644 index 0000000..eef0669 --- /dev/null +++ b/docs/examples/databases/update-text-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->updateTextAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-varchar-attribute.md b/docs/examples/databases/update-varchar-attribute.md new file mode 100644 index 0000000..df98322 --- /dev/null +++ b/docs/examples/databases/update-varchar-attribute.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->updateVarcharAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', + size: 1, // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-longtext-column.md b/docs/examples/tablesdb/create-longtext-column.md new file mode 100644 index 0000000..48c5747 --- /dev/null +++ b/docs/examples/tablesdb/create-longtext-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createLongtextColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-mediumtext-column.md b/docs/examples/tablesdb/create-mediumtext-column.md new file mode 100644 index 0000000..f2472fb --- /dev/null +++ b/docs/examples/tablesdb/create-mediumtext-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createMediumtextColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-text-column.md b/docs/examples/tablesdb/create-text-column.md new file mode 100644 index 0000000..00f1611 --- /dev/null +++ b/docs/examples/tablesdb/create-text-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createTextColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-varchar-column.md b/docs/examples/tablesdb/create-varchar-column.md new file mode 100644 index 0000000..bbd8650 --- /dev/null +++ b/docs/examples/tablesdb/create-varchar-column.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createVarcharColumn( + databaseId: '', + tableId: '', + key: '', + size: 1, + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-longtext-column.md b/docs/examples/tablesdb/update-longtext-column.md new file mode 100644 index 0000000..0ba81d6 --- /dev/null +++ b/docs/examples/tablesdb/update-longtext-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateLongtextColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-mediumtext-column.md b/docs/examples/tablesdb/update-mediumtext-column.md new file mode 100644 index 0000000..5ff6424 --- /dev/null +++ b/docs/examples/tablesdb/update-mediumtext-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateMediumtextColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-text-column.md b/docs/examples/tablesdb/update-text-column.md new file mode 100644 index 0000000..56aa217 --- /dev/null +++ b/docs/examples/tablesdb/update-text-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateTextColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-varchar-column.md b/docs/examples/tablesdb/update-varchar-column.md new file mode 100644 index 0000000..077e8c4 --- /dev/null +++ b/docs/examples/tablesdb/update-varchar-column.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateVarcharColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + size: 1, // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/tablesdb.md b/docs/tablesdb.md index e92f32b..863408d 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -559,6 +559,82 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | newKey | string | New Column Key. | | +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/longtext +``` + +** Create a longtext column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key} +``` + +** Update a longtext column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext +``` + +** Create a mediumtext column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key} +``` + +** Update a mediumtext column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + ```http request POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/point ``` @@ -691,6 +767,44 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | newKey | string | New Column Key. | | +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/text +``` + +** Create a text column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key} +``` + +** Update a text column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + ```http request POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/url ``` @@ -729,6 +843,46 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | newKey | string | New Column Key. | | +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/varchar +``` + +** Create a varchar column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | +| key | string | Column Key. | | +| size | integer | Column size for varchar columns, in number of characters. Maximum size is 16381. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key} +``` + +** Update a varchar column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| size | integer | Maximum size of the varchar column. | | +| newKey | string | New Column Key. | | + + ```http request GET https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/{key} ``` diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 770d786..b4aa42c 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -1407,6 +1407,174 @@ public function updateLineAttribute(string $databaseId, string $collectionId, st ); } + /** + * Create a longtext attribute. + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}'], + [$databaseId, $collectionId], + '/databases/{databaseId}/collections/{collectionId}/attributes/longtext' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a longtext attribute. Changing the `default` value will not update + * already existing documents. + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateLongtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{key}'], + [$databaseId, $collectionId, $key], + '/databases/{databaseId}/collections/{collectionId}/attributes/longtext/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a mediumtext attribute. + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}'], + [$databaseId, $collectionId], + '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a mediumtext attribute. Changing the `default` value will not update + * already existing documents. + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateMediumtextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{key}'], + [$databaseId, $collectionId, $key], + '/databases/{databaseId}/collections/{collectionId}/attributes/mediumtext/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Create a geometric point attribute. * @@ -1726,6 +1894,90 @@ public function updateStringAttribute(string $databaseId, string $collectionId, ); } + /** + * Create a text attribute. + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}'], + [$databaseId, $collectionId], + '/databases/{databaseId}/collections/{collectionId}/attributes/text' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a text attribute. Changing the `default` value will not update + * already existing documents. + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateTextAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{key}'], + [$databaseId, $collectionId, $key], + '/databases/{databaseId}/collections/{collectionId}/attributes/text/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Create a URL attribute. * @@ -1816,6 +2068,94 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str ); } + /** + * Create a varchar attribute. + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param int $size + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createVarcharAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}'], + [$databaseId, $collectionId], + '/databases/{databaseId}/collections/{collectionId}/attributes/varchar' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['size'] = $size; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a varchar attribute. Changing the `default` value will not update + * already existing documents. + * + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?int $size + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateVarcharAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{key}'], + [$databaseId, $collectionId, $key], + '/databases/{databaseId}/collections/{collectionId}/attributes/varchar/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + $apiParams['size'] = $size; + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get attribute by ID. * diff --git a/src/Appwrite/Services/TablesDB.php b/src/Appwrite/Services/TablesDB.php index e5799e1..685378f 100644 --- a/src/Appwrite/Services/TablesDB.php +++ b/src/Appwrite/Services/TablesDB.php @@ -1325,6 +1325,174 @@ public function updateLineColumn(string $databaseId, string $tableId, string $ke ); } + /** + * Create a longtext column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a longtext column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateLongtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/longtext/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a mediumtext column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a mediumtext column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateMediumtextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/mediumtext/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Create a geometric point column. * @@ -1544,6 +1712,9 @@ public function createRelationshipColumn(string $databaseId, string $tableId, st * @param ?bool $encrypt * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.9.0. Please use `createTextColumn` instead. + * @see TablesDB::createTextColumn */ public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array { @@ -1594,6 +1765,9 @@ public function createStringColumn(string $databaseId, string $tableId, string $ * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateTextColumn` instead. + * @see TablesDB::updateTextColumn */ public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array { @@ -1623,6 +1797,90 @@ public function updateStringColumn(string $databaseId, string $tableId, string $ ); } + /** + * Create a text column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/text' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a text column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateTextColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/text/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Create a URL column. * @@ -1707,6 +1965,94 @@ public function updateUrlColumn(string $databaseId, string $tableId, string $key ); } + /** + * Create a varchar column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param int $size + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createVarcharColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['size'] = $size; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a varchar column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?int $size + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateVarcharColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/varchar/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + $apiParams['size'] = $size; + $apiParams['newKey'] = $newKey; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Get column by ID. * diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index 53c64b6..23f2d44 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -778,6 +778,108 @@ public function testMethodUpdateLineAttribute(): void { $this->assertSame($data, $response); } + public function testMethodCreateLongtextAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createLongtextAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateLongtextAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateLongtextAttribute( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMediumtextAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createMediumtextAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMediumtextAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateMediumtextAttribute( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreatePointAttribute(): void { $data = array( @@ -963,6 +1065,57 @@ public function testMethodUpdateStringAttribute(): void { $this->assertSame($data, $response); } + public function testMethodCreateTextAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createTextAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTextAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateTextAttribute( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateUrlAttribute(): void { $data = array( @@ -1016,6 +1169,60 @@ public function testMethodUpdateUrlAttribute(): void { $this->assertSame($data, $response); } + public function testMethodCreateVarcharAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createVarcharAttribute( + "", + "", + "", + 1, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateVarcharAttribute(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateVarcharAttribute( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodGetAttribute(): void { $data = array( diff --git a/tests/Appwrite/Services/TablesDBTest.php b/tests/Appwrite/Services/TablesDBTest.php index 93b330d..38893c1 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -778,6 +778,108 @@ public function testMethodUpdateLineColumn(): void { $this->assertSame($data, $response); } + public function testMethodCreateLongtextColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createLongtextColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateLongtextColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateLongtextColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateMediumtextColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createMediumtextColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateMediumtextColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateMediumtextColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreatePointColumn(): void { $data = array( @@ -963,6 +1065,57 @@ public function testMethodUpdateStringColumn(): void { $this->assertSame($data, $response); } + public function testMethodCreateTextColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createTextColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateTextColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateTextColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateUrlColumn(): void { $data = array( @@ -1016,6 +1169,60 @@ public function testMethodUpdateUrlColumn(): void { $this->assertSame($data, $response); } + public function testMethodCreateVarcharColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createVarcharColumn( + "", + "", + "", + 1, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateVarcharColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateVarcharColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodGetColumn(): void { $data = array( From 4508b2b0c4014939f88798eab1c3ddf60e51485a Mon Sep 17 00:00:00 2001 From: root Date: Mon, 2 Feb 2026 12:35:38 +0000 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f91f69d..e744356 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Add array-based enum parameters (e.g., `permissions: array`). * Breaking change: `Output` enum has been removed; use `ImageFormat` instead. * Add `getQueueAudits` support to `Health` service. +* Add longtext/mediumtext/text/varchar attribute and column helpers to `Databases` and `TablesDB` services. ## 19.1.0 @@ -47,4 +48,4 @@ * Add `dart38` and `flutter332` support to runtime models * Add `gif` support to `ImageFormat` enum * Add `upsertDocument` support to `Databases` service -* Add `sequence` support to `Document` model +* Add `sequence` support to `Document` model \ No newline at end of file