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..e7c7d5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log +## 19.1.1 + +* Update SDK as per latest server specs, these include - + * Updates to Runtime enums + * `Output` is now renamed to `ImageFormat` - Note that this is a breaking change + * Introduces Backups module for managing Database backups + * Introduces Organization module + ## 19.1.0 * Added ability to create columns and indexes synchronously while creating a table @@ -7,7 +15,8 @@ ## 19.0.0 * Rename `VCSDeploymentType` enum to `VCSReferenceType` -* Change `createTemplateDeployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) and `reference` parameters +* Change `createTemplateDeployment` method signature: replace `version` parameter with `type` (TemplateReferenceType) + and `reference` parameters * Add `Theme`, `Timezone` and `Output` enums ## 18.0.1 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..6f4db85 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).** +**This SDK is compatible with Appwrite server version latest. 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/backups.md b/docs/backups.md new file mode 100644 index 0000000..36a4ee9 --- /dev/null +++ b/docs/backups.md @@ -0,0 +1,172 @@ +# Backups Service + + +```http request +GET https://cloud.appwrite.io/v1/backups/archives +``` + +** List all archives for a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +POST https://cloud.appwrite.io/v1/backups/archives +``` + +** Create a new archive asynchronously for a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| services | array | Array of services to backup | | +| resourceId | string | Resource ID. When set, only this single resource will be backed up. | | + + +```http request +GET https://cloud.appwrite.io/v1/backups/archives/{archiveId} +``` + +** Get a backup archive using it's ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| archiveId | string | **Required** Archive ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + + +```http request +DELETE https://cloud.appwrite.io/v1/backups/archives/{archiveId} +``` + +** Delete an existing archive for a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| archiveId | string | **Required** Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + + +```http request +GET https://cloud.appwrite.io/v1/backups/policies +``` + +** List all policies for a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +POST https://cloud.appwrite.io/v1/backups/policies +``` + +** Create a new backup policy. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| policyId | string | Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Policy name. Max length: 128 chars. | | +| services | array | Array of services to backup | | +| resourceId | string | Resource ID. When set, only this single resource will be backed up. | | +| enabled | boolean | Is policy enabled? When set to 'disabled', no backups will be taken | 1 | +| retention | integer | Days to keep backups before deletion | | +| schedule | string | Schedule CRON syntax. | | + + +```http request +GET https://cloud.appwrite.io/v1/backups/policies/{policyId} +``` + +** Get a backup policy using it's ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| policyId | string | **Required** Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/backups/policies/{policyId} +``` + +** Update an existing policy using it's ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| policyId | string | **Required** Policy ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Policy name. Max length: 128 chars. | | +| retention | integer | Days to keep backups before deletion | | +| schedule | string | Cron expression | | +| enabled | boolean | Is Backup enabled? When set to 'disabled', No backup will be taken | | + + +```http request +DELETE https://cloud.appwrite.io/v1/backups/policies/{policyId} +``` + +** Delete a policy using it's ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| policyId | string | **Required** Policy ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + + +```http request +POST https://cloud.appwrite.io/v1/backups/restoration +``` + +** Create and trigger a new restoration for a backup on a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| archiveId | string | Backup archive ID to restore | | +| services | array | Array of services to restore | | +| newResourceId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| newResourceName | string | Database name. Max length: 128 chars. | | + + +```http request +GET https://cloud.appwrite.io/v1/backups/restorations +``` + +** List all backup restorations for a project. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +GET https://cloud.appwrite.io/v1/backups/restorations/{restorationId} +``` + +** Get the current status of a backup restoration. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| restorationId | string | **Required** Restoration ID. Choose a custom ID`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | + 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..c936f5c 100644 --- a/docs/examples/avatars/get-screenshot.md +++ b/docs/examples/avatars/get-screenshot.md @@ -4,7 +4,7 @@ use Appwrite\Client; use Appwrite\Services\Avatars; use Appwrite\Enums\Theme; use Appwrite\Enums\Timezone; -use Appwrite\Enums\Output; +use Appwrite\Enums\ImageFormat; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint @@ -36,5 +36,5 @@ $result = $avatars->getScreenshot( width: 800, // optional height: 600, // optional quality: 85, // optional - output: Output::JPG() // optional + output: ImageFormat::JPG() // optional ); \ No newline at end of file diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md new file mode 100644 index 0000000..4744efe --- /dev/null +++ b/docs/examples/backups/create-archive.md @@ -0,0 +1,16 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->createArchive( + services: [], + resourceId: '' // optional +); \ No newline at end of file diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md new file mode 100644 index 0000000..4b9aecf --- /dev/null +++ b/docs/examples/backups/create-policy.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->createPolicy( + policyId: '', + services: [], + retention: 1, + schedule: '', + name: '', // optional + resourceId: '', // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md new file mode 100644 index 0000000..1eb34f3 --- /dev/null +++ b/docs/examples/backups/create-restoration.md @@ -0,0 +1,18 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->createRestoration( + archiveId: '', + services: [], + newResourceId: '', // optional + newResourceName: '' // optional +); \ No newline at end of file diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md new file mode 100644 index 0000000..3c000f7 --- /dev/null +++ b/docs/examples/backups/delete-archive.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->deleteArchive( + archiveId: '' +); \ No newline at end of file diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md new file mode 100644 index 0000000..6a20d40 --- /dev/null +++ b/docs/examples/backups/delete-policy.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->deletePolicy( + policyId: '' +); \ No newline at end of file diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md new file mode 100644 index 0000000..b689fc4 --- /dev/null +++ b/docs/examples/backups/get-archive.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->getArchive( + archiveId: '' +); \ No newline at end of file diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md new file mode 100644 index 0000000..934e4a8 --- /dev/null +++ b/docs/examples/backups/get-policy.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->getPolicy( + policyId: '' +); \ No newline at end of file diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md new file mode 100644 index 0000000..ae1b135 --- /dev/null +++ b/docs/examples/backups/get-restoration.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->getRestoration( + restorationId: '' +); \ No newline at end of file diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md new file mode 100644 index 0000000..5810f6c --- /dev/null +++ b/docs/examples/backups/list-archives.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->listArchives( + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md new file mode 100644 index 0000000..df0cc41 --- /dev/null +++ b/docs/examples/backups/list-policies.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->listPolicies( + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md new file mode 100644 index 0000000..4d23414 --- /dev/null +++ b/docs/examples/backups/list-restorations.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->listRestorations( + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md new file mode 100644 index 0000000..0390d00 --- /dev/null +++ b/docs/examples/backups/update-policy.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$backups = new Backups($client); + +$result = $backups->updatePolicy( + policyId: '', + name: '', // optional + retention: 1, // optional + schedule: '', // optional + enabled: false // optional +); \ No newline at end of file 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/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/organizations/delete.md b/docs/examples/organizations/delete.md new file mode 100644 index 0000000..256edef --- /dev/null +++ b/docs/examples/organizations/delete.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$organizations = new Organizations($client); + +$result = $organizations->delete( + organizationId: '' +); \ No newline at end of file diff --git a/docs/examples/organizations/estimation-delete-organization.md b/docs/examples/organizations/estimation-delete-organization.md new file mode 100644 index 0000000..33bbef1 --- /dev/null +++ b/docs/examples/organizations/estimation-delete-organization.md @@ -0,0 +1,15 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$organizations = new Organizations($client); + +$result = $organizations->estimationDeleteOrganization( + organizationId: '' +); \ 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/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/organizations.md b/docs/organizations.md new file mode 100644 index 0000000..1b7105f --- /dev/null +++ b/docs/organizations.md @@ -0,0 +1,28 @@ +# Organizations Service + + +```http request +DELETE https://cloud.appwrite.io/v1/organizations/{organizationId} +``` + +** Delete an organization. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| organizationId | string | **Required** Team ID. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/organizations/{organizationId}/estimations/delete-organization +``` + +** Get estimation for deleting an organization. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| organizationId | string | **Required** Team ID. | | + diff --git a/docs/storage.md b/docs/storage.md index 8654029..c051c9b 100644 --- a/docs/storage.md +++ b/docs/storage.md @@ -31,9 +31,9 @@ POST https://cloud.appwrite.io/v1/storage/buckets | permissions | array | An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | fileSecurity | boolean | Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | 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. | [] | +| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 5GB. | [] | | 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 | @@ -67,9 +67,9 @@ PUT https://cloud.appwrite.io/v1/storage/buckets/{bucketId} | permissions | array | An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | fileSecurity | boolean | Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](https://appwrite.io/docs/permissions). | | | 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. | [] | +| maximumFileSize | integer | Maximum file size allowed in bytes. Maximum allowed value is 5GB. | [] | | 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..cbfc0f8 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/19.1.1 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '19.1.0', + 'x-sdk-version'=> '19.1.1', ]; + /** + * 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/BuildRuntime.php b/src/Appwrite/Enums/BuildRuntime.php index 0806513..32d94fa 100644 --- a/src/Appwrite/Enums/BuildRuntime.php +++ b/src/Appwrite/Enums/BuildRuntime.php @@ -28,9 +28,6 @@ class BuildRuntime implements JsonSerializable private static BuildRuntime $PYTHON312; private static BuildRuntime $PYTHONML311; private static BuildRuntime $PYTHONML312; - private static BuildRuntime $DENO121; - private static BuildRuntime $DENO124; - private static BuildRuntime $DENO135; private static BuildRuntime $DENO140; private static BuildRuntime $DENO146; private static BuildRuntime $DENO20; @@ -245,27 +242,6 @@ public static function PYTHONML312(): BuildRuntime } return self::$PYTHONML312; } - public static function DENO121(): BuildRuntime - { - if (!isset(self::$DENO121)) { - self::$DENO121 = new BuildRuntime('deno-1.21'); - } - return self::$DENO121; - } - public static function DENO124(): BuildRuntime - { - if (!isset(self::$DENO124)) { - self::$DENO124 = new BuildRuntime('deno-1.24'); - } - return self::$DENO124; - } - public static function DENO135(): BuildRuntime - { - if (!isset(self::$DENO135)) { - self::$DENO135 = new BuildRuntime('deno-1.35'); - } - return self::$DENO135; - } public static function DENO140(): BuildRuntime { if (!isset(self::$DENO140)) { 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/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/Runtime.php b/src/Appwrite/Enums/Runtime.php index 75e78e5..498952b 100644 --- a/src/Appwrite/Enums/Runtime.php +++ b/src/Appwrite/Enums/Runtime.php @@ -28,9 +28,6 @@ class Runtime implements JsonSerializable private static Runtime $PYTHON312; private static Runtime $PYTHONML311; private static Runtime $PYTHONML312; - private static Runtime $DENO121; - private static Runtime $DENO124; - private static Runtime $DENO135; private static Runtime $DENO140; private static Runtime $DENO146; private static Runtime $DENO20; @@ -245,27 +242,6 @@ public static function PYTHONML312(): Runtime } return self::$PYTHONML312; } - public static function DENO121(): Runtime - { - if (!isset(self::$DENO121)) { - self::$DENO121 = new Runtime('deno-1.21'); - } - return self::$DENO121; - } - public static function DENO124(): Runtime - { - if (!isset(self::$DENO124)) { - self::$DENO124 = new Runtime('deno-1.24'); - } - return self::$DENO124; - } - public static function DENO135(): Runtime - { - if (!isset(self::$DENO135)) { - self::$DENO135 = new Runtime('deno-1.35'); - } - return self::$DENO135; - } public static function DENO140(): Runtime { if (!isset(self::$DENO140)) { 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..7700148 100644 --- a/src/Appwrite/Services/Avatars.php +++ b/src/Appwrite/Services/Avatars.php @@ -11,7 +11,7 @@ use Appwrite\Enums\Flag; use Appwrite\Enums\Theme; use Appwrite\Enums\Timezone; -use Appwrite\Enums\Output; +use Appwrite\Enums\ImageFormat; class Avatars extends Service { @@ -391,11 +391,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/Backups.php b/src/Appwrite/Services/Backups.php new file mode 100644 index 0000000..2815da6 --- /dev/null +++ b/src/Appwrite/Services/Backups.php @@ -0,0 +1,410 @@ +client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new archive asynchronously for a project. + * + * @param array $services + * @param ?string $resourceId + * @throws AppwriteException + * @return array + */ + public function createArchive(array $services, ?string $resourceId = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/archives' + ); + + $apiParams = []; + $apiParams['services'] = $services; + $apiParams['resourceId'] = $resourceId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a backup archive using it's ID. + * + * @param string $archiveId + * @throws AppwriteException + * @return array + */ + public function getArchive(string $archiveId): array + { + $apiPath = str_replace( + ['{archiveId}'], + [$archiveId], + '/backups/archives/{archiveId}' + ); + + $apiParams = []; + $apiParams['archiveId'] = $archiveId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete an existing archive for a project. + * + * @param string $archiveId + * @throws AppwriteException + * @return string + */ + public function deleteArchive(string $archiveId): string + { + $apiPath = str_replace( + ['{archiveId}'], + [$archiveId], + '/backups/archives/{archiveId}' + ); + + $apiParams = []; + $apiParams['archiveId'] = $archiveId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List all policies for a project. + * + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listPolicies(?array $queries = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/policies' + ); + + $apiParams = []; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new backup policy. + * + * @param string $policyId + * @param array $services + * @param int $retention + * @param string $schedule + * @param ?string $name + * @param ?string $resourceId + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function createPolicy(string $policyId, array $services, int $retention, string $schedule, ?string $name = null, ?string $resourceId = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/policies' + ); + + $apiParams = []; + $apiParams['policyId'] = $policyId; + $apiParams['services'] = $services; + $apiParams['retention'] = $retention; + $apiParams['schedule'] = $schedule; + + if (!is_null($name)) { + $apiParams['name'] = $name; + } + $apiParams['resourceId'] = $resourceId; + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a backup policy using it's ID. + * + * @param string $policyId + * @throws AppwriteException + * @return array + */ + public function getPolicy(string $policyId): array + { + $apiPath = str_replace( + ['{policyId}'], + [$policyId], + '/backups/policies/{policyId}' + ); + + $apiParams = []; + $apiParams['policyId'] = $policyId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an existing policy using it's ID. + * + * @param string $policyId + * @param ?string $name + * @param ?int $retention + * @param ?string $schedule + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function updatePolicy(string $policyId, ?string $name = null, ?int $retention = null, ?string $schedule = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{policyId}'], + [$policyId], + '/backups/policies/{policyId}' + ); + + $apiParams = []; + $apiParams['policyId'] = $policyId; + $apiParams['name'] = $name; + $apiParams['retention'] = $retention; + + if (!is_null($schedule)) { + $apiParams['schedule'] = $schedule; + } + $apiParams['enabled'] = $enabled; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a policy using it's ID. + * + * @param string $policyId + * @throws AppwriteException + * @return string + */ + public function deletePolicy(string $policyId): string + { + $apiPath = str_replace( + ['{policyId}'], + [$policyId], + '/backups/policies/{policyId}' + ); + + $apiParams = []; + $apiParams['policyId'] = $policyId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create and trigger a new restoration for a backup on a project. + * + * @param string $archiveId + * @param array $services + * @param ?string $newResourceId + * @param ?string $newResourceName + * @throws AppwriteException + * @return array + */ + public function createRestoration(string $archiveId, array $services, ?string $newResourceId = null, ?string $newResourceName = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/restoration' + ); + + $apiParams = []; + $apiParams['archiveId'] = $archiveId; + $apiParams['services'] = $services; + + if (!is_null($newResourceId)) { + $apiParams['newResourceId'] = $newResourceId; + } + + if (!is_null($newResourceName)) { + $apiParams['newResourceName'] = $newResourceName; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List all backup restorations for a project. + * + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listRestorations(?array $queries = null): array + { + $apiPath = str_replace( + [], + [], + '/backups/restorations' + ); + + $apiParams = []; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get the current status of a backup restoration. + * + * @param string $restorationId + * @throws AppwriteException + * @return array + */ + public function getRestoration(string $restorationId): array + { + $apiPath = str_replace( + ['{restorationId}'], + [$restorationId], + '/backups/restorations/{restorationId}' + ); + + $apiParams = []; + $apiParams['restorationId'] = $restorationId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } +} \ No newline at end of file diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index e9796fa..53a56a3 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -2244,7 +2244,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 +2253,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 +2265,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..42e80d5 100644 --- a/src/Appwrite/Services/Functions.php +++ b/src/Appwrite/Services/Functions.php @@ -485,7 +485,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 +552,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/Organizations.php b/src/Appwrite/Services/Organizations.php new file mode 100644 index 0000000..9e340ab --- /dev/null +++ b/src/Appwrite/Services/Organizations.php @@ -0,0 +1,74 @@ +client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get estimation for deleting an organization. + * + * @param string $organizationId + * @throws AppwriteException + * @return array + */ + public function estimationDeleteOrganization(string $organizationId): array + { + $apiPath = str_replace( + ['{organizationId}'], + [$organizationId], + '/organizations/{organizationId}/estimations/delete-organization' + ); + + $apiParams = []; + $apiParams['organizationId'] = $organizationId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } +} \ No newline at end of file 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/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..5f74293 100644 --- a/tests/Appwrite/QueryTest.php +++ b/tests/Appwrite/QueryTest.php @@ -37,169 +37,250 @@ 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 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..d0c630c 100644 --- a/tests/Appwrite/Services/AvatarsTest.php +++ b/tests/Appwrite/Services/AvatarsTest.php @@ -6,6 +6,12 @@ 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\ImageFormat; final class AvatarsTest extends TestCase { private $client; @@ -20,13 +26,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 +41,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 +56,6 @@ public function testMethodGetFavicon(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -68,13 +71,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 +86,6 @@ public function testMethodGetImage(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -100,7 +101,6 @@ public function testMethodGetInitials(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -115,7 +115,6 @@ public function testMethodGetQR(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -131,7 +130,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/BackupsTest.php b/tests/Appwrite/Services/BackupsTest.php new file mode 100644 index 0000000..2c76ddf --- /dev/null +++ b/tests/Appwrite/Services/BackupsTest.php @@ -0,0 +1,275 @@ +client = Mockery::mock(Client::class); + $this->backups = new Backups($this->client); + } + + public function testMethodListArchives(): void { + + $data = array( + "total" => 5, + "archives" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->listArchives( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateArchive(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "policyId" => "did8jx6ws45jana098ab7", + "size" => 100000, + "status" => "completed", + "startedAt" => "2020-10-15T06:38:00.000+00:00", + "migrationId" => "did8jx6ws45jana098ab7", + "services" => array(), + "resources" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->createArchive( + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetArchive(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "policyId" => "did8jx6ws45jana098ab7", + "size" => 100000, + "status" => "completed", + "startedAt" => "2020-10-15T06:38:00.000+00:00", + "migrationId" => "did8jx6ws45jana098ab7", + "services" => array(), + "resources" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->getArchive( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteArchive(): void { + + $data = ''; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->deleteArchive( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListPolicies(): void { + + $data = array( + "total" => 5, + "policies" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->listPolicies( + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePolicy(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "Hourly backups", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "services" => array(), + "resources" => array(), + "retention" => 7, + "schedule" => "0 * * * *", + "enabled" => true); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->createPolicy( + "", + array(), + 1, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetPolicy(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "Hourly backups", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "services" => array(), + "resources" => array(), + "retention" => 7, + "schedule" => "0 * * * *", + "enabled" => true); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->getPolicy( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePolicy(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "name" => "Hourly backups", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "services" => array(), + "resources" => array(), + "retention" => 7, + "schedule" => "0 * * * *", + "enabled" => true); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->updatePolicy( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeletePolicy(): void { + + $data = ''; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->deletePolicy( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRestoration(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "archiveId" => "did8jx6ws45jana098ab7", + "policyId" => "did8jx6ws45jana098ab7", + "status" => "completed", + "startedAt" => "2020-10-15T06:38:00.000+00:00", + "migrationId" => "did8jx6ws45jana098ab7", + "services" => array(), + "resources" => array(), + "options" => "{databases.database[{oldId, newId, newName}]}"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->createRestoration( + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodListRestorations(): void { + + $data = array( + "total" => 5, + "restorations" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->listRestorations( + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetRestoration(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "archiveId" => "did8jx6ws45jana098ab7", + "policyId" => "did8jx6ws45jana098ab7", + "status" => "completed", + "startedAt" => "2020-10-15T06:38:00.000+00:00", + "migrationId" => "did8jx6ws45jana098ab7", + "services" => array(), + "resources" => array(), + "options" => "{databases.database[{oldId, newId, newName}]}"); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->backups->getRestoration( + "" + ); + + $this->assertSame($data, $response); + } + +} diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index 8aa6a6b..10b7960 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -6,6 +6,9 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\RelationshipType; +use Appwrite\Enums\RelationMutate; +use Appwrite\Enums\IndexType; final class DatabasesTest extends TestCase { private $client; @@ -20,8 +23,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 +43,9 @@ 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", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -60,8 +63,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 +83,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 +103,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 +124,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 +141,6 @@ public function testMethodDeleteTransaction(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -162,8 +160,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 +181,9 @@ 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", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -206,8 +204,9 @@ 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", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -225,7 +224,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -241,8 +239,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 +264,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 +291,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 +317,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()) @@ -342,7 +336,6 @@ public function testMethodDeleteCollection(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -359,8 +352,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 +375,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 +400,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 +427,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 +453,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 +480,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 +506,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 +534,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 +562,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 +589,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 +614,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 +640,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 +665,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 +692,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 +718,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 +744,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 +769,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 +794,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 +819,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 +844,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 +869,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 +900,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 +910,7 @@ public function testMethodCreateRelationshipAttribute(): void { "", "", "", - "oneToOne" + RelationshipType::ONETOONE() ); $this->assertSame($data, $response); @@ -955,8 +926,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 +953,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 +980,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 +1006,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 +1025,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 +1051,6 @@ public function testMethodDeleteAttribute(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1107,8 +1079,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 +1098,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 +1121,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 +1141,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 +1160,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 +1179,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 +1197,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 +1220,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 +1244,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 +1253,7 @@ public function testMethodUpsertDocument(): void { $response = $this->databases->upsertDocument( "", "", - "", - array() + "" ); $this->assertSame($data, $response); @@ -1306,8 +1268,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 +1287,6 @@ public function testMethodDeleteDocument(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1349,8 +1309,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 +1334,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 +1354,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 +1379,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 +1389,7 @@ public function testMethodCreateIndex(): void { "", "", "", - "key", + IndexType::KEY(), array() ); @@ -1451,8 +1407,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 +1426,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..d7916ad 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -6,6 +6,11 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\Runtime; +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 +25,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 +67,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 +76,7 @@ public function testMethodCreate(): void { $response = $this->functions->create( "", "", - "node-14.5" + Runtime::NODE145() ); $this->assertSame($data, $response); @@ -83,8 +86,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 +102,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 +144,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 +187,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 +205,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -248,8 +246,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 +264,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 +306,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 +350,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 +393,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 +404,7 @@ public function testMethodCreateTemplateDeployment(): void { "", "", "", - "commit", + TemplateReferenceType::COMMIT(), "" ); @@ -447,8 +440,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 +448,7 @@ public function testMethodCreateVcsDeployment(): void { $response = $this->functions->createVcsDeployment( "", - "branch", + VCSReferenceType::BRANCH(), "" ); @@ -492,8 +484,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 +502,6 @@ public function testMethodDeleteDeployment(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -528,7 +518,6 @@ public function testMethodGetDeploymentDownload(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -570,8 +559,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 +577,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 +609,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 +641,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 +659,6 @@ public function testMethodDeleteExecution(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -691,8 +675,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 +698,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 +723,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 +747,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 +766,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..e3e5849 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()) @@ -56,8 +55,7 @@ public function testMethodGetCache(): void { $data = array( "name" => "database", "ping" => 128, - "status" => "pass",); - + "status" => "pass"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -77,8 +75,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()) @@ -95,8 +92,7 @@ public function testMethodGetDB(): void { $data = array( "name" => "database", "ping" => 128, - "status" => "pass",); - + "status" => "pass"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -113,8 +109,7 @@ public function testMethodGetPubSub(): void { $data = array( "name" => "database", "ping" => 128, - "status" => "pass",); - + "status" => "pass"); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -129,8 +124,7 @@ public function testMethodGetPubSub(): void { public function testMethodGetQueueBuilds(): void { $data = array( - "size" => 8,); - + "size" => 8); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -145,8 +139,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 +154,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 +169,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 +184,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 +200,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 +215,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 +230,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 +245,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 +260,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 +275,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 +290,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 +305,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 +322,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 +339,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 +356,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/OrganizationsTest.php b/tests/Appwrite/Services/OrganizationsTest.php new file mode 100644 index 0000000..ad96680 --- /dev/null +++ b/tests/Appwrite/Services/OrganizationsTest.php @@ -0,0 +1,50 @@ +client = Mockery::mock(Client::class); + $this->organizations = new Organizations($this->client); + } + + public function testMethodDelete(): void { + + $data = ''; + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->organizations->delete( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodEstimationDeleteOrganization(): void { + + $data = array( + "unpaidInvoices" => array()); + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->organizations->estimationDeleteOrganization( + "" + ); + + $this->assertSame($data, $response); + } + +} 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..42ed526 100644 --- a/tests/Appwrite/Services/TablesDBTest.php +++ b/tests/Appwrite/Services/TablesDBTest.php @@ -6,6 +6,9 @@ use Appwrite\InputFile; use Mockery; use PHPUnit\Framework\TestCase; +use Appwrite\Enums\RelationshipType; +use Appwrite\Enums\RelationMutate; +use Appwrite\Enums\IndexType; final class TablesDBTest extends TestCase { private $client; @@ -20,8 +23,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 +43,9 @@ 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", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -60,8 +63,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 +83,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 +103,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 +124,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 +141,6 @@ public function testMethodDeleteTransaction(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -162,8 +160,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 +181,9 @@ 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", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -206,8 +204,9 @@ 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", + "policies" => array(), + "archives" => array()); $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) @@ -225,7 +224,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -241,8 +239,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 +264,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 +291,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 +317,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()) @@ -342,7 +336,6 @@ public function testMethodDeleteTable(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -359,8 +352,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 +375,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 +400,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 +427,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 +453,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 +480,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 +506,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 +534,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 +562,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 +589,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 +614,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 +640,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 +665,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 +692,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 +718,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 +744,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 +769,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 +794,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 +819,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 +844,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 +869,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 +900,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 +910,7 @@ public function testMethodCreateRelationshipColumn(): void { "", "", "", - "oneToOne" + RelationshipType::ONETOONE() ); $this->assertSame($data, $response); @@ -955,8 +926,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 +953,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 +980,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 +1006,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 +1025,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 +1051,6 @@ public function testMethodDeleteColumn(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1107,8 +1079,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 +1098,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 +1123,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 +1133,7 @@ public function testMethodCreateIndex(): void { "", "", "", - "key", + IndexType::KEY(), array() ); @@ -1182,8 +1151,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 +1170,6 @@ public function testMethodDeleteIndex(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1220,8 +1187,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 +1210,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 +1230,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 +1249,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 +1268,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 +1286,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 +1309,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 +1333,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 +1357,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 +1376,6 @@ public function testMethodDeleteRow(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -1441,8 +1398,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 +1423,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..d909af5 100644 --- a/tests/Appwrite/Services/TeamsTest.php +++ b/tests/Appwrite/Services/TeamsTest.php @@ -20,8 +20,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 +40,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 +62,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 +83,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 +101,6 @@ public function testMethodDelete(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -121,8 +116,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 +144,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()) @@ -180,8 +173,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 +202,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()) @@ -230,7 +221,6 @@ public function testMethodDeleteMembership(): void { $data = ''; - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -258,8 +248,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 +268,6 @@ public function testMethodGetPrefs(): void { $data = array(); - $this->client ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) ->andReturn($data); @@ -295,7 +283,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())