Initialize Rector for PHPUnit tests (#12495)

This commit is contained in:
Chirag Aggarwal authored and GitHub committed 2026-06-04 18:19:56 +05:30
1 parent ba71f9bff0
commit 1baf576299
264 files changed
+3421 -3059

No files matched your search

+20
View File
@@ -139,6 +139,26 @@ jobs:
- name: Run Linter
run: composer lint
refactor:
name: Checks / Refactor
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup PHP
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: '8.3'
tools: composer:v2
coverage: none
- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-reqs
- name: Run Rector
run: composer refactor:check
analyze:
name: Checks / Analyze
runs-on: ubuntu-latest
+4 -1
View File
@@ -16,6 +16,8 @@
"analyze": "./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=1G",
"bench": "vendor/bin/phpbench run --report=benchmark",
"check": "./vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=1G",
"refactor": "vendor/bin/rector process",
"refactor:check": "vendor/bin/rector process --dry-run",
"installer:clean": "php src/Appwrite/Platform/Installer/Server.php --clean",
"installer:dev": "docker compose build && composer installer:clean && php src/Appwrite/Platform/Installer/Server.php --docker"
},
@@ -107,7 +109,8 @@
"phpstan/phpstan": "^2.0",
"textalk/websocket": "1.5.*",
"czproject/git-php": "4.*",
"laravel/pint": "1.*"
"laravel/pint": "1.*",
"rector/rector": "^2.4"
},
"provide": {
"ext-phpiredis": "*"
Generated
+61 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "0c23c30bba86ad84377d4d1abce0992a",
"content-hash": "5cc3d8a63a229bf9363c4baa8d985f7c",
"packages": [
{
"name": "adhocore/jwt",
@@ -6893,6 +6893,66 @@
],
"time": "2026-05-27T14:01:10+00:00"
},
{
"name": "rector/rector",
"version": "2.4.5",
"source": {
"type": "git",
"url": "https://github.com/rectorphp/rector.git",
"reference": "cbd86024be5014d3c14d9f0b3f7aae8ecbffd62c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/rectorphp/rector/zipball/cbd86024be5014d3c14d9f0b3f7aae8ecbffd62c",
"reference": "cbd86024be5014d3c14d9f0b3f7aae8ecbffd62c",
"shasum": ""
},
"require": {
"php": "^7.4|^8.0",
"phpstan/phpstan": "^2.1.56"
},
"conflict": {
"rector/rector-doctrine": "*",
"rector/rector-downgrade-php": "*",
"rector/rector-phpunit": "*",
"rector/rector-symfony": "*"
},
"suggest": {
"ext-dom": "To manipulate phpunit.xml via the custom-rule command"
},
"bin": [
"bin/rector"
],
"type": "library",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Instant Upgrade and Automated Refactoring of any PHP code",
"homepage": "https://getrector.com/",
"keywords": [
"automation",
"dev",
"migration",
"refactoring"
],
"support": {
"issues": "https://github.com/rectorphp/rector/issues",
"source": "https://github.com/rectorphp/rector/tree/2.4.5"
},
"funding": [
{
"url": "https://github.com/tomasvotruba",
"type": "github"
}
],
"time": "2026-05-26T21:03:22+00:00"
},
{
"name": "sebastian/cli-parser",
"version": "4.2.1",
+19
View File
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;
return RectorConfig::configure()
->withBootstrapFiles([
__DIR__ . '/app/init/constants.php',
])
->withPaths([
__DIR__ . '/tests',
])
->withSkipPath(__DIR__ . '/vendor')
->withSkipPath(__DIR__ . '/tests/resources')
->withSets([
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
]);
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\General;
use CURLFile;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\System\System;
class AbuseTest extends Scope
final class AbuseTest extends Scope
{
use ProjectCustom;
use SideNone;
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\General;
use Appwrite\ID;
@@ -11,7 +13,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class CompressionTest extends Scope
final class CompressionTest extends Scope
{
use ProjectCustom;
use SideServer;
+5 -3
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\General;
use Tests\E2E\Client;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideNone;
use Utopia\Config\Config;
class HTTPTest extends Scope
final class HTTPTest extends Scope
{
use ProjectNone;
use SideNone;
@@ -54,7 +56,7 @@ class HTTPTest extends Scope
]));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertStringContainsString('# humanstxt.org/', $response['body']);
$this->assertStringContainsString('# humanstxt.org/', (string) $response['body']);
}
public function testRobots()
@@ -67,7 +69,7 @@ class HTTPTest extends Scope
]));
$this->assertEquals(200, $response['headers']['status-code'], "Simple GET /robots.txt HTTP request failed: " . \json_encode($response));
$this->assertStringContainsString('# robotstxt.org/', $response['body']);
$this->assertStringContainsString('# robotstxt.org/', (string) $response['body']);
}
public function testAcmeChallenge()
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\General;
use Appwrite\Extend\Exception;
@@ -9,7 +11,7 @@ use Tests\E2E\Scopes\ProjectConsole;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class HooksTest extends Scope
final class HooksTest extends Scope
{
use ProjectConsole;
use SideClient;
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\General;
use Tests\E2E\Client;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class PingTest extends Scope
final class PingTest extends Scope
{
use ProjectCustom;
use SideClient;
+14 -12
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\General;
use Appwrite\Platform\Modules\Compute\Specification;
@@ -19,7 +21,7 @@ use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\System\System;
use WebSocket\Client as WebSocketClient;
class UsageTest extends Scope
final class UsageTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -288,8 +290,8 @@ class UsageTest extends Scope
);
$this->assertEquals('90d', $response['body']['range']);
$this->assertEquals(90, count($response['body']['users']));
$this->assertEquals(90, count($response['body']['sessions']));
$this->assertCount(90, $response['body']['users']);
$this->assertCount(90, $response['body']['sessions']);
$this->assertEquals((self::CREATE / 2), $response['body']['users'][array_key_last($response['body']['users'])]['value']);
});
}
@@ -412,7 +414,7 @@ class UsageTest extends Scope
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('90d', $response['body']['range']);
$this->assertEquals(90, count($response['body']['presences']));
$this->assertCount(90, $response['body']['presences']);
$this->assertEquals(2, $response['body']['usersOnlineTotal']);
$this->assertEquals(2, $response['body']['presences'][array_key_last($response['body']['presences'])]['value']);
$this->validateDates($response['body']['presences']);
@@ -1707,7 +1709,7 @@ class UsageTest extends Scope
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(24, count($response['body']));
$this->assertCount(24, $response['body']);
$this->assertEquals('30d', $response['body']['range']);
$this->assertIsArray($response['body']['deployments']);
$this->assertIsArray($response['body']['deploymentsStorage']);
@@ -1734,8 +1736,8 @@ class UsageTest extends Scope
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(25, count($response['body']));
$this->assertEquals($response['body']['range'], '30d');
$this->assertCount(25, $response['body']);
$this->assertEquals('30d', $response['body']['range']);
$this->assertIsArray($response['body']['functions']);
$this->assertIsArray($response['body']['deployments']);
$this->assertIsArray($response['body']['deploymentsStorage']);
@@ -1845,7 +1847,7 @@ class UsageTest extends Scope
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(30, count($response['body']));
$this->assertCount(30, $response['body']);
$this->assertEquals('30d', $response['body']['range']);
$this->assertIsArray($response['body']['deployments']);
$this->assertEquals($deploymentsSuccess, $response['body']['buildsSuccessTotal']);
@@ -1879,8 +1881,8 @@ class UsageTest extends Scope
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(31, count($response['body']));
$this->assertEquals($response['body']['range'], '30d');
$this->assertCount(31, $response['body']);
$this->assertEquals('30d', $response['body']['range']);
$this->assertIsArray($response['body']['sites']);
$this->assertIsArray($response['body']['deployments']);
$this->assertIsArray($response['body']['deploymentsStorage']);
@@ -1957,7 +1959,7 @@ class UsageTest extends Scope
);
$this->assertEquals(200, $functionsResponse['headers']['status-code']);
$this->assertEquals(24, count($functionsResponse['body']));
$this->assertCount(24, $functionsResponse['body']);
$this->assertEquals('30d', $functionsResponse['body']['range']);
$projectResponse = $this->client->call(
@@ -1996,7 +1998,7 @@ class UsageTest extends Scope
);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(24, count($response['body']));
$this->assertCount(24, $response['body']);
$this->assertEquals('30d', $response['body']['range']);
// Check if the new values are greater than the old values
-110
View File
@@ -1,110 +0,0 @@
<?php
namespace Tests\E2E\Scopes;
/**
* API configuration trait for VectorsDB database API.
* Uses: /vectorsdb, collections, documents, indexes
*/
trait ApiVectorsDB
{
protected function getApiBasePath(): string
{
return '/vectorsdb';
}
protected function getDatabaseType(): string
{
return 'vectorsdb';
}
protected function getContainerResource(): string
{
return 'collections';
}
protected function getContainerIdParam(): string
{
return 'collectionId';
}
protected function getSchemaResource(): string
{
return 'attributes';
}
protected function getSchemaParam(): string
{
return 'attribute';
}
protected function getRecordResource(): string
{
return 'documents';
}
protected function getRecordIdParam(): string
{
return 'documentId';
}
protected function getSecurityParam(): string
{
return 'documentSecurity';
}
protected function getRelatedIdParam(): string
{
return 'relatedCollectionId';
}
protected function getRelatedResourceKey(): string
{
return 'relatedCollection';
}
protected function getContainerIdResponseKey(): string
{
return '$collectionId';
}
protected function getOppositeContainerIdResponseKey(): string
{
return '$tableId';
}
protected function getIndexAttributesParam(): string
{
return 'attributes';
}
protected function getSecurityResponseKey(): string
{
return 'documentSecurity';
}
protected function getSupportForAttributes(): bool
{
return false;
}
protected function getSupportForRelationships(): bool
{
return false;
}
protected function getSupportForIntegerIds(): bool
{
return false;
}
protected function getSupportForOperators(): bool
{
return false;
}
protected function getSupportForSpatials(): bool
{
return false;
}
}
+2
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Scopes;
use Appwrite\Tests\Async;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Account;
use Tests\E2E\Client;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\Helpers\ID;
class AccountConsoleClientTest extends Scope
final class AccountConsoleClientTest extends Scope
{
use AccountBase;
use ProjectConsole;
@@ -36,7 +38,7 @@ class AccountConsoleClientTest extends Scope
'name' => $name,
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals(201, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'origin' => 'http://localhost',
@@ -47,7 +49,7 @@ class AccountConsoleClientTest extends Scope
'password' => $password,
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals(201, $response['headers']['status-code']);
$session = $response['cookies']['a_session_' . $this->getProject()['$id']];
@@ -61,7 +63,7 @@ class AccountConsoleClientTest extends Scope
'teamId' => 'unique()',
'name' => 'myteam'
]);
$this->assertEquals($team['headers']['status-code'], 201);
$this->assertEquals(201, $team['headers']['status-code']);
// Account deletion should succeed even with active membership
$response = $this->client->call(Client::METHOD_DELETE, '/account', array_merge([
@@ -94,7 +96,7 @@ class AccountConsoleClientTest extends Scope
'name' => $name,
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals(201, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'origin' => 'http://localhost',
@@ -105,7 +107,7 @@ class AccountConsoleClientTest extends Scope
'password' => $password,
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals(201, $response['headers']['status-code']);
$session = $response['cookies']['a_session_' . $this->getProject()['$id']];
@@ -169,10 +171,10 @@ class AccountConsoleClientTest extends Scope
$lastEmail = $this->getLastEmailByAddress($email);
$this->assertNotEmpty($lastEmail, 'Email not found for address: ' . $email);
$this->assertStringContainsString('Security alert: new session', $lastEmail['subject']);
$this->assertStringContainsString($response['body']['ip'], $lastEmail['text']); // IP Address
$this->assertStringContainsString('Unknown', $lastEmail['text']); // Country
$this->assertStringContainsString($response['body']['clientName'], $lastEmail['text']); // Client name
$this->assertStringContainsString('Security alert: new session', (string) $lastEmail['subject']);
$this->assertStringContainsString($response['body']['ip'], (string) $lastEmail['text']); // IP Address
$this->assertStringContainsString('Unknown', (string) $lastEmail['text']); // Country
$this->assertStringContainsString($response['body']['clientName'], (string) $lastEmail['text']); // Client name
$this->assertStringContainsStringIgnoringCase('Appwrite logo', $lastEmail['html']);
// Verify no alert sent in OTP login
@@ -185,7 +187,7 @@ class AccountConsoleClientTest extends Scope
'email' => 'otpuser2@appwrite.io'
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['$createdAt']);
$this->assertNotEmpty($response['body']['userId']);
@@ -247,7 +249,7 @@ class AccountConsoleClientTest extends Scope
'name' => $name,
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals(201, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([
'origin' => 'http://localhost',
@@ -258,7 +260,7 @@ class AccountConsoleClientTest extends Scope
'password' => $password,
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals(201, $response['headers']['status-code']);
$session = $response['cookies']['a_session_' . $this->getProject()['$id']];
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Account;
use Appwrite\Tests\Retry;
@@ -14,7 +16,7 @@ use Utopia\Database\Validator\Datetime as DatetimeValidator;
use function sleep;
class AccountCustomClientTest extends Scope
final class AccountCustomClientTest extends Scope
{
use AccountBase;
use ProjectCustom;
@@ -383,7 +385,7 @@ class AccountCustomClientTest extends Scope
]);
$lastEmail = $this->getLastEmailByAddress($email, function ($email) {
$this->assertStringContainsString('Password Reset', $email['subject']);
$this->assertStringContainsString('Password Reset', (string) $email['subject']);
});
$tokens = $this->extractQueryParamsFromEmailLink($lastEmail['html']);
$recovery = $tokens['secret'];
@@ -410,7 +412,7 @@ class AccountCustomClientTest extends Scope
// Use a truly unique phone number for parallel test safety
// Combine microtime, PID, and random digits to avoid collisions across parallel processes
$number = '+1' . substr(str_replace('.', '', microtime(true)) . getmypid() . random_int(100, 999), -9);
$number = '+1' . substr(str_replace('.', '', (string) microtime(true)) . getmypid() . random_int(100, 999), -9);
$response = $this->client->call(Client::METHOD_POST, '/account/tokens/phone', array_merge([
'origin' => 'http://localhost',
@@ -569,7 +571,7 @@ class AccountCustomClientTest extends Scope
$data = $this->setupPhoneConvertedToPassword();
$session = $data['session'];
// Use a truly unique phone number to avoid target conflicts across parallel test runs
$newPhone = '+456' . substr(str_replace('.', '', microtime(true)) . getmypid() . random_int(100, 999), -8);
$newPhone = '+456' . substr(str_replace('.', '', (string) microtime(true)) . getmypid() . random_int(100, 999), -8);
$response = $this->client->call(Client::METHOD_PATCH, '/account/phone', array_merge([
'origin' => 'http://localhost',
@@ -1128,7 +1130,7 @@ class AccountCustomClientTest extends Scope
$this->assertIsArray($logsWithIncludeTotalFalse['body']);
$this->assertIsArray($logsWithIncludeTotalFalse['body']['logs']);
$this->assertIsInt($logsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $logsWithIncludeTotalFalse['body']['total']);
$this->assertSame(0, $logsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($logsWithIncludeTotalFalse['body']['logs']));
/**
@@ -1901,7 +1903,7 @@ class AccountCustomClientTest extends Scope
$this->assertTrue((new DatetimeValidator())->isValid($response['body']['expire']));
$lastEmail = $this->getLastEmailByAddress($email, function ($email) {
$this->assertStringContainsString('Password Reset', $email['subject']);
$this->assertStringContainsString('Password Reset', (string) $email['subject']);
});
$this->assertNotEmpty($lastEmail, 'Email not found for address: ' . $email);
@@ -2081,10 +2083,10 @@ class AccountCustomClientTest extends Scope
$lastEmail = $this->getLastEmailByAddress($email);
$this->assertNotEmpty($lastEmail, 'Email not found for address: ' . $email);
$this->assertStringContainsString('Security alert: new session', $lastEmail['subject']);
$this->assertStringContainsString($response['body']['ip'], $lastEmail['text']); // IP Address
$this->assertStringContainsString('Unknown', $lastEmail['text']); // Country
$this->assertStringContainsString($response['body']['clientName'], $lastEmail['text']); // Client name
$this->assertStringContainsString('Security alert: new session', (string) $lastEmail['subject']);
$this->assertStringContainsString($response['body']['ip'], (string) $lastEmail['text']); // IP Address
$this->assertStringContainsString('Unknown', (string) $lastEmail['text']); // Country
$this->assertStringContainsString($response['body']['clientName'], (string) $lastEmail['text']); // Client name
$this->assertStringNotContainsStringIgnoringCase('Appwrite logo', $lastEmail['html']);
// Verify no alert sent in OTP login
@@ -2097,7 +2099,7 @@ class AccountCustomClientTest extends Scope
'email' => 'otpuser3@appwrite.io'
]);
$this->assertEquals($response['headers']['status-code'], 201);
$this->assertEquals(201, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertNotEmpty($response['body']['$createdAt']);
$this->assertNotEmpty($response['body']['userId']);
@@ -2547,7 +2549,7 @@ class AccountCustomClientTest extends Scope
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertStringContainsString('a_session_' . $this->getProject()['$id'] . '=deleted', $response['headers']['set-cookie']);
$this->assertStringContainsString('a_session_' . $this->getProject()['$id'] . '=deleted', (string) $response['headers']['set-cookie']);
$this->assertEquals('[]', $response['headers']['x-fallback-cookies']);
$response = $this->client->call(Client::METHOD_GET, '/account', array_merge([
@@ -3459,7 +3461,7 @@ class AccountCustomClientTest extends Scope
public function testUpdatePhone(): void
{
$data = $this->setupPhoneConvertedToPassword();
$newPhone = '+456' . substr(str_replace('.', '', microtime(true)) . getmypid() . random_int(100, 999), -8);
$newPhone = '+456' . substr(str_replace('.', '', (string) microtime(true)) . getmypid() . random_int(100, 999), -8);
$session = $data['session'];
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Account;
use Tests\E2E\Client;
@@ -9,7 +11,7 @@ use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
class AccountCustomServerTest extends Scope
final class AccountCustomServerTest extends Scope
{
use AccountBase;
use ProjectCustom;
@@ -289,7 +291,7 @@ class AccountCustomServerTest extends Scope
$this->getHeaders(),
));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertArrayHasKey('accessedAt', $response['body']);
$this->assertNotEmpty($response['body']['accessedAt']);
@@ -375,7 +377,7 @@ class AccountCustomServerTest extends Scope
]
));
$this->assertEquals($response['headers']['status-code'], 200);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertNotEmpty($response['body']);
$this->assertNotEmpty($response['body']['$id']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($response['body']['registration']));
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Advisor;
use Tests\E2E\Client;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Helpers\ID;
class AdvisorCustomServerTest extends Scope
final class AdvisorCustomServerTest extends Scope
{
use AdvisorBase;
use ProjectCustom;
@@ -1,12 +1,14 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Avatars;
use Tests\E2E\Scopes\ProjectConsole;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class AvatarsConsoleClientTest extends Scope
final class AvatarsConsoleClientTest extends Scope
{
use AvatarsBase;
use ProjectConsole;
@@ -1,12 +1,14 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Avatars;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class AvatarsCustomClientTest extends Scope
final class AvatarsCustomClientTest extends Scope
{
use AvatarsBase;
use ProjectCustom;
@@ -1,12 +1,14 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Avatars;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class AvatarsCustomServerTest extends Scope
final class AvatarsCustomServerTest extends Scope
{
use AvatarsBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Console;
use Tests\E2E\Client;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectConsole;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class ConsoleConsoleClientTest extends Scope
final class ConsoleConsoleClientTest extends Scope
{
use ConsoleBase;
use ProjectConsole;
@@ -53,7 +55,7 @@ class ConsoleConsoleClientTest extends Scope
$this->assertIsInt($response['body']['total']);
$this->assertIsArray($response['body']['oAuth2Providers']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertEquals($response['body']['total'], \count($response['body']['oAuth2Providers']));
$this->assertCount($response['body']['total'], $response['body']['oAuth2Providers']);
$providerIds = \array_column($response['body']['oAuth2Providers'], '$id');
$this->assertEquals('amazon', $providerIds[0]);
@@ -142,7 +144,7 @@ class ConsoleConsoleClientTest extends Scope
$this->assertIsInt($response['body']['total']);
$this->assertIsArray($response['body']['scopes']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertEquals($response['body']['total'], \count($response['body']['scopes']));
$this->assertCount($response['body']['total'], $response['body']['scopes']);
$scopeIds = \array_column($response['body']['scopes'], '$id');
@@ -187,7 +189,7 @@ class ConsoleConsoleClientTest extends Scope
$this->assertIsInt($response['body']['total']);
$this->assertIsArray($response['body']['scopes']);
$this->assertGreaterThan(0, $response['body']['total']);
$this->assertEquals($response['body']['total'], \count($response['body']['scopes']));
$this->assertCount($response['body']['total'], $response['body']['scopes']);
$scopeIds = \array_column($response['body']['scopes'], '$id');
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Console;
use Tests\E2E\Client;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class ConsoleCustomClientTest extends Scope
final class ConsoleCustomClientTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Console;
use Tests\E2E\Client;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class ConsoleCustomServerTest extends Scope
final class ConsoleCustomServerTest extends Scope
{
use ProjectCustom;
use SideServer;
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Console;
use Appwrite\Extend\Exception;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\ProjectConsole;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class ModeTest extends Scope
final class ModeTest extends Scope
{
use ProjectConsole;
use SideClient;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\DocumentsDB;
use Tests\E2E\Scopes\ProjectCustom;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Database;
use Utopia\Database\Helpers\ID;
class DocumentsDBIndexTest extends Scope
final class DocumentsDBIndexTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases;
use Tests\E2E\Scopes\ApiDocumentsDB;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideConsole;
class DocumentsDBConsoleClientTest extends Scope
final class DocumentsDBConsoleClientTest extends Scope
{
use DatabasesBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases;
use Tests\E2E\Scopes\ApiDocumentsDB;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class DocumentsDBCustomClientTest extends Scope
final class DocumentsDBCustomClientTest extends Scope
{
use DatabasesBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases;
use Tests\E2E\Scopes\ApiDocumentsDB;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class DocumentsDBCustomServerTest extends Scope
final class DocumentsDBCustomServerTest extends Scope
{
use DatabasesBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Legacy;
use Tests\E2E\Client;
@@ -13,7 +15,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DatabasesStringTypesTest extends Scope
final class DatabasesStringTypesTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases;
use Tests\E2E\Scopes\ApiLegacy;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideConsole;
class LegacyConsoleClientTest extends Scope
final class LegacyConsoleClientTest extends Scope
{
use DatabasesBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases;
use Tests\E2E\Scopes\ApiLegacy;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class LegacyCustomClientTest extends Scope
final class LegacyCustomClientTest extends Scope
{
use DatabasesBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases;
use Tests\E2E\Scopes\ApiLegacy;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class LegacyCustomServerTest extends Scope
final class LegacyCustomServerTest extends Scope
{
use DatabasesBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -13,7 +15,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\Authorization;
class DocumentsDBPermissionsGuestTest extends Scope
final class DocumentsDBPermissionsGuestTest extends Scope
{
use DatabasesPermissionsBase;
use ProjectCustom;
@@ -92,16 +94,14 @@ class DocumentsDBPermissionsGuestTest extends Scope
];
}
public static function permissionsProvider(): array
public static function permissionsProvider(): \Iterator
{
return [
[[Permission::read(Role::any())]],
[[Permission::read(Role::users())]],
[[Permission::update(Role::any()), Permission::delete(Role::any())]],
[[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())]],
[[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())]],
[[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())]],
];
yield [[Permission::read(Role::any())]];
yield [[Permission::read(Role::users())]];
yield [[Permission::update(Role::any()), Permission::delete(Role::any())]];
yield [[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())]];
yield [[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())]];
yield [[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())]];
}
#[DataProvider('permissionsProvider')]
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DocumentsDBPermissionsMemberTest extends Scope
final class DocumentsDBPermissionsMemberTest extends Scope
{
use DatabasesPermissionsBase;
use ProjectCustom;
@@ -29,22 +31,20 @@ class DocumentsDBPermissionsMemberTest extends Scope
];
}
public static function permissionsProvider(): array
public static function permissionsProvider(): \Iterator
{
return [
[[Permission::read(Role::any())], 1, 1, 1],
[[Permission::read(Role::users())], 1, 1, 1],
[[Permission::read(Role::user(ID::custom('random')))], 1, 1, 0],
[[Permission::read(Role::user(ID::custom('lorem'))), Permission::update(Role::user('lorem')), Permission::delete(Role::user('lorem'))], 1, 1, 0],
[[Permission::read(Role::user(ID::custom('dolor'))), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 1, 1, 0],
[[Permission::read(Role::user(ID::custom('dolor'))), Permission::read(Role::user('lorem')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 1, 1, 0],
[[Permission::update(Role::any()), Permission::delete(Role::any())], 1, 1, 0],
[[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())], 1, 1, 1],
[[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())], 1, 1, 1],
[[Permission::read(Role::user(ID::custom('user1')))], 1, 1, 1],
[[Permission::read(Role::user(ID::custom('user1'))), Permission::read(Role::user(ID::custom('user1')))], 1, 1, 1],
[[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())], 1, 1, 1],
];
yield [[Permission::read(Role::any())], 1, 1, 1];
yield [[Permission::read(Role::users())], 1, 1, 1];
yield [[Permission::read(Role::user(ID::custom('random')))], 1, 1, 0];
yield [[Permission::read(Role::user(ID::custom('lorem'))), Permission::update(Role::user('lorem')), Permission::delete(Role::user('lorem'))], 1, 1, 0];
yield [[Permission::read(Role::user(ID::custom('dolor'))), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 1, 1, 0];
yield [[Permission::read(Role::user(ID::custom('dolor'))), Permission::read(Role::user('lorem')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 1, 1, 0];
yield [[Permission::update(Role::any()), Permission::delete(Role::any())], 1, 1, 0];
yield [[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())], 1, 1, 1];
yield [[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())], 1, 1, 1];
yield [[Permission::read(Role::user(ID::custom('user1')))], 1, 1, 1];
yield [[Permission::read(Role::user(ID::custom('user1'))), Permission::read(Role::user(ID::custom('user1')))], 1, 1, 1];
yield [[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())], 1, 1, 1];
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DocumentsDBPermissionsTeamTest extends Scope
final class DocumentsDBPermissionsTeamTest extends Scope
{
use DatabasesPermissionsBase;
use ProjectCustom;
@@ -97,32 +99,28 @@ class DocumentsDBPermissionsTeamTest extends Scope
* $success = can $user read from $collection
* [$user, $collection, $success]
*/
public static function readDocumentsProvider(): array
public static function readDocumentsProvider(): \Iterator
{
return [
['user1', 'collection1', true],
['user2', 'collection1', false],
['user3', 'collection1', true],
['user1', 'collection2', false],
['user2', 'collection2', true],
['user3', 'collection2', true],
];
yield ['user1', 'collection1', true];
yield ['user2', 'collection1', false];
yield ['user3', 'collection1', true];
yield ['user1', 'collection2', false];
yield ['user2', 'collection2', true];
yield ['user3', 'collection2', true];
}
/*
* $success = can $user write to $collection
* [$user, $collection, $success]
*/
public static function writeDocumentsProvider(): array
public static function writeDocumentsProvider(): \Iterator
{
return [
['user1', 'collection1', true],
['user2', 'collection1', false],
['user3', 'collection1', false],
['user1', 'collection2', false],
['user2', 'collection2', true],
['user3', 'collection2', false],
];
yield ['user1', 'collection1', true];
yield ['user2', 'collection1', false];
yield ['user3', 'collection1', false];
yield ['user1', 'collection2', false];
yield ['user2', 'collection2', true];
yield ['user3', 'collection2', false];
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -13,7 +15,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class LegacyPermissionsGuestTest extends Scope
final class LegacyPermissionsGuestTest extends Scope
{
use DatabasesPermissionsBase;
use ProjectCustom;
@@ -96,16 +98,14 @@ class LegacyPermissionsGuestTest extends Scope
];
}
public static function permissionsProvider(): array
public static function permissionsProvider(): \Iterator
{
return [
[[Permission::read(Role::any())]],
[[Permission::read(Role::users())]],
[[Permission::update(Role::any()), Permission::delete(Role::any())]],
[[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())]],
[[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())]],
[[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())]],
];
yield [[Permission::read(Role::any())]];
yield [[Permission::read(Role::users())]];
yield [[Permission::update(Role::any()), Permission::delete(Role::any())]];
yield [[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())]];
yield [[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())]];
yield [[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())]];
}
#[DataProvider('permissionsProvider')]
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -13,7 +15,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class LegacyPermissionsMemberTest extends Scope
final class LegacyPermissionsMemberTest extends Scope
{
use DatabasesPermissionsBase;
use ProjectCustom;
@@ -31,22 +33,20 @@ class LegacyPermissionsMemberTest extends Scope
];
}
public static function permissionsProvider(): array
public static function permissionsProvider(): \Iterator
{
return [
[[Permission::read(Role::any())], 1, 1, 1],
[[Permission::read(Role::users())], 1, 1, 1],
[[Permission::read(Role::user(ID::custom('random')))], 1, 1, 0],
[[Permission::read(Role::user(ID::custom('lorem'))), Permission::update(Role::user('lorem')), Permission::delete(Role::user('lorem'))], 1, 1, 0],
[[Permission::read(Role::user(ID::custom('dolor'))), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 1, 1, 0],
[[Permission::read(Role::user(ID::custom('dolor'))), Permission::read(Role::user('lorem')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 1, 1, 0],
[[Permission::update(Role::any()), Permission::delete(Role::any())], 1, 1, 0],
[[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())], 1, 1, 1],
[[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())], 1, 1, 1],
[[Permission::read(Role::user(ID::custom('user1')))], 1, 1, 1],
[[Permission::read(Role::user(ID::custom('user1'))), Permission::read(Role::user(ID::custom('user1')))], 1, 1, 1],
[[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())], 1, 1, 1],
];
yield [[Permission::read(Role::any())], 1, 1, 1];
yield [[Permission::read(Role::users())], 1, 1, 1];
yield [[Permission::read(Role::user(ID::custom('random')))], 1, 1, 0];
yield [[Permission::read(Role::user(ID::custom('lorem'))), Permission::update(Role::user('lorem')), Permission::delete(Role::user('lorem'))], 1, 1, 0];
yield [[Permission::read(Role::user(ID::custom('dolor'))), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 1, 1, 0];
yield [[Permission::read(Role::user(ID::custom('dolor'))), Permission::read(Role::user('lorem')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 1, 1, 0];
yield [[Permission::update(Role::any()), Permission::delete(Role::any())], 1, 1, 0];
yield [[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())], 1, 1, 1];
yield [[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())], 1, 1, 1];
yield [[Permission::read(Role::user(ID::custom('user1')))], 1, 1, 1];
yield [[Permission::read(Role::user(ID::custom('user1'))), Permission::read(Role::user(ID::custom('user1')))], 1, 1, 1];
yield [[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())], 1, 1, 1];
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -13,7 +15,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class LegacyPermissionsTeamTest extends Scope
final class LegacyPermissionsTeamTest extends Scope
{
use DatabasesPermissionsBase;
use ProjectCustom;
@@ -122,32 +124,28 @@ class LegacyPermissionsTeamTest extends Scope
* $success = can $user read from $collection
* [$user, $collection, $success]
*/
public static function readDocumentsProvider(): array
public static function readDocumentsProvider(): \Iterator
{
return [
['user1', 'collection1', true],
['user2', 'collection1', false],
['user3', 'collection1', true],
['user1', 'collection2', false],
['user2', 'collection2', true],
['user3', 'collection2', true],
];
yield ['user1', 'collection1', true];
yield ['user2', 'collection1', false];
yield ['user3', 'collection1', true];
yield ['user1', 'collection2', false];
yield ['user2', 'collection2', true];
yield ['user3', 'collection2', true];
}
/*
* $success = can $user write to $collection
* [$user, $collection, $success]
*/
public static function writeDocumentsProvider(): array
public static function writeDocumentsProvider(): \Iterator
{
return [
['user1', 'collection1', true],
['user2', 'collection1', false],
['user3', 'collection1', false],
['user1', 'collection2', false],
['user2', 'collection2', true],
['user3', 'collection2', false],
];
yield ['user1', 'collection1', true];
yield ['user2', 'collection1', false];
yield ['user3', 'collection1', false];
yield ['user1', 'collection2', false];
yield ['user2', 'collection2', true];
yield ['user3', 'collection2', false];
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiDocumentsDB;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class DocumentsDBACIDTest extends Scope
final class DocumentsDBACIDTest extends Scope
{
use ACIDBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiDocumentsDB;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class DocumentsDBTransactionPermissionsCustomClientTest extends Scope
final class DocumentsDBTransactionPermissionsCustomClientTest extends Scope
{
use TransactionPermissionsBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiDocumentsDB;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideConsole;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class DocumentsDBTransactionsConsoleClientTest extends Scope
final class DocumentsDBTransactionsConsoleClientTest extends Scope
{
use TransactionsBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiDocumentsDB;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class DocumentsDBTransactionsCustomClientTest extends Scope
final class DocumentsDBTransactionsCustomClientTest extends Scope
{
use TransactionsBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiDocumentsDB;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class DocumentsDBTransactionsCustomServerTest extends Scope
final class DocumentsDBTransactionsCustomServerTest extends Scope
{
use TransactionsBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiLegacy;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class LegacyACIDTest extends Scope
final class LegacyACIDTest extends Scope
{
use ACIDBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiLegacy;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class LegacyTransactionPermissionsCustomClientTest extends Scope
final class LegacyTransactionPermissionsCustomClientTest extends Scope
{
use TransactionPermissionsBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiLegacy;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideConsole;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class LegacyTransactionsConsoleClientTest extends Scope
final class LegacyTransactionsConsoleClientTest extends Scope
{
use TransactionsBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiLegacy;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class LegacyTransactionsCustomClientTest extends Scope
final class LegacyTransactionsCustomClientTest extends Scope
{
use TransactionsBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\Transactions;
use Tests\E2E\Scopes\ApiLegacy;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Tests\E2E\Traits\DatabasesUrlHelpers;
class LegacyTransactionsCustomServerTest extends Scope
final class LegacyTransactionsCustomServerTest extends Scope
{
use TransactionsBase;
use DatabasesUrlHelpers;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB;
use PHPUnit\Framework\Attributes\Depends;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DatabasesConsoleClientTest extends Scope
final class DatabasesConsoleClientTest extends Scope
{
use ProjectCustom;
use SideConsole;
@@ -51,7 +53,7 @@ class DatabasesConsoleClientTest extends Scope
]);
$this->assertEquals(201, $movies['headers']['status-code']);
$this->assertEquals($movies['body']['name'], 'Movies');
$this->assertEquals('Movies', $movies['body']['name']);
/**
* Test when database is disabled but can still create collections
@@ -94,7 +96,7 @@ class DatabasesConsoleClientTest extends Scope
]);
$this->assertEquals(201, $tvShows['headers']['status-code']);
$this->assertEquals($tvShows['body']['name'], 'TvShows');
$this->assertEquals('TvShows', $tvShows['body']['name']);
return ['moviesId' => $movies['body']['$id'], 'databaseId' => $databaseId, 'tvShowsId' => $tvShows['body']['$id']];
}
@@ -174,7 +176,7 @@ class DatabasesConsoleClientTest extends Scope
], $this->getHeaders()));
$this->assertEquals(204, $response['headers']['status-code']);
$this->assertEquals($response['body'], "");
$this->assertEquals("", $response['body']);
}
#[Depends('testCreateCollection')]
@@ -206,7 +208,7 @@ class DatabasesConsoleClientTest extends Scope
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(11, count($response['body']));
$this->assertCount(11, $response['body']);
$this->assertEquals('24h', $response['body']['range']);
$this->assertIsNumeric($response['body']['documentsTotal']);
$this->assertIsNumeric($response['body']['collectionsTotal']);
@@ -251,7 +253,7 @@ class DatabasesConsoleClientTest extends Scope
'range' => '24h'
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(3, count($response['body']));
$this->assertCount(3, $response['body']);
$this->assertEquals('24h', $response['body']['range']);
$this->assertIsNumeric($response['body']['documentsTotal']);
$this->assertIsArray($response['body']['documents']);
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB;
use Tests\E2E\Client;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DatabasesCustomClientTest extends Scope
final class DatabasesCustomClientTest extends Scope
{
use DatabasesBase;
use ProjectCustom;
@@ -14,7 +14,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DatabasesCustomServerTest extends Scope
final class DatabasesCustomServerTest extends Scope
{
use DatabasesBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Validator\Authorization;
class DatabasesPermissionsGuestTest extends Scope
final class DatabasesPermissionsGuestTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -74,16 +76,14 @@ class DatabasesPermissionsGuestTest extends Scope
];
}
public static function permissionsProvider(): array
public static function permissionsProvider(): \Iterator
{
return [
[[Permission::read(Role::any())]],
[[Permission::read(Role::users())]],
[[Permission::update(Role::any()), Permission::delete(Role::any())]],
[[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())]],
[[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())]],
[[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())]],
];
yield [[Permission::read(Role::any())]];
yield [[Permission::read(Role::users())]];
yield [[Permission::update(Role::any()), Permission::delete(Role::any())]];
yield [[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())]];
yield [[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())]];
yield [[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())]];
}
#[DataProvider('permissionsProvider')]
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DatabasesPermissionsMemberTest extends Scope
final class DatabasesPermissionsMemberTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -28,22 +30,20 @@ class DatabasesPermissionsMemberTest extends Scope
];
}
public static function permissionsProvider(): array
public static function permissionsProvider(): \Iterator
{
return [
[[Permission::read(Role::any())], 1, 1, 1],
[[Permission::read(Role::users())], 2, 2, 2],
[[Permission::read(Role::user(ID::custom('random')))], 3, 3, 2],
[[Permission::read(Role::user(ID::custom('lorem'))), Permission::update(Role::user('lorem')), Permission::delete(Role::user('lorem'))], 4, 4, 2],
[[Permission::read(Role::user(ID::custom('dolor'))), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 5, 5, 2],
[[Permission::read(Role::user(ID::custom('dolor'))), Permission::read(Role::user('lorem')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 6, 6, 2],
[[Permission::update(Role::any()), Permission::delete(Role::any())], 7, 7, 2],
[[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())], 8, 8, 3],
[[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())], 9, 9, 4],
[[Permission::read(Role::user(ID::custom('user1')))], 10, 10, 5],
[[Permission::read(Role::user(ID::custom('user1'))), Permission::read(Role::user(ID::custom('user1')))], 11, 11, 6],
[[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())], 12, 12, 7],
];
yield [[Permission::read(Role::any())], 1, 1, 1];
yield [[Permission::read(Role::users())], 2, 2, 2];
yield [[Permission::read(Role::user(ID::custom('random')))], 3, 3, 2];
yield [[Permission::read(Role::user(ID::custom('lorem'))), Permission::update(Role::user('lorem')), Permission::delete(Role::user('lorem'))], 4, 4, 2];
yield [[Permission::read(Role::user(ID::custom('dolor'))), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 5, 5, 2];
yield [[Permission::read(Role::user(ID::custom('dolor'))), Permission::read(Role::user('lorem')), Permission::update(Role::user('dolor')), Permission::delete(Role::user('dolor'))], 6, 6, 2];
yield [[Permission::update(Role::any()), Permission::delete(Role::any())], 7, 7, 2];
yield [[Permission::read(Role::any()), Permission::update(Role::any()), Permission::delete(Role::any())], 8, 8, 3];
yield [[Permission::read(Role::any()), Permission::update(Role::users()), Permission::delete(Role::users())], 9, 9, 4];
yield [[Permission::read(Role::user(ID::custom('user1')))], 10, 10, 5];
yield [[Permission::read(Role::user(ID::custom('user1'))), Permission::read(Role::user(ID::custom('user1')))], 11, 11, 6];
yield [[Permission::read(Role::users()), Permission::update(Role::users()), Permission::delete(Role::users())], 12, 12, 7];
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB\Permissions;
use PHPUnit\Framework\Attributes\DataProvider;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DatabasesPermissionsTeamTest extends Scope
final class DatabasesPermissionsTeamTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -81,32 +83,28 @@ class DatabasesPermissionsTeamTest extends Scope
* $success = can $user read from $collection
* [$user, $collection, $success]
*/
public static function readDocumentsProvider(): array
public static function readDocumentsProvider(): \Iterator
{
return [
['user1', 'collection1', true],
['user2', 'collection1', false],
['user3', 'collection1', true],
['user1', 'collection2', false],
['user2', 'collection2', true],
['user3', 'collection2', true],
];
yield ['user1', 'collection1', true];
yield ['user2', 'collection1', false];
yield ['user3', 'collection1', true];
yield ['user1', 'collection2', false];
yield ['user2', 'collection2', true];
yield ['user3', 'collection2', true];
}
/*
* $success = can $user write to $collection
* [$user, $collection, $success]
*/
public static function writeDocumentsProvider(): array
public static function writeDocumentsProvider(): \Iterator
{
return [
['user1', 'collection1', true],
['user2', 'collection1', false],
['user3', 'collection1', false],
['user1', 'collection2', false],
['user2', 'collection2', true],
['user3', 'collection2', false],
];
yield ['user1', 'collection1', true];
yield ['user2', 'collection1', false];
yield ['user3', 'collection1', false];
yield ['user1', 'collection2', false];
yield ['user2', 'collection2', true];
yield ['user3', 'collection2', false];
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB\Transactions;
use Tests\E2E\Client;
@@ -10,7 +12,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class ACIDTest extends Scope
final class ACIDTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -1,12 +1,14 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB\Transactions;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideConsole;
class TransactionsConsoleClientTest extends Scope
final class TransactionsConsoleClientTest extends Scope
{
use TransactionsBase;
use ProjectCustom;
@@ -1,12 +1,14 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB\Transactions;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
class TransactionsCustomClientTest extends Scope
final class TransactionsCustomClientTest extends Scope
{
use TransactionsBase;
use ProjectCustom;
@@ -1,12 +1,14 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Databases\VectorsDB\Transactions;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class TransactionsCustomServerTest extends Scope
final class TransactionsCustomServerTest extends Scope
{
use TransactionsBase;
use ProjectCustom;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Functions;
use Tests\E2E\Client;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Query;
class FunctionsConsoleClientTest extends Scope
final class FunctionsConsoleClientTest extends Scope
{
use ProjectCustom;
use SideConsole;
@@ -143,7 +145,7 @@ class FunctionsConsoleClientTest extends Scope
'range' => '24h'
]);
$this->assertEquals(200, $usage['headers']['status-code']);
$this->assertEquals(24, count($usage['body']));
$this->assertCount(24, $usage['body']);
$this->assertEquals('24h', $usage['body']['range']);
$this->assertIsNumeric($usage['body']['deploymentsTotal']);
$this->assertIsNumeric($usage['body']['deploymentsStorageTotal']);
@@ -316,7 +318,7 @@ class FunctionsConsoleClientTest extends Scope
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(2, sizeof($response['body']['variables']));
$this->assertCount(2, $response['body']['variables']);
$this->assertEquals(2, $response['body']['total']);
$this->assertEquals("APP_TEST", $response['body']['variables'][0]['key']);
$this->assertEquals("TESTINGVALUE", $response['body']['variables'][0]['value']);
@@ -850,7 +852,7 @@ class FunctionsConsoleClientTest extends Scope
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(0, sizeof($response['body']['variables']));
$this->assertCount(0, $response['body']['variables']);
$this->assertEquals(0, $response['body']['total']);
/**
@@ -950,7 +952,7 @@ class FunctionsConsoleClientTest extends Scope
$buildMd5 = \md5($response['body']);
$this->assertNotEquals($deploymentMd5, $buildMd5);
$this->assertNotSame($deploymentMd5, $buildMd5);
$this->cleanupFunction($functionId);
}
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Functions;
use Tests\E2E\Client;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\System\System;
class FunctionsCustomClientTest extends Scope
final class FunctionsCustomClientTest extends Scope
{
use FunctionsBase;
use ProjectCustom;
@@ -391,7 +393,7 @@ class FunctionsCustomClientTest extends Scope
$this->assertIsArray($templatesWithIncludeTotalFalse['body']);
$this->assertIsArray($templatesWithIncludeTotalFalse['body']['templates']);
$this->assertIsInt($templatesWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $templatesWithIncludeTotalFalse['body']['total']);
$this->assertSame(0, $templatesWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($templatesWithIncludeTotalFalse['body']['templates']));
foreach ($templates['body']['templates'] as $template) {
@@ -605,7 +607,7 @@ class FunctionsCustomClientTest extends Scope
$lastExecution = $executions['body']['executions'][0];
$this->assertEquals('completed', $lastExecution['status']);
$this->assertEquals(204, $lastExecution['responseStatusCode']);
$this->assertStringContainsString($documentId, $lastExecution['logs']);
$this->assertStringContainsString($documentId, (string) $lastExecution['logs']);
}, 20000, 500);
$this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId, [
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Functions;
use Appwrite\Platform\Modules\Compute\Specification;
@@ -16,7 +18,7 @@ use Utopia\Database\Helpers\Role;
use Utopia\Database\Query;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
class FunctionsCustomServerTest extends Scope
final class FunctionsCustomServerTest extends Scope
{
use FunctionsBase;
use ProjectCustom;
@@ -314,9 +316,9 @@ class FunctionsCustomServerTest extends Scope
'search' => $data['functionId']
]);
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals(200, $functions['headers']['status-code']);
$this->assertCount(1, $functions['body']['functions']);
$this->assertEquals($functions['body']['functions'][0]['name'], 'Test');
$this->assertEquals('Test', $functions['body']['functions'][0]['name']);
// Test pagination limit
$functions = $this->listFunctions([
@@ -325,7 +327,7 @@ class FunctionsCustomServerTest extends Scope
],
]);
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals(200, $functions['headers']['status-code']);
$this->assertCount(1, $functions['body']['functions']);
// Test pagination offset - combined with limit to verify offset works
@@ -337,7 +339,7 @@ class FunctionsCustomServerTest extends Scope
],
]);
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals(200, $functions['headers']['status-code']);
// In parallel mode, other tests may create functions, so just verify offset works
$this->assertIsArray($functions['body']['functions']);
@@ -348,7 +350,7 @@ class FunctionsCustomServerTest extends Scope
],
]);
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals(200, $functions['headers']['status-code']);
// In parallel mode, other tests may create enabled functions
$this->assertGreaterThanOrEqual(1, count($functions['body']['functions']));
@@ -359,7 +361,7 @@ class FunctionsCustomServerTest extends Scope
],
]);
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals(200, $functions['headers']['status-code']);
// In parallel mode, other tests may create disabled functions
$this->assertIsArray($functions['body']['functions']);
@@ -368,7 +370,7 @@ class FunctionsCustomServerTest extends Scope
'search' => 'Test'
]);
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals(200, $functions['headers']['status-code']);
// In parallel mode, other tests may create functions with 'Test' in the name
$this->assertGreaterThanOrEqual(1, count($functions['body']['functions']));
// Verify our function is in the results
@@ -380,7 +382,7 @@ class FunctionsCustomServerTest extends Scope
'search' => 'node-22'
]);
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals(200, $functions['headers']['status-code']);
// In parallel mode, other tests may create functions with node-22 runtime
$this->assertGreaterThanOrEqual(1, count($functions['body']['functions']));
// Verify our function is in the results
@@ -404,7 +406,7 @@ class FunctionsCustomServerTest extends Scope
$functions = $this->listFunctions();
$this->assertEquals($functions['headers']['status-code'], 200);
$this->assertEquals(200, $functions['headers']['status-code']);
// In parallel mode, there may be more functions created by other tests
$this->assertGreaterThanOrEqual(2, $functions['body']['total']);
$this->assertIsArray($functions['body']['functions']);
@@ -426,7 +428,7 @@ class FunctionsCustomServerTest extends Scope
],
]);
$this->assertEquals($functions1['headers']['status-code'], 200);
$this->assertEquals(200, $functions1['headers']['status-code']);
// Should have at least Test 2 after Test (may have more from parallel tests)
$this->assertGreaterThanOrEqual(1, count($functions1['body']['functions']));
$functionNames1 = array_column($functions1['body']['functions'], 'name');
@@ -438,7 +440,7 @@ class FunctionsCustomServerTest extends Scope
],
]);
$this->assertEquals($functions2['headers']['status-code'], 200);
$this->assertEquals(200, $functions2['headers']['status-code']);
// Should have at least Test before Test 2
$this->assertGreaterThanOrEqual(1, count($functions2['body']['functions']));
$functionNames2 = array_column($functions2['body']['functions'], 'name');
@@ -452,7 +454,7 @@ class FunctionsCustomServerTest extends Scope
Query::cursorAfter(new Document(['$id' => 'unknown']))->toString(),
],
]);
$this->assertEquals($functions['headers']['status-code'], 400);
$this->assertEquals(400, $functions['headers']['status-code']);
}
public function testGetFunction(): void
@@ -464,15 +466,15 @@ class FunctionsCustomServerTest extends Scope
*/
$function = $this->getFunction($data['functionId']);
$this->assertEquals($function['headers']['status-code'], 200);
$this->assertEquals($function['body']['name'], 'Test');
$this->assertEquals(200, $function['headers']['status-code']);
$this->assertEquals('Test', $function['body']['name']);
/**
* Test for FAILURE
*/
$function = $this->getFunction('x');
$this->assertEquals($function['headers']['status-code'], 404);
$this->assertEquals(404, $function['headers']['status-code']);
}
public function testUpdateFunction(): void
@@ -695,7 +697,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertIsArray($deploymentsWithIncludeTotalFalse['body']);
$this->assertIsArray($deploymentsWithIncludeTotalFalse['body']['deployments']);
$this->assertIsInt($deploymentsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $deploymentsWithIncludeTotalFalse['body']['total']);
$this->assertSame(0, $deploymentsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($deploymentsWithIncludeTotalFalse['body']['deployments']));
$lastDeployment = $deployments['body']['deployments'][0];
@@ -731,7 +733,7 @@ class FunctionsCustomServerTest extends Scope
$totalUsers = $users['body']['total'];
$this->assertStringContainsString("Total users: " . $totalUsers, $execution['body']['logs']);
$this->assertStringContainsString("Total users: " . $totalUsers, (string) $execution['body']['logs']);
// Execute function again but async
$execution = $this->createExecution($functionId, [
@@ -753,7 +755,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEmpty($execution['body']['responseBody']);
$this->assertEmpty($execution['body']['errors']);
$this->assertStringContainsString("Total users: " . $totalUsers, $execution['body']['logs']);
$this->assertStringContainsString("Total users: " . $totalUsers, (string) $execution['body']['logs']);
}, 10000, 500);
$deployment = $this->getDeployment($functionId, $deployment['body']['$id']);
@@ -1018,7 +1020,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEventually(function () use ($functionId, $deploymentId) {
$deployment = $this->getDeployment($functionId, $deploymentId);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertStringContainsString('Build has been canceled.', $deployment['body']['buildLogs']);
$this->assertStringContainsString('Build has been canceled.', (string) $deployment['body']['buildLogs']);
});
$deployment = $this->getDeployment($functionId, $deploymentId);
@@ -1368,7 +1370,7 @@ class FunctionsCustomServerTest extends Scope
$functionId = $data['functionId'];
$deployments = $this->listDeployments($functionId);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertGreaterThanOrEqual(1, $deployments['body']['total']);
$this->assertIsArray($deployments['body']['deployments']);
$this->assertGreaterThanOrEqual(1, count($deployments['body']['deployments']));
@@ -1381,7 +1383,7 @@ class FunctionsCustomServerTest extends Scope
],
]);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertCount(1, $deployments['body']['deployments']);
$deployments = $this->listDeployments($functionId, [
@@ -1390,7 +1392,7 @@ class FunctionsCustomServerTest extends Scope
],
]);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertGreaterThanOrEqual(1, count($deployments['body']['deployments']));
// Check all deployments have correct attributes from select query
foreach ($deployments['body']['deployments'] as $deployment) {
@@ -1404,7 +1406,7 @@ class FunctionsCustomServerTest extends Scope
Query::select(['buildLogs'])->toString(),
],
]);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertGreaterThanOrEqual(1, count($deployments['body']['deployments']));
// Check all deployments have correct attributes from select query
foreach ($deployments['body']['deployments'] as $deployment) {
@@ -1436,7 +1438,7 @@ class FunctionsCustomServerTest extends Scope
]
);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
// At least 1 manual deployment should exist
$this->assertGreaterThanOrEqual(1, $deployments['body']['total']);
@@ -1449,7 +1451,7 @@ class FunctionsCustomServerTest extends Scope
]
);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertEquals(0, $deployments['body']['total']);
$deployments = $this->listDeployments(
@@ -1461,7 +1463,7 @@ class FunctionsCustomServerTest extends Scope
]
);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertEquals(0, $deployments['body']['total']);
$deployments = $this->listDeployments(
@@ -1473,7 +1475,7 @@ class FunctionsCustomServerTest extends Scope
]
);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
// At least 1 deployment with sourceSize > 0 should exist
$this->assertGreaterThanOrEqual(1, $deployments['body']['total']);
@@ -1485,7 +1487,7 @@ class FunctionsCustomServerTest extends Scope
],
]
);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertEquals(200, $deployments['headers']['status-code']);
// At least 1 deployment with sourceSize > -100 should exist
$this->assertGreaterThanOrEqual(1, $deployments['body']['total']);
@@ -1554,7 +1556,7 @@ class FunctionsCustomServerTest extends Scope
*/
$deployment = $this->getDeployment($data['functionId'], 'x');
$this->assertEquals($deployment['headers']['status-code'], 404);
$this->assertEquals(404, $deployment['headers']['status-code']);
}
public function testCreateExecution(): void
@@ -1588,13 +1590,13 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($data['functionId'], $execution['body']['functionId']);
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEquals(200, $execution['body']['responseStatusCode']);
$this->assertStringContainsString($execution['body']['functionId'], $execution['body']['responseBody']);
$this->assertStringContainsString($data['deploymentId'], $execution['body']['responseBody']);
$this->assertStringContainsString('Test1', $execution['body']['responseBody']);
$this->assertStringContainsString('http', $execution['body']['responseBody']);
$this->assertStringContainsString('Node.js', $execution['body']['responseBody']);
$this->assertStringContainsString('22', $execution['body']['responseBody']);
$this->assertStringContainsString('Global Variable Value', $execution['body']['responseBody']);
$this->assertStringContainsString($execution['body']['functionId'], (string) $execution['body']['responseBody']);
$this->assertStringContainsString($data['deploymentId'], (string) $execution['body']['responseBody']);
$this->assertStringContainsString('Test1', (string) $execution['body']['responseBody']);
$this->assertStringContainsString('http', (string) $execution['body']['responseBody']);
$this->assertStringContainsString('Node.js', (string) $execution['body']['responseBody']);
$this->assertStringContainsString('22', (string) $execution['body']['responseBody']);
$this->assertStringContainsString('Global Variable Value', (string) $execution['body']['responseBody']);
// $this->assertStringContainsString('êä', $execution['body']['responseBody']); // tests unknown utf-8 chars
$this->assertNotEmpty($execution['body']['errors']);
$this->assertNotEmpty($execution['body']['logs']);
@@ -1663,7 +1665,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertIsArray($executionsWithIncludeTotalFalse['body']);
$this->assertIsArray($executionsWithIncludeTotalFalse['body']['executions']);
$this->assertIsInt($executionsWithIncludeTotalFalse['body']['total']);
$this->assertEquals(0, $executionsWithIncludeTotalFalse['body']['total']);
$this->assertSame(0, $executionsWithIncludeTotalFalse['body']['total']);
$this->assertGreaterThan(0, count($executionsWithIncludeTotalFalse['body']['executions']));
$executions = $this->listExecutions($data['functionId'], [
@@ -1757,10 +1759,10 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEquals(200, $execution['body']['responseStatusCode']);
$this->assertStringContainsString('Test1', $execution['body']['responseBody']);
$this->assertStringContainsString('http', $execution['body']['responseBody']);
$this->assertStringContainsString('Node.js', $execution['body']['responseBody']);
$this->assertStringContainsString('22', $execution['body']['responseBody']);
$this->assertStringContainsString('Test1', (string) $execution['body']['responseBody']);
$this->assertStringContainsString('http', (string) $execution['body']['responseBody']);
$this->assertStringContainsString('Node.js', (string) $execution['body']['responseBody']);
$this->assertStringContainsString('22', (string) $execution['body']['responseBody']);
// $this->assertStringContainsString('êä', $execution['body']['response']); // tests unknown utf-8 chars
$this->assertLessThan(1.500, $execution['body']['duration']);
}
@@ -1783,7 +1785,7 @@ class FunctionsCustomServerTest extends Scope
*/
$function = $this->getExecution($data['functionId'], 'x');
$this->assertEquals($function['headers']['status-code'], 404);
$this->assertEquals(404, $function['headers']['status-code']);
}
@@ -1816,7 +1818,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals(404, $execution['headers']['status-code']);
$this->assertStringContainsString('Execution with the requested ID could not be found', $execution['body']['message']);
$this->assertStringContainsString('Execution with the requested ID could not be found', (string) $execution['body']['message']);
/**
* Test for FAILURE
@@ -1838,8 +1840,8 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()));
$this->assertEquals(400, $execution['headers']['status-code']);
$this->assertStringContainsString('execution_in_progress', $execution['body']['type']);
$this->assertStringContainsString('Can\'t delete ongoing execution.', $execution['body']['message']);
$this->assertStringContainsString('execution_in_progress', (string) $execution['body']['type']);
$this->assertStringContainsString('Can\'t delete ongoing execution.', (string) $execution['body']['message']);
}
@@ -2124,24 +2126,18 @@ class FunctionsCustomServerTest extends Scope
$this->assertLessThan(20, $execution['body']['duration']);
$this->assertEquals('', $execution['body']['responseBody']);
$this->assertEquals('', $execution['body']['logs']);
$this->assertStringContainsString('timed out', $execution['body']['errors']);
$this->assertStringContainsString('timed out', (string) $execution['body']['errors']);
}, 10000, 500);
$this->cleanupFunction($functionId);
}
public static function provideCustomExecutions(): array
public static function provideCustomExecutions(): \Iterator
{
// Most disabled to keep tests fast
// Using positional arrays to avoid PHPUnit 11 named argument conflicts with @depends
return [
// ['php-fn', 'php-8.0', 'index.php', 'PHP', '8.0'],
['node', 'node-22', 'index.js', 'Node.js', '22'],
// ['python', 'python-3.9', 'main.py', 'Python', '3.9'],
// ['ruby', 'ruby-3.1', 'main.rb', 'Ruby', '3.1'],
// ['dart', 'dart-2.15', 'main.dart', 'Dart', '2.15'],
// ['swift', 'swift-5.5', 'index.swift', 'Swift', '5.5'],
];
// ['php-fn', 'php-8.0', 'index.php', 'PHP', '8.0'],
yield ['node', 'node-22', 'index.js', 'Node.js', '22'];
}
#[DataProvider('provideCustomExecutions')]
@@ -2185,12 +2181,12 @@ class FunctionsCustomServerTest extends Scope
$executions = $this->listExecutions($functionId);
$this->assertEquals($executions['headers']['status-code'], 200);
$this->assertEquals($executions['body']['total'], 1);
$this->assertEquals(200, $executions['headers']['status-code']);
$this->assertEquals(1, $executions['body']['total']);
$this->assertIsArray($executions['body']['executions']);
$this->assertCount(1, $executions['body']['executions']);
$this->assertEquals($executions['body']['executions'][0]['$id'], $executionId);
$this->assertEquals($executions['body']['executions'][0]['trigger'], 'http');
$this->assertEquals('http', $executions['body']['executions'][0]['trigger']);
$this->assertEquals(200, $executions['body']['executions'][0]['responseStatusCode']);
$this->assertEmpty($executions['body']['executions'][0]['responseBody']);
@@ -2220,7 +2216,7 @@ class FunctionsCustomServerTest extends Scope
]);
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertStringContainsString('multipart/form-data', $execution['headers']['content-type']);
$this->assertStringContainsString('multipart/form-data', (string) $execution['headers']['content-type']);
$contentType = explode(';', $execution['headers']['content-type']);
$this->assertStringContainsString('boundary=----', $contentType[1]);
$bytes = unpack('C*byte', $execution['body']['responseBody']);
@@ -2240,7 +2236,7 @@ class FunctionsCustomServerTest extends Scope
]);
$this->assertEquals(400, $execution['headers']['status-code']);
$this->assertStringContainsString('Failed to parse response', $execution['body']['message']);
$this->assertStringContainsString('Failed to parse response', (string) $execution['body']['message']);
$this->cleanupFunction($functionId);
}
@@ -2357,8 +2353,8 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals('completed', $lastExecution['status']);
$this->assertEquals(204, $lastExecution['responseStatusCode']);
$this->assertStringContainsString($userId, $lastExecution['logs']);
$this->assertStringContainsString('Event User', $lastExecution['logs']);
$this->assertStringContainsString($userId, (string) $lastExecution['logs']);
$this->assertStringContainsString('Event User', (string) $lastExecution['logs']);
$this->assertNotEmpty($lastExecution['$id']);
$headers = array_column($lastExecution['requestHeaders'] ?? [], 'value', 'name');
$this->assertEmpty($headers['x-appwrite-client-ip'] ?? '');
@@ -2408,7 +2404,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $execution['body']['responseStatusCode']);
$this->assertGreaterThan(0, $execution['body']['duration']);
$this->assertNotEmpty($execution['body']['responseBody']);
$this->assertStringContainsString("total", $execution['body']['responseBody']);
$this->assertStringContainsString("total", (string) $execution['body']['responseBody']);
$execution = $this->createExecution($functionId, [
'async' => true,
@@ -2427,7 +2423,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $execution['body']['responseStatusCode']);
$this->assertGreaterThan(0, $execution['body']['duration']);
$this->assertNotEmpty($execution['body']['logs']);
$this->assertStringContainsString("total", $execution['body']['logs']);
$this->assertStringContainsString("total", (string) $execution['body']['logs']);
}, 10000, 500);
$this->cleanupFunction($functionId);
@@ -2517,7 +2513,7 @@ class FunctionsCustomServerTest extends Scope
], $this->getHeaders()), []);
$this->assertEquals(200, $executions['headers']['status-code']);
$this->assertEquals(1, count($executions['body']['executions']));
$this->assertCount(1, $executions['body']['executions']);
});
$this->assertEventually(function () use ($functionId) {
@@ -2526,7 +2522,7 @@ class FunctionsCustomServerTest extends Scope
]);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(24, count($response['body']));
$this->assertCount(24, $response['body']);
$this->assertEquals('24h', $response['body']['range']);
$this->assertEquals(1, $response['body']['executionsTotal']);
}, 25000, 500);
@@ -2822,7 +2818,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEventually(function () use ($functionId, $deploymentId) {
$deployment = $this->getDeployment($functionId, $deploymentId);
$this->assertTrue(str_contains($deployment['body']['buildLogs'], '2048:2'));
$this->assertStringContainsString('2048:2', (string) $deployment['body']['buildLogs']);
}, 10000, 500);
// Check if the function specifications are correctly set in executions
@@ -2857,7 +2853,7 @@ class FunctionsCustomServerTest extends Scope
$execution = $this->createExecution($functionId);
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertStringContainsString('APPWRITE_FUNCTION_ID', $execution['body']['responseBody']);
$this->assertStringContainsString('APPWRITE_FUNCTION_ID', (string) $execution['body']['responseBody']);
$function = $this->updateFunction($functionId, [
'runtime' => 'node-22',
@@ -2866,7 +2862,7 @@ class FunctionsCustomServerTest extends Scope
'commands' => 'rm index.js && mv maintenance.js index.js'
]);
$this->assertEquals(200, $function['headers']['status-code']);
$this->assertStringContainsString('maintenance.js', $function['body']['commands']);
$this->assertStringContainsString('maintenance.js', (string) $function['body']['commands']);
$deployment = $this->createDuplicateDeployment($functionId, $deploymentId1);
$this->assertEquals(202, $deployment['headers']['status-code']);
@@ -2887,7 +2883,7 @@ class FunctionsCustomServerTest extends Scope
$execution = $this->createExecution($functionId);
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertStringContainsString('Maintenance', $execution['body']['responseBody']);
$this->assertStringContainsString('Maintenance', (string) $execution['body']['responseBody']);
$deployment = $this->getDeployment($functionId, $deploymentId2);
$this->assertEquals(200, $deployment['headers']['status-code']);
@@ -2935,7 +2931,7 @@ class FunctionsCustomServerTest extends Scope
]);
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertStringContainsString('cookieValue', $execution['body']['responseBody']);
$this->assertStringContainsString('cookieValue', (string) $execution['body']['responseBody']);
$deploymentId2 = $this->setupDeployment($functionId, [
'code' => $this->packageFunction('basic'),
@@ -2951,7 +2947,7 @@ class FunctionsCustomServerTest extends Scope
$execution = $this->createExecution($functionId);
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertStringContainsString('UNICODE_TEST', $execution['body']['responseBody']);
$this->assertStringContainsString('UNICODE_TEST', (string) $execution['body']['responseBody']);
$function = $this->getFunction($functionId);
$this->assertEquals(200, $function['headers']['status-code']);
@@ -2974,7 +2970,7 @@ class FunctionsCustomServerTest extends Scope
]);
$this->assertEquals(201, $execution['headers']['status-code']);
$this->assertNotEmpty($execution['body']['$id']);
$this->assertStringContainsString('cookieValue', $execution['body']['responseBody']);
$this->assertStringContainsString('cookieValue', (string) $execution['body']['responseBody']);
$deployment = $this->deleteDeployment($functionId, $deploymentId2);
$this->assertEquals(204, $deployment['headers']['status-code']);
@@ -2999,8 +2995,8 @@ class FunctionsCustomServerTest extends Scope
$response = $proxyClient->call(Client::METHOD_GET, '/');
$this->assertEquals(404, $response['headers']['status-code']);
$this->assertStringContainsString('Nothing is here yet', $response['body']);
$this->assertStringContainsString('Start with this domain', $response['body']);
$this->assertStringContainsString('Nothing is here yet', (string) $response['body']);
$this->assertStringContainsString('Start with this domain', (string) $response['body']);
// failed deployment
$functionId = $this->setupFunction([
@@ -3029,8 +3025,8 @@ class FunctionsCustomServerTest extends Scope
]));
$this->assertEquals(404, $response['headers']['status-code']);
$this->assertStringContainsString('No active deployments', $response['body']);
$this->assertStringContainsString('View deployments', $response['body']);
$this->assertStringContainsString('No active deployments', (string) $response['body']);
$this->assertStringContainsString('View deployments', (string) $response['body']);
// canceled deployment
$deployment = $this->createDeployment($functionId, [
@@ -3051,8 +3047,8 @@ class FunctionsCustomServerTest extends Scope
]));
$this->assertEquals(404, $response['headers']['status-code']);
$this->assertStringContainsString('No active deployments', $response['body']);
$this->assertStringContainsString('View deployments', $response['body']);
$this->assertStringContainsString('No active deployments', (string) $response['body']);
$this->assertStringContainsString('View deployments', (string) $response['body']);
$this->cleanupFunction($functionId);
}
@@ -3085,8 +3081,8 @@ class FunctionsCustomServerTest extends Scope
]));
$this->assertEquals(401, $response['headers']['status-code']);
$this->assertStringContainsString('Execution not permitted', $response['body']);
$this->assertStringContainsString('View settings', $response['body']);
$this->assertStringContainsString('Execution not permitted', (string) $response['body']);
$this->assertStringContainsString('View settings', (string) $response['body']);
$this->cleanupFunction($functionId);
}
@@ -3118,46 +3114,46 @@ class FunctionsCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id']
]));
$this->assertEquals(404, $response['headers']['status-code']);
$this->assertStringContainsString('Error 404', $response['body']);
$this->assertStringContainsString('does not exist', $response['body']);
$this->assertStringContainsString('Error 404', (string) $response['body']);
$this->assertStringContainsString('does not exist', (string) $response['body']);
$response = $proxyClient->call(Client::METHOD_GET, '/custom-response?code=504', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
]));
$this->assertEquals(504, $response['headers']['status-code']);
$this->assertStringContainsString('Error 504', $response['body']);
$this->assertStringContainsString('respond in time', $response['body']);
$this->assertStringContainsString('Error 504', (string) $response['body']);
$this->assertStringContainsString('respond in time', (string) $response['body']);
$response = $proxyClient->call(Client::METHOD_GET, '/custom-response?code=400', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
]));
$this->assertEquals(400, $response['headers']['status-code']);
$this->assertStringContainsString('Error 400', $response['body']);
$this->assertStringContainsString('unexpected client error', $response['body']);
$this->assertStringContainsString('Error 400', (string) $response['body']);
$this->assertStringContainsString('unexpected client error', (string) $response['body']);
$response = $proxyClient->call(Client::METHOD_GET, '/custom-response?code=500', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
]));
$this->assertEquals(500, $response['headers']['status-code']);
$this->assertStringContainsString('Error 500', $response['body']);
$this->assertStringContainsString('unexpected server error', $response['body']);
$this->assertStringContainsString('Error 500', (string) $response['body']);
$this->assertStringContainsString('unexpected server error', (string) $response['body']);
$response = $proxyClient->call(Client::METHOD_GET, '/custom-response?code=400&body=CustomError400', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
]));
$this->assertEquals(400, $response['headers']['status-code']);
$this->assertStringContainsString('CustomError400', $response['body']);
$this->assertStringContainsString('CustomError400', (string) $response['body']);
$response = $proxyClient->call(Client::METHOD_GET, '/custom-response?code=500&body=CustomError500', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
]));
$this->assertEquals(500, $response['headers']['status-code']);
$this->assertStringContainsString('CustomError500', $response['body']);
$this->assertStringContainsString('CustomError500', (string) $response['body']);
$this->cleanupFunction($functionId);
}
@@ -3189,14 +3185,14 @@ class FunctionsCustomServerTest extends Scope
$this->assertLessThanOrEqual(APP_FUNCTION_LOG_LENGTH_LIMIT, strlen($logs));
$this->assertStringStartsWith('[WARNING] Logs truncated', $logs);
$this->assertStringContainsString('a', $logs);
$this->assertStringContainsString('a', (string) $logs);
// Verify errors are truncated and warning message is present at the beginning
$errors = $execution['body']['errors'];
$this->assertLessThanOrEqual(APP_FUNCTION_ERROR_LENGTH_LIMIT, strlen($errors));
$this->assertStringStartsWith('[WARNING] Errors truncated', $errors);
$this->assertStringContainsString('a', $errors);
$this->assertStringContainsString('a', (string) $errors);
$this->cleanupFunction($functionId);
}
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\FunctionsSchedule;
use Appwrite\ID;
@@ -10,7 +12,7 @@ use Tests\E2E\Scopes\SideServer;
use Tests\E2E\Services\Functions\FunctionsBase;
use Utopia\Database\Helpers\Role;
class FunctionsScheduleTest extends Scope
final class FunctionsScheduleTest extends Scope
{
use FunctionsBase;
use ProjectCustom;
@@ -91,7 +93,7 @@ class FunctionsScheduleTest extends Scope
// Schedule execution for the future
\date_default_timezone_set('UTC');
$futureTime = (new \DateTime())->add(new \DateInterval('PT2M')); // 2 minutes in the future
$futureTime->setTime($futureTime->format('H'), $futureTime->format('i'), 0, 0);
$futureTime->setTime((int) $futureTime->format('H'), (int) $futureTime->format('i'), 0, 0);
$execution = $this->client->call(
@@ -132,12 +134,12 @@ class FunctionsScheduleTest extends Scope
$this->assertEquals('completed', $execution['body']['status']);
$this->assertEquals('/custom-path', $execution['body']['requestPath']);
$this->assertEquals('PATCH', $execution['body']['requestMethod']);
$this->assertStringContainsString('body-is-custom-body', $execution['body']['logs']);
$this->assertStringContainsString('custom-header-is-custom-value', $execution['body']['logs']);
$this->assertStringContainsString('method-is-patch', $execution['body']['logs']);
$this->assertStringContainsString('path-is-/custom-path', $execution['body']['logs']);
$this->assertStringContainsString('user-is-' . $this->getUser()['$id'], $execution['body']['logs']);
$this->assertStringContainsString('jwt-is-valid', $execution['body']['logs']);
$this->assertStringContainsString('body-is-custom-body', (string) $execution['body']['logs']);
$this->assertStringContainsString('custom-header-is-custom-value', (string) $execution['body']['logs']);
$this->assertStringContainsString('method-is-patch', (string) $execution['body']['logs']);
$this->assertStringContainsString('path-is-/custom-path', (string) $execution['body']['logs']);
$this->assertStringContainsString('user-is-' . $this->getUser()['$id'], (string) $execution['body']['logs']);
$this->assertStringContainsString('jwt-is-valid', (string) $execution['body']['logs']);
$this->assertGreaterThan(0, $execution['body']['duration']);
}, 120000, 500);
@@ -191,7 +193,7 @@ class FunctionsScheduleTest extends Scope
]);
$futureTime = (new \DateTime())->add(new \DateInterval('PT10H'));
$futureTime->setTime($futureTime->format('H'), $futureTime->format('i'), 0, 0);
$futureTime->setTime((int) $futureTime->format('H'), (int) $futureTime->format('i'), 0, 0);
$execution = $this->createExecution($functionId, [
'async' => true,
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\Helpers\ID;
class AccountTest extends Scope
final class AccountTest extends Scope
{
use ProjectCustom;
use SideClient;
+16 -14
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class AvatarsTest extends Scope
final class AvatarsTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -31,7 +33,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $creditCardIcon['headers']['status-code']);
$this->assertNotEmpty($creditCardIcon['body']);
$this->assertStringContainsString('image/', $creditCardIcon['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $creditCardIcon['headers']['content-type']);
return $creditCardIcon['body'];
}
@@ -54,7 +56,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $browserIcon['headers']['status-code']);
$this->assertNotEmpty($browserIcon['body']);
$this->assertStringContainsString('image/', $browserIcon['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $browserIcon['headers']['content-type']);
return $browserIcon['body'];
}
@@ -77,7 +79,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $countryFlag['headers']['status-code']);
$this->assertNotEmpty($countryFlag['body']);
$this->assertStringContainsString('image/', $countryFlag['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $countryFlag['headers']['content-type']);
return $countryFlag['body'];
}
@@ -100,7 +102,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $image['headers']['status-code']);
$this->assertNotEmpty($image['body']);
$this->assertStringContainsString('image/', $image['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $image['headers']['content-type']);
return $image['body'];
}
@@ -123,7 +125,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $favicon['headers']['status-code']);
$this->assertNotEmpty($favicon['body']);
$this->assertStringContainsString('image/', $favicon['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $favicon['headers']['content-type']);
return $favicon['body'];
}
@@ -146,7 +148,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $qrCode['headers']['status-code']);
$this->assertNotEmpty($qrCode['body']);
$this->assertStringContainsString('image/', $qrCode['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $qrCode['headers']['content-type']);
return $qrCode['body'];
}
@@ -169,7 +171,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $initials['headers']['status-code']);
$this->assertNotEmpty($initials['body']);
$this->assertStringContainsString('image/', $initials['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $initials['headers']['content-type']);
return $initials['body'];
}
@@ -201,7 +203,7 @@ class AvatarsTest extends Scope
echo "Response body: " . print_r($screenshot['body'], true) . "\n";
}
$this->assertStringContainsString('image/', $screenshot['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $screenshot['headers']['content-type']);
return $screenshot['body'];
}
@@ -232,7 +234,7 @@ class AvatarsTest extends Scope
echo "Response body: " . print_r($screenshot['body'], true) . "\n";
}
$this->assertStringContainsString('image/', $screenshot['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $screenshot['headers']['content-type']);
return $screenshot['body'];
}
@@ -284,7 +286,7 @@ class AvatarsTest extends Scope
echo "Response body: " . print_r($screenshot['body'], true) . "\n";
}
$this->assertStringContainsString('image/', $screenshot['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $screenshot['headers']['content-type']);
return $screenshot['body'];
}
@@ -311,7 +313,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $screenshot['headers']['status-code']);
$this->assertNotEmpty($screenshot['body']);
$this->assertStringContainsString('image/', $screenshot['headers']['content-type']);
$this->assertStringContainsString('image/', (string) $screenshot['headers']['content-type']);
return $screenshot['body'];
}
@@ -350,7 +352,7 @@ class AvatarsTest extends Scope
}
// If not an image, verify it's a known error (avatar_remote_url_failed)
$this->assertStringContainsString('application/json', $screenshot['headers']['content-type']);
$this->assertStringContainsString('application/json', (string) $screenshot['headers']['content-type']);
return '';
}
@@ -381,7 +383,7 @@ class AvatarsTest extends Scope
$this->assertEquals(200, $screenshot['headers']['status-code']);
$this->assertArrayHasKey('errors', $screenshot['body']);
$this->assertNotEmpty($screenshot['body']['errors']);
$this->assertStringContainsString('Invalid `permissions` param', $screenshot['body']['errors'][0]['message']);
$this->assertStringContainsString('Invalid `permissions` param', (string) $screenshot['body']['errors'][0]['message']);
return $screenshot['body'];
}
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\Helpers\ID;
class BatchTest extends Scope
final class BatchTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use CURLFile;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class ContentTypeTest extends Scope
final class ContentTypeTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Appwrite\Tests\Async;
@@ -10,7 +12,7 @@ use Tests\E2E\Scopes\SideClient;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Role;
class FunctionsClientTest extends Scope
final class FunctionsClientTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Appwrite\Tests\Async;
@@ -11,7 +13,7 @@ use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Role;
class FunctionsServerTest extends Scope
final class FunctionsServerTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -313,7 +315,7 @@ class FunctionsServerTest extends Scope
* @return array
* @throws \Exception
*/
public function testGetDeployments()
public function testGetDeployments(): array
{
$function = $this->setupFunction();
@@ -343,7 +345,7 @@ class FunctionsServerTest extends Scope
* @return array
* @throws \Exception
*/
public function testGetDeployment()
public function testGetDeployment(): array
{
$deployment = $this->setupDeployment();
+13 -11
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -7,13 +9,13 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class HealthTest extends Scope
final class HealthTest extends Scope
{
use ProjectCustom;
use SideServer;
use Base;
public function testGetHTTPHealth()
public function testGetHTTPHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_HTTP_HEALTH);
@@ -34,7 +36,7 @@ class HealthTest extends Scope
return $httpHealth;
}
public function testGetDBHealth()
public function testGetDBHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_DB_HEALTH);
@@ -57,7 +59,7 @@ class HealthTest extends Scope
return $dbHealth;
}
public function testGetCacheHealth()
public function testGetCacheHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_CACHE_HEALTH);
@@ -80,7 +82,7 @@ class HealthTest extends Scope
return $cacheHealth;
}
public function testGetTimeHealth()
public function testGetTimeHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_TIME_HEALTH);
@@ -101,7 +103,7 @@ class HealthTest extends Scope
return $timeHealth;
}
public function testGetWebhooksQueueHealth()
public function testGetWebhooksQueueHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_WEBHOOKS_QUEUE_HEALTH);
@@ -122,7 +124,7 @@ class HealthTest extends Scope
return $webhooksQueueHealth;
}
public function testGetLogsQueueHealth()
public function testGetLogsQueueHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_LOGS_QUEUE_HEALTH);
@@ -143,7 +145,7 @@ class HealthTest extends Scope
return $logsQueueHealth;
}
public function testGetCertificatesQueueHealth()
public function testGetCertificatesQueueHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_CERTIFICATES_QUEUE_HEALTH);
@@ -164,7 +166,7 @@ class HealthTest extends Scope
return $certificatesQueueHealth;
}
public function testGetFunctionsQueueHealth()
public function testGetFunctionsQueueHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_FUNCTION_QUEUE_HEALTH);
@@ -185,7 +187,7 @@ class HealthTest extends Scope
return $functionsQueueHealth;
}
public function testGetLocalStorageHealth()
public function testGetLocalStorageHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_LOCAL_STORAGE_HEALTH);
@@ -206,7 +208,7 @@ class HealthTest extends Scope
return $localStorageHealth;
}
public function testGetAntiVirusHealth()
public function testGetAntiVirusHealth(): array
{
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::GET_ANITVIRUS_HEALTH);
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL\Legacy;
use Tests\E2E\Client;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\System\System;
class AbuseTest extends Scope
final class AbuseTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -91,7 +93,7 @@ class AbuseTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders(false)), $graphQLPayload);
$max = System::getEnv('_APP_GRAPHQL_MAX_QUERY_COMPLEXITY', 250);
$max = System::getEnv('_APP_GRAPHQL_MAX_QUERY_COMPLEXITY', '250');
$this->assertEquals('Max query complexity should be ' . $max . ' but got 259.', $response['body']['errors'][0]['message']);
}
@@ -99,7 +101,7 @@ class AbuseTest extends Scope
public function testTooManyQueriesBlocked()
{
$projectId = $this->getProject()['$id'];
$maxQueries = System::getEnv('_APP_GRAPHQL_MAX_QUERIES', 10);
$maxQueries = System::getEnv('_APP_GRAPHQL_MAX_QUERIES', '10');
$query = [];
for ($i = 0; $i <= ((int) $maxQueries) + 1; $i++) {
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL\Legacy;
use Tests\E2E\Client;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class AuthTest extends Scope
final class AuthTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL\Legacy;
use Tests\E2E\Client;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DatabaseClientTest extends Scope
final class DatabaseClientTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -486,7 +488,7 @@ class DatabaseClientTest extends Scope
// Attribute may already exist from setupAttributes, so we check for either success or already exists error
if (isset($attribute['body']['errors'])) {
$this->assertStringContainsString('already', $attribute['body']['errors'][0]['message']);
$this->assertStringContainsString('already', (string) $attribute['body']['errors'][0]['message']);
} else {
$this->assertIsArray($attribute['body']['data']);
$this->assertIsArray($attribute['body']['data']['databasesCreateStringAttribute']);
@@ -519,7 +521,7 @@ class DatabaseClientTest extends Scope
// Attribute may already exist from setupAttributes, so we check for either success or already exists error
if (isset($attribute['body']['errors'])) {
$this->assertStringContainsString('already', $attribute['body']['errors'][0]['message']);
$this->assertStringContainsString('already', (string) $attribute['body']['errors'][0]['message']);
} else {
$this->assertIsArray($attribute['body']['data']);
$this->assertIsArray($attribute['body']['data']['databasesCreateIntegerAttribute']);
@@ -618,7 +620,7 @@ class DatabaseClientTest extends Scope
$document = $document['body']['data']['databasesUpdateDocument'];
$this->assertIsArray($document);
$this->assertStringContainsString('New Document Name', $document['data']);
$this->assertStringContainsString('New Document Name', (string) $document['data']);
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL\Legacy;
use Exception;
@@ -13,7 +15,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class DatabaseServerTest extends Scope
final class DatabaseServerTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -1157,9 +1159,9 @@ class DatabaseServerTest extends Scope
$this->assertIsArray($attribute['body']['data']);
$this->assertIsArray($attribute['body']['data']['databasesUpdateFloatAttribute']);
$this->assertFalse($attribute['body']['data']['databasesUpdateFloatAttribute']['required']);
$this->assertEquals(100.0, $attribute['body']['data']['databasesUpdateFloatAttribute']['min']);
$this->assertEquals(1000000.0, $attribute['body']['data']['databasesUpdateFloatAttribute']['max']);
$this->assertEquals(2500.0, $attribute['body']['data']['databasesUpdateFloatAttribute']['default']);
$this->assertEqualsWithDelta(100.0, $attribute['body']['data']['databasesUpdateFloatAttribute']['min'], PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(1000000.0, $attribute['body']['data']['databasesUpdateFloatAttribute']['max'], PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(2500.0, $attribute['body']['data']['databasesUpdateFloatAttribute']['default'], PHP_FLOAT_EPSILON);
$this->assertEquals(200, $attribute['headers']['status-code']);
}
@@ -2207,7 +2209,7 @@ class DatabaseServerTest extends Scope
$this->assertIsArray($document['body']['data']);
$document = $document['body']['data']['databasesUpdateDocument'];
$this->assertIsArray($document);
$this->assertStringContainsString('New Document Name', $document['data']);
$this->assertStringContainsString('New Document Name', (string) $document['data']);
}
// /**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -7,7 +9,7 @@ use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
class LocalizationTest extends Scope
final class LocalizationTest extends Scope
{
use ProjectCustom;
use SideServer;
+12 -10
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -10,7 +12,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\DSN\DSN;
use Utopia\System\System;
class MessagingTest extends Scope
final class MessagingTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -548,7 +550,7 @@ class MessagingTest extends Scope
$this->assertEquals(200, $message['headers']['status-code']);
$this->assertEquals(1, $message['body']['data']['messagingGetMessage']['deliveredTotal']);
$this->assertEquals(0, \count($message['body']['data']['messagingGetMessage']['deliveryErrors']));
$this->assertCount(0, $message['body']['data']['messagingGetMessage']['deliveryErrors']);
self::$cachedEmail[$key] = $message['body']['data']['messagingGetMessage'];
return self::$cachedEmail[$key];
@@ -707,7 +709,7 @@ class MessagingTest extends Scope
$this->assertEquals(200, $message['headers']['status-code']);
$this->assertEquals(1, $message['body']['data']['messagingGetMessage']['deliveredTotal']);
$this->assertEquals(0, \count($message['body']['data']['messagingGetMessage']['deliveryErrors']));
$this->assertCount(0, $message['body']['data']['messagingGetMessage']['deliveryErrors']);
self::$cachedSms[$key] = $message['body']['data']['messagingGetMessage'];
return self::$cachedSms[$key];
@@ -868,7 +870,7 @@ class MessagingTest extends Scope
$this->assertEquals(200, $message['headers']['status-code']);
$this->assertEquals(1, $message['body']['data']['messagingGetMessage']['deliveredTotal']);
$this->assertEquals(0, \count($message['body']['data']['messagingGetMessage']['deliveryErrors']));
$this->assertCount(0, $message['body']['data']['messagingGetMessage']['deliveryErrors']);
self::$cachedPush[$key] = $message['body']['data']['messagingGetMessage'];
return self::$cachedPush[$key];
@@ -900,7 +902,7 @@ class MessagingTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey'],
], $graphQLPayload);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(\count($providers), \count($response['body']['data']['messagingListProviders']['providers']));
$this->assertCount(\count($providers), $response['body']['data']['messagingListProviders']['providers']);
}
public function testGetProvider()
@@ -976,7 +978,7 @@ class MessagingTest extends Scope
]), $graphQLPayload);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals(1, \count($response['body']['data']['messagingListTopics']['topics']));
$this->assertCount(1, $response['body']['data']['messagingListTopics']['topics']);
}
public function testGetTopic()
@@ -1027,7 +1029,7 @@ class MessagingTest extends Scope
$this->assertEquals($subscriber['topicId'], $response['body']['data']['messagingListSubscribers']['subscribers'][0]['topicId']);
$this->assertEquals($subscriber['targetId'], $response['body']['data']['messagingListSubscribers']['subscribers'][0]['targetId']);
$this->assertEquals($subscriber['target']['userId'], $response['body']['data']['messagingListSubscribers']['subscribers'][0]['target']['userId']);
$this->assertEquals(1, \count($response['body']['data']['messagingListSubscribers']['subscribers']));
$this->assertCount(1, $response['body']['data']['messagingListSubscribers']['subscribers']);
}
public function testGetSubscriber()
@@ -1179,7 +1181,7 @@ class MessagingTest extends Scope
$this->assertEquals(200, $message['headers']['status-code']);
$this->assertEquals(1, $message['body']['data']['messagingGetMessage']['deliveredTotal']);
$this->assertEquals(0, \count($message['body']['data']['messagingGetMessage']['deliveryErrors']));
$this->assertCount(0, $message['body']['data']['messagingGetMessage']['deliveryErrors']);
}
public function testSendSMS(): void
@@ -1251,7 +1253,7 @@ class MessagingTest extends Scope
$this->assertEquals(200, $message['headers']['status-code']);
$this->assertEquals(1, $message['body']['data']['messagingGetMessage']['deliveredTotal']);
$this->assertEquals(0, \count($message['body']['data']['messagingGetMessage']['deliveryErrors']));
$this->assertCount(0, $message['body']['data']['messagingGetMessage']['deliveryErrors']);
}
public function testSendPushNotification(): void
@@ -1324,6 +1326,6 @@ class MessagingTest extends Scope
$this->assertEquals(200, $message['headers']['status-code']);
$this->assertEquals(1, $message['body']['data']['messagingGetMessage']['deliveredTotal']);
$this->assertEquals(0, \count($message['body']['data']['messagingGetMessage']['deliveryErrors']));
$this->assertCount(0, $message['body']['data']['messagingGetMessage']['deliveryErrors']);
}
}
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Helpers\ID;
class PresenceTest extends Scope
final class PresenceTest extends Scope
{
use ProjectCustom;
use SideServer;
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Helpers\ID;
class ScopeTest extends Scope
final class ScopeTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use CURLFile;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class StorageClientTest extends Scope
final class StorageClientTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -179,7 +181,7 @@ class StorageClientTest extends Scope
* @return array
* @throws \Exception
*/
public function testGetFilePreview()
public function testGetFilePreview(): array
{
$file = $this->setupFile();
@@ -209,7 +211,7 @@ class StorageClientTest extends Scope
* @return array
* @throws \Exception
*/
public function testGetFileDownload()
public function testGetFileDownload(): array
{
$file = $this->setupFile();
@@ -228,7 +230,7 @@ class StorageClientTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
$this->assertEquals(47218, \strlen($file['body']));
$this->assertSame(47218, \strlen($file['body']));
return $file;
}
@@ -255,7 +257,7 @@ class StorageClientTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
$this->assertEquals(47218, \strlen($file['body']));
$this->assertSame(47218, \strlen($file['body']));
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use CURLFile;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class StorageServerTest extends Scope
final class StorageServerTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -241,7 +243,7 @@ class StorageServerTest extends Scope
* @return array
* @throws \Exception
*/
public function testGetFilePreview()
public function testGetFilePreview(): array
{
$file = $this->setupFile();
@@ -271,7 +273,7 @@ class StorageServerTest extends Scope
* @return array
* @throws \Exception
*/
public function testGetFileDownload()
public function testGetFileDownload(): array
{
$file = $this->setupFile();
@@ -290,7 +292,7 @@ class StorageServerTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
$this->assertEquals(47218, \strlen($file['body']));
$this->assertSame(47218, \strlen($file['body']));
return $file;
}
@@ -317,7 +319,7 @@ class StorageServerTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $gqlPayload);
$this->assertEquals(47218, \strlen($file['body']));
$this->assertSame(47218, \strlen($file['body']));
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL\TablesDB;
use Tests\E2E\Client;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\System\System;
class AbuseTest extends Scope
final class AbuseTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -91,7 +93,7 @@ class AbuseTest extends Scope
'x-appwrite-project' => $projectId,
], $this->getHeaders()), $graphQLPayload);
$max = System::getEnv('_APP_GRAPHQL_MAX_QUERY_COMPLEXITY', 250);
$max = System::getEnv('_APP_GRAPHQL_MAX_QUERY_COMPLEXITY', '250');
$this->assertEquals('Max query complexity should be ' . $max . ' but got 259.', $response['body']['errors'][0]['message']);
}
@@ -99,7 +101,7 @@ class AbuseTest extends Scope
public function testTooManyQueriesBlocked()
{
$projectId = $this->getProject()['$id'];
$maxQueries = System::getEnv('_APP_GRAPHQL_MAX_QUERIES', 10);
$maxQueries = System::getEnv('_APP_GRAPHQL_MAX_QUERIES', '10');
$query = [];
for ($i = 0; $i <= ((int) $maxQueries) + 1; $i++) {
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL\TablesDB;
use Tests\E2E\Client;
@@ -11,7 +13,7 @@ use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
class AuthTest extends Scope
final class AuthTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL\TablesDB;
use Tests\E2E\Client;
@@ -12,7 +14,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Query;
class DatabaseClientTest extends Scope
final class DatabaseClientTest extends Scope
{
use ProjectCustom;
use SideClient;
@@ -601,7 +603,7 @@ class DatabaseClientTest extends Scope
$row = $row['body']['data']['tablesDBUpdateRow'];
$this->assertIsArray($row);
$this->assertStringContainsString('New Row Name', $row['data']);
$this->assertStringContainsString('New Row Name', (string) $row['data']);
}
/**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL\TablesDB;
use Exception;
@@ -14,7 +16,7 @@ use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Query;
class DatabaseServerTest extends Scope
final class DatabaseServerTest extends Scope
{
use ProjectCustom;
use SideServer;
@@ -1370,9 +1372,9 @@ class DatabaseServerTest extends Scope
$this->assertIsArray($column['body']['data']);
$this->assertIsArray($column['body']['data']['tablesDBUpdateFloatColumn']);
$this->assertFalse($column['body']['data']['tablesDBUpdateFloatColumn']['required']);
$this->assertEquals(100.0, $column['body']['data']['tablesDBUpdateFloatColumn']['min']);
$this->assertEquals(1000000.0, $column['body']['data']['tablesDBUpdateFloatColumn']['max']);
$this->assertEquals(2500.0, $column['body']['data']['tablesDBUpdateFloatColumn']['default']);
$this->assertEqualsWithDelta(100.0, $column['body']['data']['tablesDBUpdateFloatColumn']['min'], PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(1000000.0, $column['body']['data']['tablesDBUpdateFloatColumn']['max'], PHP_FLOAT_EPSILON);
$this->assertEqualsWithDelta(2500.0, $column['body']['data']['tablesDBUpdateFloatColumn']['default'], PHP_FLOAT_EPSILON);
$this->assertEquals(200, $column['headers']['status-code']);
}
@@ -2390,7 +2392,7 @@ class DatabaseServerTest extends Scope
$this->assertIsArray($row['body']['data']);
$row = $row['body']['data']['tablesDBUpdateRow'];
$this->assertIsArray($row);
$this->assertStringContainsString('New Row Name', $row['data']);
$this->assertStringContainsString('New Row Name', (string) $row['data']);
}
// /**
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -8,7 +10,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideClient;
use Utopia\Database\Helpers\ID;
class TeamsClientTest extends Scope
final class TeamsClientTest extends Scope
{
use ProjectCustom;
use Base;
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use PHPUnit\Framework\Attributes\Group;
@@ -9,7 +11,7 @@ use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Helpers\ID;
class TeamsServerTest extends Scope
final class TeamsServerTest extends Scope
{
use ProjectCustom;
use Base;
+3 -1
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\GraphQL;
use Tests\E2E\Client;
@@ -9,7 +11,7 @@ use Tests\E2E\Scopes\SideServer;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Query;
class UsersTest extends Scope
final class UsersTest extends Scope
{
use ProjectCustom;
use SideServer;
+3 -1
View File
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class AntiVirusTest extends HealthBase
final class AntiVirusTest extends HealthBase
{
public function testAntiVirus(): void
{
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class AuditsQueueTest extends HealthBase
final class AuditsQueueTest extends HealthBase
{
public function testAuditsQueue(): void
{
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class BuildsQueueTest extends HealthBase
final class BuildsQueueTest extends HealthBase
{
public function testBuildsQueue(): void
{
+3 -1
View File
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class CacheTest extends HealthBase
final class CacheTest extends HealthBase
{
public function testCacheSuccess(): void
{
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class CertificateTest extends HealthBase
final class CertificateTest extends HealthBase
{
public function testCertificateValidity(): void
{
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class CertificatesQueueTest extends HealthBase
final class CertificatesQueueTest extends HealthBase
{
public function testCertificatesQueue(): void
{
+3 -1
View File
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class DBTest extends HealthBase
final class DBTest extends HealthBase
{
public function testDBSuccess(): void
{
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class DatabasesQueueTest extends HealthBase
final class DatabasesQueueTest extends HealthBase
{
public function testDatabasesQueue(): void
{
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class DeletesQueueTest extends HealthBase
final class DeletesQueueTest extends HealthBase
{
public function testDeletesQueue(): void
{
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class FunctionsQueueTest extends HealthBase
final class FunctionsQueueTest extends HealthBase
{
public function testFunctionsQueue(): void
{
+3 -1
View File
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class HTTPTest extends HealthBase
final class HTTPTest extends HealthBase
{
public function testHTTPSuccess(): void
{
+2
View File
@@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
use Tests\E2E\Client;
+3 -1
View File
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class LogsQueueTest extends HealthBase
final class LogsQueueTest extends HealthBase
{
public function testLogsQueue(): void
{
+3 -1
View File
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class MailsQueueTest extends HealthBase
final class MailsQueueTest extends HealthBase
{
public function testMailsQueue(): void
{
@@ -1,8 +1,10 @@
<?php
declare(strict_types=1);
namespace Tests\E2E\Services\Health;
class MessagingQueueTest extends HealthBase
final class MessagingQueueTest extends HealthBase
{
public function testMessagingQueue(): void
{
Loaded 100 of 264 files, more files were not shown because too many files have changed in this diff. Show more