diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3278d76af..5537f9ab5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/composer.json b/composer.json index b78637ccd9..910b655d83 100644 --- a/composer.json +++ b/composer.json @@ -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": "*" diff --git a/composer.lock b/composer.lock index 79cee0b33e..0446b274b3 100644 --- a/composer.lock +++ b/composer.lock @@ -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", diff --git a/rector.php b/rector.php new file mode 100644 index 0000000000..ad224f77f6 --- /dev/null +++ b/rector.php @@ -0,0 +1,19 @@ +withBootstrapFiles([ + __DIR__ . '/app/init/constants.php', + ]) + ->withPaths([ + __DIR__ . '/tests', + ]) + ->withSkipPath(__DIR__ . '/vendor') + ->withSkipPath(__DIR__ . '/tests/resources') + ->withSets([ + PHPUnitSetList::PHPUNIT_CODE_QUALITY, + ]); diff --git a/tests/e2e/General/AbuseTest.php b/tests/e2e/General/AbuseTest.php index e30186bcc0..fbda7b7ad4 100644 --- a/tests/e2e/General/AbuseTest.php +++ b/tests/e2e/General/AbuseTest.php @@ -1,5 +1,7 @@ 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() diff --git a/tests/e2e/General/HooksTest.php b/tests/e2e/General/HooksTest.php index 812fb61496..58e8d0d921 100644 --- a/tests/e2e/General/HooksTest.php +++ b/tests/e2e/General/HooksTest.php @@ -1,5 +1,7 @@ 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 diff --git a/tests/e2e/Scopes/ApiVectorsDB.php b/tests/e2e/Scopes/ApiVectorsDB.php deleted file mode 100644 index 09494d3c10..0000000000 --- a/tests/e2e/Scopes/ApiVectorsDB.php +++ /dev/null @@ -1,110 +0,0 @@ - $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']]; diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index 5b0d947198..47b75fdce0 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -1,5 +1,7 @@ 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']; /** diff --git a/tests/e2e/Services/Account/AccountCustomServerTest.php b/tests/e2e/Services/Account/AccountCustomServerTest.php index b5c4ebe103..fa77e4a1a6 100644 --- a/tests/e2e/Services/Account/AccountCustomServerTest.php +++ b/tests/e2e/Services/Account/AccountCustomServerTest.php @@ -1,5 +1,7 @@ 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'])); diff --git a/tests/e2e/Services/Advisor/AdvisorCustomServerTest.php b/tests/e2e/Services/Advisor/AdvisorCustomServerTest.php index d91f95035e..23914e1d05 100644 --- a/tests/e2e/Services/Advisor/AdvisorCustomServerTest.php +++ b/tests/e2e/Services/Advisor/AdvisorCustomServerTest.php @@ -1,5 +1,7 @@ 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'); diff --git a/tests/e2e/Services/Console/ConsoleCustomClientTest.php b/tests/e2e/Services/Console/ConsoleCustomClientTest.php index 4b78b7f43c..c2b32d8b9f 100644 --- a/tests/e2e/Services/Console/ConsoleCustomClientTest.php +++ b/tests/e2e/Services/Console/ConsoleCustomClientTest.php @@ -1,5 +1,7 @@ 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']); diff --git a/tests/e2e/Services/Databases/VectorsDB/DatabasesCustomClientTest.php b/tests/e2e/Services/Databases/VectorsDB/DatabasesCustomClientTest.php index b27cb420b4..0ff3b7a46e 100644 --- a/tests/e2e/Services/Databases/VectorsDB/DatabasesCustomClientTest.php +++ b/tests/e2e/Services/Databases/VectorsDB/DatabasesCustomClientTest.php @@ -1,5 +1,7 @@ '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); } diff --git a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php index 1208121077..c04631bf60 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomClientTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomClientTest.php @@ -1,5 +1,7 @@ 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, [ diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 44d5d274da..726e73931c 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -1,5 +1,7 @@ $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); } diff --git a/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php b/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php index f4a70b5a9e..946f4069aa 100644 --- a/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php +++ b/tests/e2e/Services/FunctionsSchedule/FunctionsScheduleTest.php @@ -1,5 +1,7 @@ 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, diff --git a/tests/e2e/Services/GraphQL/AccountTest.php b/tests/e2e/Services/GraphQL/AccountTest.php index 76f98ce02f..4a7339a2d8 100644 --- a/tests/e2e/Services/GraphQL/AccountTest.php +++ b/tests/e2e/Services/GraphQL/AccountTest.php @@ -1,5 +1,7 @@ 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']; } diff --git a/tests/e2e/Services/GraphQL/BatchTest.php b/tests/e2e/Services/GraphQL/BatchTest.php index 550568a896..78863d2495 100644 --- a/tests/e2e/Services/GraphQL/BatchTest.php +++ b/tests/e2e/Services/GraphQL/BatchTest.php @@ -1,5 +1,7 @@ setupFunction(); @@ -343,7 +345,7 @@ class FunctionsServerTest extends Scope * @return array * @throws \Exception */ - public function testGetDeployment() + public function testGetDeployment(): array { $deployment = $this->setupDeployment(); diff --git a/tests/e2e/Services/GraphQL/HealthTest.php b/tests/e2e/Services/GraphQL/HealthTest.php index 732f7b5b1a..8b00bc42ef 100644 --- a/tests/e2e/Services/GraphQL/HealthTest.php +++ b/tests/e2e/Services/GraphQL/HealthTest.php @@ -1,5 +1,7 @@ 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); diff --git a/tests/e2e/Services/GraphQL/Legacy/AbuseTest.php b/tests/e2e/Services/GraphQL/Legacy/AbuseTest.php index 39939fdc0e..767187e808 100644 --- a/tests/e2e/Services/GraphQL/Legacy/AbuseTest.php +++ b/tests/e2e/Services/GraphQL/Legacy/AbuseTest.php @@ -1,5 +1,7 @@ $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++) { diff --git a/tests/e2e/Services/GraphQL/Legacy/AuthTest.php b/tests/e2e/Services/GraphQL/Legacy/AuthTest.php index d3c6d01ffa..22fdb3c0d1 100644 --- a/tests/e2e/Services/GraphQL/Legacy/AuthTest.php +++ b/tests/e2e/Services/GraphQL/Legacy/AuthTest.php @@ -1,5 +1,7 @@ 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']); } /** diff --git a/tests/e2e/Services/GraphQL/Legacy/DatabaseServerTest.php b/tests/e2e/Services/GraphQL/Legacy/DatabaseServerTest.php index 77c70dc83c..c148a1b0e0 100644 --- a/tests/e2e/Services/GraphQL/Legacy/DatabaseServerTest.php +++ b/tests/e2e/Services/GraphQL/Legacy/DatabaseServerTest.php @@ -1,5 +1,7 @@ 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']); } // /** diff --git a/tests/e2e/Services/GraphQL/LocalizationTest.php b/tests/e2e/Services/GraphQL/LocalizationTest.php index 182cdaabae..c67da2eaeb 100644 --- a/tests/e2e/Services/GraphQL/LocalizationTest.php +++ b/tests/e2e/Services/GraphQL/LocalizationTest.php @@ -1,5 +1,7 @@ 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']); } } diff --git a/tests/e2e/Services/GraphQL/PresenceTest.php b/tests/e2e/Services/GraphQL/PresenceTest.php index b0329e1c97..141de11441 100644 --- a/tests/e2e/Services/GraphQL/PresenceTest.php +++ b/tests/e2e/Services/GraphQL/PresenceTest.php @@ -1,5 +1,7 @@ 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'])); } /** diff --git a/tests/e2e/Services/GraphQL/StorageServerTest.php b/tests/e2e/Services/GraphQL/StorageServerTest.php index 7808c50be6..91d9f24dab 100644 --- a/tests/e2e/Services/GraphQL/StorageServerTest.php +++ b/tests/e2e/Services/GraphQL/StorageServerTest.php @@ -1,5 +1,7 @@ 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'])); } /** diff --git a/tests/e2e/Services/GraphQL/TablesDB/AbuseTest.php b/tests/e2e/Services/GraphQL/TablesDB/AbuseTest.php index c358882b8b..38370f4a05 100644 --- a/tests/e2e/Services/GraphQL/TablesDB/AbuseTest.php +++ b/tests/e2e/Services/GraphQL/TablesDB/AbuseTest.php @@ -1,5 +1,7 @@ $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++) { diff --git a/tests/e2e/Services/GraphQL/TablesDB/AuthTest.php b/tests/e2e/Services/GraphQL/TablesDB/AuthTest.php index 13f083f0eb..7f71f78374 100644 --- a/tests/e2e/Services/GraphQL/TablesDB/AuthTest.php +++ b/tests/e2e/Services/GraphQL/TablesDB/AuthTest.php @@ -1,5 +1,7 @@ assertIsArray($row); - $this->assertStringContainsString('New Row Name', $row['data']); + $this->assertStringContainsString('New Row Name', (string) $row['data']); } /** diff --git a/tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php b/tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php index f0b4e4b75c..12910be6c0 100644 --- a/tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php +++ b/tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php @@ -1,5 +1,7 @@ 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']); } // /** diff --git a/tests/e2e/Services/GraphQL/TeamsClientTest.php b/tests/e2e/Services/GraphQL/TeamsClientTest.php index e6c27f44f8..fac138fe89 100644 --- a/tests/e2e/Services/GraphQL/TeamsClientTest.php +++ b/tests/e2e/Services/GraphQL/TeamsClientTest.php @@ -1,5 +1,7 @@ $this->getProject()['$id'], ], $this->getHeaders())); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); @@ -62,7 +64,7 @@ class MessagingConsoleClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); $this->assertCount(2, $logs['body']['logs']); @@ -77,7 +79,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertLessThanOrEqual(1, count($logs['body']['logs'])); $this->assertIsNumeric($logs['body']['total']); @@ -91,7 +93,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); @@ -105,7 +107,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertLessThanOrEqual(1, count($logs['body']['logs'])); $this->assertIsNumeric($logs['body']['total']); @@ -122,7 +124,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/providers/' . $provider['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -133,7 +135,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/providers/' . $provider['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -144,7 +146,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/providers/' . $provider['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -155,7 +157,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/providers/' . $provider['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -166,7 +168,7 @@ class MessagingConsoleClientTest extends Scope ] ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); } public function testGetTopicLogs(): void @@ -180,7 +182,7 @@ class MessagingConsoleClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); @@ -208,7 +210,7 @@ class MessagingConsoleClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertCount(2, $logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); @@ -223,7 +225,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertLessThanOrEqual(1, count($logs['body']['logs'])); $this->assertIsNumeric($logs['body']['total']); @@ -237,7 +239,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); @@ -251,7 +253,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertLessThanOrEqual(1, count($logs['body']['logs'])); $this->assertIsNumeric($logs['body']['total']); @@ -268,7 +270,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $topic['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -279,7 +281,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $topic['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -290,7 +292,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $topic['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -301,7 +303,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/topics/' . $topic['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -312,7 +314,7 @@ class MessagingConsoleClientTest extends Scope ] ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); } public function testGetMessageLogs(): void @@ -334,7 +336,7 @@ class MessagingConsoleClientTest extends Scope 'x-appwrite-key' => $this->getProject()['apiKey'], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); @@ -365,7 +367,7 @@ class MessagingConsoleClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); $this->assertCount(2, $logs['body']['logs']); @@ -379,7 +381,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertLessThanOrEqual(1, count($logs['body']['logs'])); $this->assertIsNumeric($logs['body']['total']); @@ -393,7 +395,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertIsNumeric($logs['body']['total']); @@ -407,7 +409,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($logs['headers']['status-code'], 200); + $this->assertEquals(200, $logs['headers']['status-code']); $this->assertIsArray($logs['body']['logs']); $this->assertLessThanOrEqual(1, count($logs['body']['logs'])); $this->assertIsNumeric($logs['body']['total']); @@ -424,7 +426,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/messages/' . $email['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -435,7 +437,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/messages/' . $email['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -446,7 +448,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/messages/' . $email['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -457,7 +459,7 @@ class MessagingConsoleClientTest extends Scope ], ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_GET, '/messaging/messages/' . $email['body']['$id'] . '/logs', \array_merge([ 'content-type' => 'application/json', @@ -468,6 +470,6 @@ class MessagingConsoleClientTest extends Scope ] ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); } } diff --git a/tests/e2e/Services/Messaging/MessagingCustomClientTest.php b/tests/e2e/Services/Messaging/MessagingCustomClientTest.php index ee7d0c2ad9..5395d3fe8a 100644 --- a/tests/e2e/Services/Messaging/MessagingCustomClientTest.php +++ b/tests/e2e/Services/Messaging/MessagingCustomClientTest.php @@ -1,12 +1,14 @@ assertEquals(200, $expireServer['headers']['status-code']); - $this->assertEquals( + $this->assertSame( (new \DateTime($expiresAt))->getTimestamp(), (new \DateTime($expireServer['body']['expiresAt']))->getTimestamp() ); diff --git a/tests/e2e/Services/Presences/PresenceRealtimeClientTest.php b/tests/e2e/Services/Presences/PresenceRealtimeClientTest.php index d824412a51..0d2a6b0970 100644 --- a/tests/e2e/Services/Presences/PresenceRealtimeClientTest.php +++ b/tests/e2e/Services/Presences/PresenceRealtimeClientTest.php @@ -1,5 +1,7 @@ receiveErrorMessage($client); - $this->assertStringContainsString('Payload is not valid. Status is required', $missingStatus['data']['message'] ?? ''); + $this->assertStringContainsString('Payload is not valid. Status is required', (string) ($missingStatus['data']['message'] ?? '')); $this->assertQuietFor( $client, fn (array $frame): bool => ($frame['type'] ?? null) === 'event' @@ -401,7 +403,7 @@ class PresenceRealtimeClientTest extends Scope ], ])); $invalidPermissions = $this->receiveErrorMessage($client); - $this->assertStringContainsString('permissions: Permissions must be an array of strings', $invalidPermissions['data']['message'] ?? ''); + $this->assertStringContainsString('permissions: Permissions must be an array of strings', (string) ($invalidPermissions['data']['message'] ?? '')); $this->assertQuietFor( $client, fn (array $frame): bool => ($frame['type'] ?? null) === 'event' diff --git a/tests/e2e/Services/Project/AuthMethodsConsoleClientTest.php b/tests/e2e/Services/Project/AuthMethodsConsoleClientTest.php index e1ae5de357..4a760b172e 100644 --- a/tests/e2e/Services/Project/AuthMethodsConsoleClientTest.php +++ b/tests/e2e/Services/Project/AuthMethodsConsoleClientTest.php @@ -1,12 +1,14 @@ assertSame(301, $oauthInit['headers']['status-code']); $this->assertArrayHasKey('location', $oauthInit['headers']); $this->assertStringStartsWith('https://github.com/login/oauth/authorize', $oauthInit['headers']['location']); - $this->assertStringContainsString('client_id=' . \urlencode($clientId), $oauthInit['headers']['location']); - $this->assertStringContainsString('redirect_uri=', $oauthInit['headers']['location']); + $this->assertStringContainsString('client_id=' . \urlencode($clientId), (string) $oauthInit['headers']['location']); + $this->assertStringContainsString('redirect_uri=', (string) $oauthInit['headers']['location']); // Follow the redirect to GitHub's authorization endpoint. With a real user agent, GitHub // would prompt for login + app approval, then redirect back to Appwrite's callback with a diff --git a/tests/e2e/Services/Project/PlatformsConsoleClientTest.php b/tests/e2e/Services/Project/PlatformsConsoleClientTest.php index 9e6b841b00..cb0f475a94 100644 --- a/tests/e2e/Services/Project/PlatformsConsoleClientTest.php +++ b/tests/e2e/Services/Project/PlatformsConsoleClientTest.php @@ -1,12 +1,14 @@ assertEquals($account['headers']['status-code'], 201); + $this->assertEquals(201, $account['headers']['status-code']); $this->assertNotEmpty($account['body']); $webhook = $this->getLastRequest($this->webhookEventProbe("users.{$id}.create")); @@ -95,13 +97,13 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.create', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.create", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.create', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); @@ -109,9 +111,9 @@ class WebhooksCustomClientTest extends Scope $this->assertNotEmpty($webhook['data']['$id']); $this->assertEquals($webhook['data']['name'], $name); $this->assertEquals(true, (new DatetimeValidator())->isValid($webhook['data']['registration'])); - $this->assertEquals($webhook['data']['status'], true); + $this->assertEquals(true, $webhook['data']['status']); $this->assertEquals($webhook['data']['email'], $email); - $this->assertEquals($webhook['data']['emailVerification'], false); + $this->assertEquals(false, $webhook['data']['emailVerification']); $this->assertEquals($webhook['data']['prefs'], []); } @@ -144,7 +146,7 @@ class WebhooksCustomClientTest extends Scope 'password' => $password, ]); - $this->assertEquals($accountSession['headers']['status-code'], 201); + $this->assertEquals(201, $accountSession['headers']['status-code']); $id = $account['body']['$id']; $session = $accountSession['cookies']['a_session_' . $this->getProject()['$id']]; @@ -156,7 +158,7 @@ class WebhooksCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, ])); - $this->assertEquals($account['headers']['status-code'], 200); + $this->assertEquals(200, $account['headers']['status-code']); $webhook = $this->getLastRequest($this->webhookEventProbe("users.{$id}.update.status")); $signatureKey = $this->getProject()['signatureKey']; @@ -164,23 +166,23 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update.status', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update.status", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update.status', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update.status", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertEquals($webhook['data']['name'], $name); $this->assertEquals(true, (new DatetimeValidator())->isValid($webhook['data']['registration'])); - $this->assertEquals($webhook['data']['status'], false); + $this->assertEquals(false, $webhook['data']['status']); $this->assertEquals($webhook['data']['email'], $email); - $this->assertEquals($webhook['data']['emailVerification'], false); + $this->assertEquals(false, $webhook['data']['emailVerification']); $this->assertEquals($webhook['data']['prefs'], []); } @@ -229,19 +231,19 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.sessions.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.sessions.*.create', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.sessions.{$sessionId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.sessions.{$sessionId}.create", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.*.create", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}.create", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.sessions.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.sessions.*.create', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.sessions.{$sessionId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.sessions.{$sessionId}.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.*.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); @@ -255,9 +257,9 @@ class WebhooksCustomClientTest extends Scope $this->assertIsString($webhook['data']['osName']); $this->assertNotEmpty($webhook['data']['osVersion']); $this->assertIsString($webhook['data']['osVersion']); - $this->assertEquals($webhook['data']['clientType'], 'browser'); - $this->assertEquals($webhook['data']['clientCode'], 'CH'); - $this->assertEquals($webhook['data']['clientName'], 'Chrome'); + $this->assertEquals('browser', $webhook['data']['clientType']); + $this->assertEquals('CH', $webhook['data']['clientCode']); + $this->assertEquals('Chrome', $webhook['data']['clientName']); $this->assertNotEmpty($webhook['data']['clientVersion']); $this->assertIsString($webhook['data']['clientVersion']); $this->assertNotEmpty($webhook['data']['clientEngine']); @@ -268,7 +270,7 @@ class WebhooksCustomClientTest extends Scope $this->assertIsString($webhook['data']['deviceModel']); $this->assertIsString($webhook['data']['countryCode']); $this->assertIsString($webhook['data']['countryName']); - $this->assertEquals($webhook['data']['current'], true); + $this->assertEquals(true, $webhook['data']['current']); } public function testDeleteAccountSession(): void @@ -294,7 +296,7 @@ class WebhooksCustomClientTest extends Scope $sessionId = $accountSession['body']['$id']; $session = $accountSession['cookies']['a_session_' . $this->getProject()['$id']]; - $this->assertEquals($accountSession['headers']['status-code'], 201); + $this->assertEquals(201, $accountSession['headers']['status-code']); $accountSession = $this->client->call(Client::METHOD_DELETE, '/account/sessions/' . $sessionId, array_merge([ 'origin' => 'http://localhost', @@ -303,7 +305,7 @@ class WebhooksCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, ])); - $this->assertEquals($accountSession['headers']['status-code'], 204); + $this->assertEquals(204, $accountSession['headers']['status-code']); $webhook = $this->getLastRequest($this->webhookEventProbe("users.{$id}.sessions.{$sessionId}.delete")); $signatureKey = $this->getProject()['signatureKey']; @@ -311,23 +313,23 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.sessions.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.sessions.*.delete', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.sessions.{$sessionId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.sessions.{$sessionId}.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.*.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.sessions.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.sessions.*.delete', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.sessions.{$sessionId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.sessions.{$sessionId}.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.*.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertNotEmpty($webhook['data']['userId']); $this->assertIsString($webhook['data']['expire']); @@ -337,9 +339,9 @@ class WebhooksCustomClientTest extends Scope $this->assertIsString($webhook['data']['osName']); $this->assertNotEmpty($webhook['data']['osVersion']); $this->assertIsString($webhook['data']['osVersion']); - $this->assertEquals($webhook['data']['clientType'], 'browser'); - $this->assertEquals($webhook['data']['clientCode'], 'CH'); - $this->assertEquals($webhook['data']['clientName'], 'Chrome'); + $this->assertEquals('browser', $webhook['data']['clientType']); + $this->assertEquals('CH', $webhook['data']['clientCode']); + $this->assertEquals('Chrome', $webhook['data']['clientName']); $this->assertNotEmpty($webhook['data']['clientVersion']); $this->assertIsString($webhook['data']['clientVersion']); $this->assertNotEmpty($webhook['data']['clientEngine']); @@ -350,7 +352,7 @@ class WebhooksCustomClientTest extends Scope $this->assertIsString($webhook['data']['deviceModel']); $this->assertIsString($webhook['data']['countryCode']); $this->assertIsString($webhook['data']['countryName']); - $this->assertEquals($webhook['data']['current'], true); + $this->assertEquals(true, $webhook['data']['current']); } public function testDeleteAccountSessions(): void @@ -376,7 +378,7 @@ class WebhooksCustomClientTest extends Scope $sessionId = $accountSession['body']['$id']; $session = $accountSession['cookies']['a_session_' . $this->getProject()['$id']]; - $this->assertEquals($accountSession['headers']['status-code'], 201); + $this->assertEquals(201, $accountSession['headers']['status-code']); $accountSession = $this->client->call(Client::METHOD_DELETE, '/account/sessions', array_merge([ 'origin' => 'http://localhost', @@ -385,7 +387,7 @@ class WebhooksCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $session, ])); - $this->assertEquals($accountSession['headers']['status-code'], 204); + $this->assertEquals(204, $accountSession['headers']['status-code']); $webhook = $this->getLastRequest($this->webhookEventProbe("users.{$id}.sessions.{$sessionId}.delete")); $signatureKey = $this->getProject()['signatureKey']; @@ -393,23 +395,23 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.sessions.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.sessions.*.delete', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.sessions.{$sessionId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.sessions.{$sessionId}.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.*.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.sessions.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.sessions.*.delete', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.sessions.{$sessionId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.sessions.{$sessionId}.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.*.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.sessions.{$sessionId}.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertNotEmpty($webhook['data']['userId']); $this->assertEquals(true, (new DatetimeValidator())->isValid($webhook['data']['expire'])); @@ -419,9 +421,9 @@ class WebhooksCustomClientTest extends Scope $this->assertIsString($webhook['data']['osName']); $this->assertNotEmpty($webhook['data']['osVersion']); $this->assertIsString($webhook['data']['osVersion']); - $this->assertEquals($webhook['data']['clientType'], 'browser'); - $this->assertEquals($webhook['data']['clientCode'], 'CH'); - $this->assertEquals($webhook['data']['clientName'], 'Chrome'); + $this->assertEquals('browser', $webhook['data']['clientType']); + $this->assertEquals('CH', $webhook['data']['clientCode']); + $this->assertEquals('Chrome', $webhook['data']['clientName']); $this->assertNotEmpty($webhook['data']['clientVersion']); $this->assertIsString($webhook['data']['clientVersion']); $this->assertNotEmpty($webhook['data']['clientEngine']); @@ -432,7 +434,7 @@ class WebhooksCustomClientTest extends Scope $this->assertIsString($webhook['data']['deviceModel']); $this->assertIsString($webhook['data']['countryCode']); $this->assertIsString($webhook['data']['countryName']); - $this->assertEquals($webhook['data']['current'], true); + $this->assertEquals(true, $webhook['data']['current']); } #[Retry(count: 1)] @@ -454,7 +456,7 @@ class WebhooksCustomClientTest extends Scope 'name' => $newName ]); - $this->assertEquals($account['headers']['status-code'], 200); + $this->assertEquals(200, $account['headers']['status-code']); $this->assertIsArray($account['body']); $webhook = $this->getLastRequest($this->webhookEventProbe("users.{$id}.update.name")); @@ -464,25 +466,25 @@ class WebhooksCustomClientTest extends Scope $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update.name', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update.name", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update.name', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update.name", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertEquals($webhook['data']['name'], $newName); $this->assertIsString($webhook['data']['registration']); - $this->assertEquals($webhook['data']['status'], true); + $this->assertEquals(true, $webhook['data']['status']); $this->assertEquals($webhook['data']['email'], $email); - $this->assertEquals($webhook['data']['emailVerification'], false); + $this->assertEquals(false, $webhook['data']['emailVerification']); $this->assertEquals($webhook['data']['prefs'], []); } @@ -516,7 +518,7 @@ class WebhooksCustomClientTest extends Scope 'oldPassword' => $password, ]); - $this->assertEquals($account['headers']['status-code'], 200); + $this->assertEquals(200, $account['headers']['status-code']); $this->assertIsArray($account['body']); $webhook = $this->getLastRequest($this->webhookEventProbe("users.{$id}.update.password")); @@ -525,25 +527,25 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update.password', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update.password", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update.password', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update.password", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); - $this->assertEquals($webhook['data']['name'], 'New Name'); + $this->assertEquals('New Name', $webhook['data']['name']); $this->assertIsString($webhook['data']['registration']); - $this->assertEquals($webhook['data']['status'], true); + $this->assertEquals(true, $webhook['data']['status']); $this->assertEquals($webhook['data']['email'], $email); - $this->assertEquals($webhook['data']['emailVerification'], false); + $this->assertEquals(false, $webhook['data']['emailVerification']); $this->assertEquals($webhook['data']['prefs'], []); } @@ -578,7 +580,7 @@ class WebhooksCustomClientTest extends Scope 'password' => $password, ]); - $this->assertEquals($account['headers']['status-code'], 200); + $this->assertEquals(200, $account['headers']['status-code']); $this->assertIsArray($account['body']); $webhook = $this->getLastRequest($this->webhookEventProbe("users.{$id}.update.email")); @@ -587,25 +589,25 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update.email', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update.email", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update.email', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update.email", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); - $this->assertEquals($webhook['data']['name'], 'New Name'); + $this->assertEquals('New Name', $webhook['data']['name']); $this->assertIsString($webhook['data']['registration']); - $this->assertEquals($webhook['data']['status'], true); + $this->assertEquals(true, $webhook['data']['status']); $this->assertEquals($webhook['data']['email'], $newEmail); - $this->assertEquals($webhook['data']['emailVerification'], false); + $this->assertEquals(false, $webhook['data']['emailVerification']); $this->assertEquals($webhook['data']['prefs'], []); } @@ -640,7 +642,7 @@ class WebhooksCustomClientTest extends Scope ] ]); - $this->assertEquals($account['headers']['status-code'], 200); + $this->assertEquals(200, $account['headers']['status-code']); $this->assertIsArray($account['body']); $webhook = $this->getLastRequest($this->webhookEventProbe("users.{$id}.update.prefs")); @@ -649,25 +651,25 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update.prefs', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update.prefs", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update.prefs', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update.prefs", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); - $this->assertEquals($webhook['data']['name'], 'New Name'); + $this->assertEquals('New Name', $webhook['data']['name']); $this->assertIsString($webhook['data']['registration']); - $this->assertEquals($webhook['data']['status'], true); + $this->assertEquals(true, $webhook['data']['status']); $this->assertEquals($webhook['data']['email'], $email); - $this->assertEquals($webhook['data']['emailVerification'], false); + $this->assertEquals(false, $webhook['data']['emailVerification']); $this->assertEquals($webhook['data']['prefs'], [ 'prefKey1' => 'prefValue1', 'prefKey2' => 'prefValue2', @@ -702,23 +704,23 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.verification.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.verification.*.create', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.verification.{$verificationId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.verification.{$verificationId}.create", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.verification.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.verification.*.create", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.verification.{$verificationId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.verification.{$verificationId}.create", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.verification.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.verification.*.create', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.verification.{$verificationId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.verification.{$verificationId}.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.verification.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.verification.*.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.verification.{$verificationId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.verification.{$verificationId}.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertNotEmpty($webhook['data']['userId']); $this->assertNotEmpty($webhook['data']['secret']); @@ -768,23 +770,23 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.verification.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.verification.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.verification.{$verificationId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.verification.{$verificationId}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.verification.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.verification.*.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.verification.{$verificationId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.verification.{$verificationId}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.verification.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.verification.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.verification.{$verificationId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.verification.{$verificationId}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.verification.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.verification.*.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.verification.{$verificationId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.verification.{$verificationId}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertNotEmpty($webhook['data']['userId']); $this->assertNotEmpty($webhook['data']['secret']); @@ -818,19 +820,19 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.recovery.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.recovery.*.create', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.recovery.{$recoveryId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.recovery.{$recoveryId}.create", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.recovery.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.recovery.*.create", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.recovery.{$recoveryId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.recovery.{$recoveryId}.create", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.recovery.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.recovery.*.create', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.recovery.{$recoveryId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.recovery.{$recoveryId}.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.recovery.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.recovery.*.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.recovery.{$recoveryId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.recovery.{$recoveryId}.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); @@ -885,19 +887,19 @@ class WebhooksCustomClientTest extends Scope $url = $webhook['url']; $signatureExpected = base64_encode(hash_hmac('sha1', $url . $payload, $signatureKey, true)); - $this->assertEquals($webhook['method'], 'POST'); - $this->assertEquals($webhook['headers']['Content-Type'], 'application/json'); - $this->assertEquals($webhook['headers']['User-Agent'], 'Appwrite-Server vdev. Please report abuse at security@appwrite.io'); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.recovery.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.recovery.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.recovery.{$recoveryId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.*.recovery.{$recoveryId}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.recovery.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.recovery.*.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.recovery.{$recoveryId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.recovery.{$recoveryId}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertEquals('POST', $webhook['method']); + $this->assertEquals('application/json', $webhook['headers']['Content-Type']); + $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.recovery.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.recovery.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.recovery.{$recoveryId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.*.recovery.{$recoveryId}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.recovery.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.recovery.*.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.recovery.{$recoveryId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.recovery.{$recoveryId}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); @@ -942,20 +944,20 @@ class WebhooksCustomClientTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('teams.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('teams.*.memberships.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('teams.*.memberships.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('teams.*.memberships.*.update.status', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.*.memberships.{$membershipUid}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.*.memberships.{$membershipUid}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.*.memberships.{$membershipUid}.update.status", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.{$teamUid}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.{$teamUid}.memberships.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.{$teamUid}.memberships.*.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.{$teamUid}.memberships.*.update.status", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.{$teamUid}.memberships.{$membershipUid}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.{$teamUid}.memberships.{$membershipUid}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("teams.{$teamUid}.memberships.{$membershipUid}.update.status", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('teams.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('teams.*.memberships.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('teams.*.memberships.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('teams.*.memberships.*.update.status', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.*.memberships.{$membershipUid}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.*.memberships.{$membershipUid}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.*.memberships.{$membershipUid}.update.status", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.{$teamUid}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.{$teamUid}.memberships.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.{$teamUid}.memberships.*.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.{$teamUid}.memberships.*.update.status", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.{$teamUid}.memberships.{$membershipUid}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.{$teamUid}.memberships.{$membershipUid}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("teams.{$teamUid}.memberships.{$membershipUid}.update.status", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); diff --git a/tests/e2e/Services/ProjectWebhooks/WebhooksCustomServerTest.php b/tests/e2e/Services/ProjectWebhooks/WebhooksCustomServerTest.php index eb08da56f2..04e541ea76 100644 --- a/tests/e2e/Services/ProjectWebhooks/WebhooksCustomServerTest.php +++ b/tests/e2e/Services/ProjectWebhooks/WebhooksCustomServerTest.php @@ -1,5 +1,7 @@ assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$id}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$id}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertTrue(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? '')); + $this->assertEmpty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''); $this->assertNotEmpty($webhook['data']['$id']); $this->assertEquals('Actors1', $webhook['data']['name']); $this->assertIsArray($webhook['data']['$permissions']); @@ -187,16 +189,16 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.indexes.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.indexes.*.create', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}.indexes.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}.indexes.*.create", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.indexes.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.indexes.*.create', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}.indexes.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}.indexes.*.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertTrue(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? '')); + $this->assertEmpty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''); }, 10000, 500); // Remove index @@ -213,16 +215,16 @@ class WebhooksCustomServerTest extends Scope // $this->assertEquals($webhook['method'], 'DELETE'); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.indexes.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.indexes.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}.indexes.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}.indexes.*.update", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.indexes.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.indexes.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}.indexes.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$actorsId}.indexes.*.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertTrue(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? '')); + $this->assertEmpty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''); } public function testDeleteCollection(): void @@ -279,14 +281,14 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.delete', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.collections.{$id}.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.collections.*.delete', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.collections.{$id}.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertTrue(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? '')); + $this->assertEmpty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''); $this->assertNotEmpty($webhook['data']['$id']); $this->assertEquals('Demo', $webhook['data']['name']); $this->assertIsArray($webhook['data']['$permissions']); @@ -322,10 +324,10 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$id}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$id}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); @@ -365,16 +367,16 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.indexes.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.indexes.*.create', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}.indexes.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}.indexes.*.create", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.indexes.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.indexes.*.create', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}.indexes.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}.indexes.*.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertTrue(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? '')); + $this->assertEmpty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''); }, 10000, 500); // Remove index @@ -391,16 +393,16 @@ class WebhooksCustomServerTest extends Scope // $this->assertEquals($webhook['method'], 'DELETE'); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.indexes.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.indexes.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}.indexes.*", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}.indexes.*.update", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.indexes.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.indexes.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}.indexes.*", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$actorsId}.indexes.*.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertTrue(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? '')); + $this->assertEmpty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''); } public function testDeleteTable(): void @@ -457,10 +459,10 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.delete', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("databases.{$databaseId}.tables.{$id}.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('databases.' . $databaseId . '.tables.*.delete', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("databases.{$databaseId}.tables.{$id}.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); @@ -501,14 +503,14 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.create', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.create", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.create', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.create", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertEquals($webhook['data']['name'], $name); $this->assertTrue((new DatetimeValidator())->isValid($webhook['data']['registration'])); @@ -543,16 +545,16 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update.prefs', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update.prefs", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update.prefs', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update.prefs", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertEquals('b', $webhook['data']['a']); } @@ -581,16 +583,16 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.update.status', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.update.status", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.update.status', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.update.status", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertEquals($webhook['data']['name'], $data['name']); $this->assertTrue((new DatetimeValidator())->isValid($webhook['data']['registration'])); @@ -621,14 +623,14 @@ class WebhooksCustomServerTest extends Scope $this->assertEquals('POST', $webhook['method']); $this->assertEquals('application/json', $webhook['headers']['Content-Type']); $this->assertEquals('Appwrite-Server vdev. Please report abuse at security@appwrite.io', $webhook['headers']['User-Agent']); - $this->assertStringContainsString('users.*', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString('users.*.delete', $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}", $webhook['headers']['X-Appwrite-Webhook-Events']); - $this->assertStringContainsString("users.{$id}.delete", $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString('users.*.delete', (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); + $this->assertStringContainsString("users.{$id}.delete", (string) $webhook['headers']['X-Appwrite-Webhook-Events']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Signature'], $signatureExpected); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Id'] ?? '', $this->getProject()['webhookId']); $this->assertEquals($webhook['headers']['X-Appwrite-Webhook-Project-Id'] ?? '', $this->getProject()['$id']); - $this->assertEquals(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); + $this->assertSame(empty($webhook['headers']['X-Appwrite-Webhook-User-Id'] ?? ''), ('server' === $this->getSide())); $this->assertNotEmpty($webhook['data']['$id']); $this->assertEquals($webhook['data']['name'], $data['name']); $this->assertTrue((new DatetimeValidator())->isValid($webhook['data']['registration'])); diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 94eb483f29..caae66b6e5 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -1,5 +1,7 @@ 'Project Test' ])); - $this->assertEquals($response['headers']['status-code'], 200); + $this->assertEquals(200, $response['headers']['status-code']); $this->assertGreaterThan(0, $response['body']['total']); $this->assertIsArray($response['body']['projects']); @@ -2040,7 +2042,7 @@ class ProjectsConsoleClientTest extends Scope }); $this->assertEquals('Fallback sign-in alert', $lastEmail['subject']); $this->assertEquals('Fallback Mailer', $lastEmail['from'][0]['name']); - $this->assertStringContainsString('Fallback sign-in alert body', $lastEmail['html']); + $this->assertStringContainsString('Fallback sign-in alert body', (string) $lastEmail['html']); /** Create a new session with German locale — expect fallback (en) template */ $response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ @@ -2060,7 +2062,7 @@ class ProjectsConsoleClientTest extends Scope }); $this->assertEquals('Fallback sign-in alert', $lastEmail['subject']); $this->assertEquals('Fallback Mailer', $lastEmail['from'][0]['name']); - $this->assertStringContainsString('Fallback sign-in alert body', $lastEmail['html']); + $this->assertStringContainsString('Fallback sign-in alert body', (string) $lastEmail['html']); /** Create a new session with Slovak locale — expect Slovak template */ $response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ @@ -2080,7 +2082,7 @@ class ProjectsConsoleClientTest extends Scope }); $this->assertEquals('Slovak sign-in alert', $lastEmail['subject']); $this->assertEquals('Slovak Mailer', $lastEmail['from'][0]['name']); - $this->assertStringContainsString('Slovak sign-in alert body', $lastEmail['html']); + $this->assertStringContainsString('Slovak sign-in alert body', (string) $lastEmail['html']); /** Cleanup — delete the project */ $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ @@ -2536,7 +2538,7 @@ class ProjectsConsoleClientTest extends Scope 'name' => $name, ]); - $this->assertEquals($response['headers']['status-code'], 501); + $this->assertEquals(501, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ 'content-type' => 'application/json', @@ -2562,7 +2564,7 @@ class ProjectsConsoleClientTest extends Scope 'url' => 'http://localhost:5000/join-us#title' ]); - $this->assertEquals($response['headers']['status-code'], 501); + $this->assertEquals(501, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_POST, '/account/jwt', array_merge([ 'content-type' => 'application/json', @@ -2570,7 +2572,7 @@ class ProjectsConsoleClientTest extends Scope 'cookie' => 'a_session_' . $id . '=' . $session, ])); - $this->assertEquals($response['headers']['status-code'], 501); + $this->assertEquals(501, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([ 'origin' => 'http://localhost', @@ -2581,7 +2583,7 @@ class ProjectsConsoleClientTest extends Scope 'password' => $originalPassword, ]); - $this->assertEquals($response['headers']['status-code'], 501); + $this->assertEquals(501, $response['headers']['status-code']); $response = $this->client->call(Client::METHOD_POST, '/account/sessions/anonymous', array_merge([ 'origin' => 'http://localhost', @@ -2589,7 +2591,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, ])); - $this->assertEquals($response['headers']['status-code'], 501); + $this->assertEquals(501, $response['headers']['status-code']); // Cleanup @@ -2715,7 +2717,7 @@ class ProjectsConsoleClientTest extends Scope 'name' => $name, ]); - $this->assertEquals($response['headers']['status-code'], 201); + $this->assertEquals(201, $response['headers']['status-code']); } public function testUpdateProjectAuthSessionsLimit(): void @@ -3029,7 +3031,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); $lastEmail = $this->getLastEmailByAddress($email, function ($email) { - $this->assertStringContainsString('Password Reset', $email['subject']); + $this->assertStringContainsString('Password Reset', (string) $email['subject']); }); $tokens = $this->extractQueryParamsFromEmailLink($lastEmail['html']); @@ -3230,7 +3232,7 @@ class ProjectsConsoleClientTest extends Scope ]); $this->assertEquals(400, $response['headers']['status-code']); - $this->assertStringContainsString('Value must a valid array no longer than 10 items', $response['body']['message']); + $this->assertStringContainsString('Value must a valid array no longer than 10 items', (string) $response['body']['message']); /** * Test for success @@ -6723,7 +6725,7 @@ class ProjectsConsoleClientTest extends Scope 'error_description' => '', ], followRedirects: false); $this->assertEquals(400, $response['headers']['status-code']); - $this->assertStringContainsString('project_invalid_success_url', $response['body']); + $this->assertStringContainsString('project_invalid_success_url', (string) $response['body']); // Ensure rule's domain can be redirect URL $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [ @@ -6753,7 +6755,7 @@ class ProjectsConsoleClientTest extends Scope 'error_deescription' => '', ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $this->assertStringContainsString('https://' . $domain, $response['headers']['location']); + $this->assertStringContainsString('https://' . $domain, (string) $response['headers']['location']); // Ensure unknown domain cannot be redirect URL $response = $this->client->call(Client::METHOD_POST, '/account/sessions/magic-url', [ @@ -6828,7 +6830,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(301, $response['headers']['status-code']); $this->assertStringStartsWith($scheme . '://', $response['headers']['location']); - $this->assertStringContainsString('error=', $response['headers']['location']); + $this->assertStringContainsString('error=', (string) $response['headers']['location']); } #[Group('abuseEnabled')] @@ -7818,14 +7820,14 @@ class ProjectsConsoleClientTest extends Scope $userEmail = $this->getUser()['email']; $lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) use ($url) { - $this->assertStringContainsString($url, $email['html'] ?? ''); + $this->assertStringContainsString($url, (string) ($email['html'] ?? '')); }); $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); $expectedUrl = $url . "&userId=" . $userId . "&secret="; - $this->assertStringContainsString($expectedUrl, $lastEmail['html']); + $this->assertStringContainsString($expectedUrl, (string) $lastEmail['html']); // With search params, with mobile backlink $url = 'appwriteio://signin?id=abcd1234&tenant=efgh5678&domain=example.com&referred=0'; @@ -7850,14 +7852,14 @@ class ProjectsConsoleClientTest extends Scope $userId = $response['body']['userId']; $lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) use ($url) { - $this->assertStringContainsString($url, $email['html'] ?? ''); + $this->assertStringContainsString($url, (string) ($email['html'] ?? '')); }); $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); $expectedUrl = $url . "&userId=" . $userId . "&secret="; - $this->assertStringContainsString($expectedUrl, $lastEmail['html']); + $this->assertStringContainsString($expectedUrl, (string) $lastEmail['html']); // Without search params $url = 'http://localhost/auth/signin'; @@ -7882,14 +7884,14 @@ class ProjectsConsoleClientTest extends Scope $userId = $response['body']['userId']; $lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) use ($url, $userId) { - $this->assertStringContainsString($url . '?userId=' . $userId, $email['html'] ?? ''); + $this->assertStringContainsString($url . '?userId=' . $userId, (string) ($email['html'] ?? '')); }); $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); $expectedUrl = $url . "?userId=" . $userId . "&secret="; - $this->assertStringContainsString($expectedUrl, $lastEmail['html']); + $this->assertStringContainsString($expectedUrl, (string) $lastEmail['html']); // Without search params, with mobile backlink $url = 'appwriteio://signin'; @@ -7914,14 +7916,14 @@ class ProjectsConsoleClientTest extends Scope $userId = $response['body']['userId']; $lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) use ($url, $userId) { - $this->assertStringContainsString($url . '?userId=' . $userId, $email['html'] ?? ''); + $this->assertStringContainsString($url . '?userId=' . $userId, (string) ($email['html'] ?? '')); }); $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); $expectedUrl = $url . "?userId=" . $userId . "&secret="; - $this->assertStringContainsString($expectedUrl, $lastEmail['html']); + $this->assertStringContainsString($expectedUrl, (string) $lastEmail['html']); // With injection (allowed, meant to be protected client-side) $url = 'http://localhost/auth/signin\">

INJECTED

'; @@ -7946,19 +7948,19 @@ class ProjectsConsoleClientTest extends Scope $userId = $response['body']['userId']; $lastEmail = $this->getLastEmailByAddress($userEmail, function ($email) { - $this->assertStringContainsString('INJECTED', $email['html'] ?? ''); + $this->assertStringContainsString('INJECTED', (string) ($email['html'] ?? '')); }); $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); - $this->assertStringContainsString('INJECTED', $lastEmail['html']); - $this->assertStringContainsString('

', $lastEmail['html']); - $this->assertStringContainsString('

', $lastEmail['html']); - $this->assertStringContainsString('">', $lastEmail['html']); - $this->assertStringContainsString('', $lastEmail['html']); + $this->assertStringContainsString('INJECTED', (string) $lastEmail['html']); + $this->assertStringContainsString('

', (string) $lastEmail['html']); + $this->assertStringContainsString('

', (string) $lastEmail['html']); + $this->assertStringContainsString('">', (string) $lastEmail['html']); + $this->assertStringContainsString('', (string) $lastEmail['html']); $expectedUrl = $url . "?userId=" . $userId . "&secret="; - $this->assertStringContainsString($expectedUrl, $lastEmail['html']); + $this->assertStringContainsString($expectedUrl, (string) $lastEmail['html']); } } diff --git a/tests/e2e/Services/Projects/ProjectsCustomServerTest.php b/tests/e2e/Services/Projects/ProjectsCustomServerTest.php index d87c2cbf78..90c8e296ad 100644 --- a/tests/e2e/Services/Projects/ProjectsCustomServerTest.php +++ b/tests/e2e/Services/Projects/ProjectsCustomServerTest.php @@ -1,5 +1,7 @@ receive(), true); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); - $this->assertStringContainsString('contains', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); + $this->assertStringContainsString('contains', (string) $response['data']['message']); // Test 2: Invalid query method in nested AND query $client = $this->getWebsocket(['documents'], [ @@ -52,8 +54,8 @@ class RealtimeCustomClientQueryTest extends Scope $response = json_decode($client->receive(), true); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); - $this->assertStringContainsString('search', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); + $this->assertStringContainsString('search', (string) $response['data']['message']); // Test 3: Invalid query method in nested OR query $client = $this->getWebsocket(['documents'], [ @@ -68,8 +70,8 @@ class RealtimeCustomClientQueryTest extends Scope $response = json_decode($client->receive(), true); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); - $this->assertStringContainsString('between', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); + $this->assertStringContainsString('between', (string) $response['data']['message']); // Test 4: Deeply nested invalid query (AND -> OR -> invalid) $client = $this->getWebsocket(['documents'], [ @@ -87,8 +89,8 @@ class RealtimeCustomClientQueryTest extends Scope $response = json_decode($client->receive(), true); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); - $this->assertStringContainsString('startsWith', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); + $this->assertStringContainsString('startsWith', (string) $response['data']['message']); // Test 5: Multiple invalid 'queries' in nested structure $client = $this->getWebsocket(['documents'], [ @@ -106,7 +108,7 @@ class RealtimeCustomClientQueryTest extends Scope $response = json_decode($client->receive(), true); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); // Should catch the first invalid method encountered $this->assertTrue( str_contains($response['data']['message'], 'contains') || diff --git a/tests/e2e/Services/Realtime/RealtimeCustomClientQueryTestWithMessage.php b/tests/e2e/Services/Realtime/RealtimeCustomClientQueryTestWithMessage.php index 4d37a8944b..13a7d549dc 100644 --- a/tests/e2e/Services/Realtime/RealtimeCustomClientQueryTestWithMessage.php +++ b/tests/e2e/Services/Realtime/RealtimeCustomClientQueryTestWithMessage.php @@ -1,5 +1,7 @@ sendUnsubscribeMessage($client, [['subscriptionId' => 123]]); $this->assertEquals('error', $errNonString['type']); - $this->assertStringContainsString('subscriptionId', $errNonString['data']['message']); + $this->assertStringContainsString('subscriptionId', (string) $errNonString['data']['message']); $errEmpty = $this->sendUnsubscribeMessage($client, [['subscriptionId' => '']]); $this->assertEquals('error', $errEmpty['type']); @@ -598,8 +600,8 @@ class RealtimeCustomClientQueryTestWithMessage extends Scope Query::contains('status', ['active'])->toString(), ]); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); - $this->assertStringContainsString('contains', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); + $this->assertStringContainsString('contains', (string) $response['data']['message']); // Test 2: Invalid query method in nested AND query $response = $this->receiveSubscribeMessageResponse(['documents'], $headers, [ @@ -609,8 +611,8 @@ class RealtimeCustomClientQueryTestWithMessage extends Scope ])->toString(), ]); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); - $this->assertStringContainsString('search', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); + $this->assertStringContainsString('search', (string) $response['data']['message']); // Test 3: Invalid query method in nested OR query $response = $this->receiveSubscribeMessageResponse(['documents'], $headers, [ @@ -620,8 +622,8 @@ class RealtimeCustomClientQueryTestWithMessage extends Scope ])->toString(), ]); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); - $this->assertStringContainsString('between', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); + $this->assertStringContainsString('between', (string) $response['data']['message']); // Test 4: Deeply nested invalid query (AND -> OR -> invalid) $response = $this->receiveSubscribeMessageResponse(['documents'], $headers, [ @@ -634,8 +636,8 @@ class RealtimeCustomClientQueryTestWithMessage extends Scope ])->toString(), ]); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); - $this->assertStringContainsString('startsWith', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); + $this->assertStringContainsString('startsWith', (string) $response['data']['message']); // Test 5: Multiple invalid 'queries' in nested structure $response = $this->receiveSubscribeMessageResponse(['documents'], $headers, [ @@ -648,7 +650,7 @@ class RealtimeCustomClientQueryTestWithMessage extends Scope ])->toString(), ]); $this->assertEquals('error', $response['type']); - $this->assertStringContainsString('not supported in Realtime queries', $response['data']['message']); + $this->assertStringContainsString('not supported in Realtime queries', (string) $response['data']['message']); $this->assertTrue( \str_contains($response['data']['message'], 'contains') || \str_contains($response['data']['message'], 'endsWith') diff --git a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php index 7fccd6839f..788c008777 100644 --- a/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php +++ b/tests/e2e/Services/Realtime/RealtimeCustomClientTest.php @@ -1,5 +1,7 @@ assertContains("users.*", $response['data']['events']); $lastEmail = $this->getLastEmailByAddress('torsten@appwrite.io', function ($email) use ($userId) { - $this->assertStringContainsString($userId, $email['html']); + $this->assertStringContainsString($userId, (string) $email['html']); }); $tokens = $this->extractQueryParamsFromEmailLink($lastEmail['html']); $verificationSecret = $tokens['secret']; @@ -674,8 +676,8 @@ class RealtimeCustomClientTest extends Scope $response = json_decode($client->receive(), true); $lastEmail = $this->getLastEmailByAddress('torsten@appwrite.io', function ($email) use ($userId) { - $this->assertStringContainsString($userId, $email['html']); - $this->assertStringContainsString('recovery', $email['html']); + $this->assertStringContainsString($userId, (string) $email['html']); + $this->assertStringContainsString('recovery', (string) $email['html']); }); $tokens = $this->extractQueryParamsFromEmailLink($lastEmail['html']); $recoverySecret = $tokens['secret']; diff --git a/tests/e2e/Services/Sites/SitesConsoleClientTest.php b/tests/e2e/Services/Sites/SitesConsoleClientTest.php index 2e0e1a892d..1bd5aa3233 100644 --- a/tests/e2e/Services/Sites/SitesConsoleClientTest.php +++ b/tests/e2e/Services/Sites/SitesConsoleClientTest.php @@ -1,5 +1,7 @@ call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Themed website", $response['body']); - $this->assertStringContainsString("@media (prefers-color-scheme: dark)", $response['body']); + $this->assertStringContainsString("Themed website", (string) $response['body']); + $this->assertStringContainsString("@media (prefers-color-scheme: dark)", (string) $response['body']); $deployment = null; $site = null; @@ -136,7 +138,7 @@ class SitesConsoleClientTest extends Scope $screenshotDarkHash = \md5($file['body']); $this->assertNotEmpty($screenshotDarkHash); - $this->assertNotEquals($screenshotDarkHash, $screenshotHash); + $this->assertNotSame($screenshotDarkHash, $screenshotHash); $screenshotId = $deployment['body']['screenshotLight']; $file = $this->client->call(Client::METHOD_GET, "/storage/buckets/screenshots/files/$screenshotId/preview?project=console"); diff --git a/tests/e2e/Services/Sites/SitesCustomClientTest.php b/tests/e2e/Services/Sites/SitesCustomClientTest.php index d576062c8f..b87faec691 100644 --- a/tests/e2e/Services/Sites/SitesCustomClientTest.php +++ b/tests/e2e/Services/Sites/SitesCustomClientTest.php @@ -1,5 +1,7 @@ assertEquals('github', $template['body']['vcsProvider']); $this->assertEquals('Simple React application integrated with Appwrite SDK.', $template['body']['tagline']); $this->assertIsArray($template['body']['frameworks']); - $this->assertStringContainsString('/images/sites/templates/starter-for-react-dark.png', $template['body']['screenshotDark']); - $this->assertStringContainsString('/images/sites/templates/starter-for-react-light.png', $template['body']['screenshotLight']); + $this->assertStringContainsString('/images/sites/templates/starter-for-react-dark.png', (string) $template['body']['screenshotDark']); + $this->assertStringContainsString('/images/sites/templates/starter-for-react-light.png', (string) $template['body']['screenshotLight']); /** * Test for FAILURE diff --git a/tests/e2e/Services/Sites/SitesCustomServerTest.php b/tests/e2e/Services/Sites/SitesCustomServerTest.php index 9cca689780..2a58a1c17b 100644 --- a/tests/e2e/Services/Sites/SitesCustomServerTest.php +++ b/tests/e2e/Services/Sites/SitesCustomServerTest.php @@ -1,5 +1,7 @@ call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Env variable is Appwrite", $response['body']); - $this->assertStringNotContainsString("Variable not found", $response['body']); + $this->assertStringContainsString("Env variable is Appwrite", (string) $response['body']); + $this->assertStringNotContainsString("Variable not found", (string) $response['body']); $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals(200, $deployment['headers']['status-code']); @@ -869,10 +871,10 @@ class SitesCustomServerTest extends Scope $proxyClient->setEndpoint('http://' . $domain); $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString('Main page', $response['body']); + $this->assertStringContainsString('Main page', (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/something'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString('Main page', $response['body']); + $this->assertStringContainsString('Main page', (string) $response['body']); $this->cleanupSite($siteId); } @@ -939,7 +941,7 @@ class SitesCustomServerTest extends Scope $proxyClient->setEndpoint('http://' . $domain); $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro SSR", $response['body']); + $this->assertStringContainsString("Astro SSR", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/not-found'); $this->assertEquals(404, $response['headers']['status-code']); @@ -951,10 +953,10 @@ class SitesCustomServerTest extends Scope $proxyClient->setEndpoint('http://' . $domain); $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro static", $response['body']); + $this->assertStringContainsString("Astro static", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/not-found'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro static", $response['body']); + $this->assertStringContainsString("Astro static", (string) $response['body']); $this->cleanupSite($siteId); } @@ -979,9 +981,9 @@ class SitesCustomServerTest extends Scope 'search' => 'Test List Sites', ]); - $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertEquals(200, $sites['headers']['status-code']); $this->assertCount(1, $sites['body']['sites']); - $this->assertEquals($sites['body']['sites'][0]['name'], 'Test List Sites'); + $this->assertEquals('Test List Sites', $sites['body']['sites'][0]['name']); // Test pagination limit $sites = $this->listSites([ @@ -990,7 +992,7 @@ class SitesCustomServerTest extends Scope ], ]); - $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertEquals(200, $sites['headers']['status-code']); $this->assertCount(1, $sites['body']['sites']); // Test pagination offset with search filter (to only count our test site) @@ -1001,7 +1003,7 @@ class SitesCustomServerTest extends Scope ], ]); - $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertEquals(200, $sites['headers']['status-code']); $this->assertCount(0, $sites['body']['sites']); // Test filter enabled (with search to isolate our test site) @@ -1012,7 +1014,7 @@ class SitesCustomServerTest extends Scope ], ]); - $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertEquals(200, $sites['headers']['status-code']); $this->assertCount(1, $sites['body']['sites']); // Test filter disabled (with search to isolate our test site) @@ -1023,7 +1025,7 @@ class SitesCustomServerTest extends Scope ], ]); - $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertEquals(200, $sites['headers']['status-code']); $this->assertCount(0, $sites['body']['sites']); // Test search name @@ -1031,7 +1033,7 @@ class SitesCustomServerTest extends Scope 'search' => 'Test List Sites' ]); - $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertEquals(200, $sites['headers']['status-code']); $this->assertCount(1, $sites['body']['sites']); $this->assertEquals($sites['body']['sites'][0]['$id'], $siteId); @@ -1040,7 +1042,7 @@ class SitesCustomServerTest extends Scope 'search' => 'analog' ]); - $this->assertEquals($sites['headers']['status-code'], 200); + $this->assertEquals(200, $sites['headers']['status-code']); $this->assertCount(1, $sites['body']['sites']); $this->assertEquals($sites['body']['sites'][0]['$id'], $siteId); @@ -1062,12 +1064,12 @@ class SitesCustomServerTest extends Scope 'search' => 'Test List Sites', ]); - $this->assertEquals($sites['headers']['status-code'], 200); - $this->assertEquals($sites['body']['total'], 2); + $this->assertEquals(200, $sites['headers']['status-code']); + $this->assertEquals(2, $sites['body']['total']); $this->assertIsArray($sites['body']['sites']); $this->assertCount(2, $sites['body']['sites']); - $this->assertEquals($sites['body']['sites'][0]['name'], 'Test List Sites'); - $this->assertEquals($sites['body']['sites'][1]['name'], 'Test List Sites 2'); + $this->assertEquals('Test List Sites', $sites['body']['sites'][0]['name']); + $this->assertEquals('Test List Sites 2', $sites['body']['sites'][1]['name']); $sites1 = $this->listSites([ 'search' => 'Test List Sites', @@ -1076,9 +1078,9 @@ class SitesCustomServerTest extends Scope ], ]); - $this->assertEquals($sites1['headers']['status-code'], 200); + $this->assertEquals(200, $sites1['headers']['status-code']); $this->assertCount(1, $sites1['body']['sites']); - $this->assertEquals($sites1['body']['sites'][0]['name'], 'Test List Sites 2'); + $this->assertEquals('Test List Sites 2', $sites1['body']['sites'][0]['name']); $sites2 = $this->listSites([ 'search' => 'Test List Sites', @@ -1087,9 +1089,9 @@ class SitesCustomServerTest extends Scope ], ]); - $this->assertEquals($sites2['headers']['status-code'], 200); + $this->assertEquals(200, $sites2['headers']['status-code']); $this->assertCount(1, $sites2['body']['sites']); - $this->assertEquals($sites2['body']['sites'][0]['name'], 'Test List Sites'); + $this->assertEquals('Test List Sites', $sites2['body']['sites'][0]['name']); /** * Test for FAILURE @@ -1099,7 +1101,7 @@ class SitesCustomServerTest extends Scope Query::cursorAfter(new Document(['$id' => 'unknown']))->toString(), ], ]); - $this->assertEquals($sites['headers']['status-code'], 400); + $this->assertEquals(400, $sites['headers']['status-code']); $this->cleanupSite($siteId); $this->cleanupSite($siteId2); @@ -1123,15 +1125,15 @@ class SitesCustomServerTest extends Scope */ $site = $this->getSite($siteId); - $this->assertEquals($site['headers']['status-code'], 200); - $this->assertEquals($site['body']['name'], 'Test Site'); + $this->assertEquals(200, $site['headers']['status-code']); + $this->assertEquals('Test Site', $site['body']['name']); /** * Test for FAILURE */ $site = $this->getSite('x'); - $this->assertEquals($site['headers']['status-code'], 404); + $this->assertEquals(404, $site['headers']['status-code']); $this->cleanupSite($siteId); } @@ -1588,7 +1590,7 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $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($siteId, $deploymentId); @@ -1676,8 +1678,8 @@ class SitesCustomServerTest extends Scope $deployments = $this->listDeployments($siteId); - $this->assertEquals($deployments['headers']['status-code'], 200); - $this->assertEquals($deployments['body']['total'], 2); + $this->assertEquals(200, $deployments['headers']['status-code']); + $this->assertEquals(2, $deployments['body']['total']); $this->assertIsArray($deployments['body']['deployments']); $this->assertCount(2, $deployments['body']['deployments']); $this->assertArrayHasKey('sourceSize', $deployments['body']['deployments'][0]); @@ -1689,7 +1691,7 @@ class SitesCustomServerTest 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($siteId, [ @@ -1698,7 +1700,7 @@ class SitesCustomServerTest extends Scope ], ]); - $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(200, $deployments['headers']['status-code']); $this->assertArrayHasKey('status', $deployments['body']['deployments'][0]); $this->assertArrayHasKey('status', $deployments['body']['deployments'][1]); $this->assertArrayNotHasKey('sourceSize', $deployments['body']['deployments'][0]); @@ -1710,7 +1712,7 @@ class SitesCustomServerTest extends Scope Query::select(['buildLogs'])->toString(), ], ]); - $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(200, $deployments['headers']['status-code']); $this->assertArrayHasKey('buildLogs', $deployments['body']['deployments'][0]); $this->assertArrayHasKey('buildLogs', $deployments['body']['deployments'][1]); $this->assertArrayNotHasKey('sourceSize', $deployments['body']['deployments'][0]); @@ -1722,7 +1724,7 @@ class SitesCustomServerTest 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( @@ -1734,7 +1736,7 @@ class SitesCustomServerTest extends Scope ] ); - $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(200, $deployments['headers']['status-code']); $this->assertEquals(2, $deployments['body']['total']); $deployments = $this->listDeployments( @@ -1746,7 +1748,7 @@ class SitesCustomServerTest 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( @@ -1758,7 +1760,7 @@ class SitesCustomServerTest 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( @@ -1770,7 +1772,7 @@ class SitesCustomServerTest 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( @@ -1782,7 +1784,7 @@ class SitesCustomServerTest extends Scope ] ); - $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(200, $deployments['headers']['status-code']); $this->assertEquals(2, $deployments['body']['total']); $deployments = $this->listDeployments( @@ -1793,7 +1795,7 @@ class SitesCustomServerTest extends Scope ], ] ); - $this->assertEquals($deployments['headers']['status-code'], 200); + $this->assertEquals(200, $deployments['headers']['status-code']); $this->assertEquals(2, $deployments['body']['total']); /** @@ -1887,7 +1889,7 @@ class SitesCustomServerTest extends Scope */ $deployment = $this->getDeployment($siteId, 'x'); - $this->assertEquals($deployment['headers']['status-code'], 404); + $this->assertEquals(404, $deployment['headers']['status-code']); $this->cleanupDeployment($siteId, $deploymentId); $this->cleanupSite($siteId); @@ -2167,7 +2169,7 @@ class SitesCustomServerTest extends Scope ])); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Index page", $response['body']); + $this->assertStringContainsString("Index page", (string) $response['body']); $this->assertArrayHasKey('x-appwrite-log-id', $response['headers']); $this->assertNotEmpty($response['headers']['x-appwrite-log-id']); @@ -2178,7 +2180,7 @@ class SitesCustomServerTest extends Scope ])); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Contact page", $response['body']); + $this->assertStringContainsString("Contact page", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/non-existing', array_merge([ 'content-type' => 'application/json', @@ -2186,9 +2188,9 @@ class SitesCustomServerTest extends Scope ])); $this->assertEquals(404, $response['headers']['status-code']); - $this->assertStringContainsString("Page not found", $response['body']); // Title - $this->assertStringContainsString("Go to homepage", $response['body']); // Button - $this->assertStringNotContainsString("Powered by", $response['body']); // Brand + $this->assertStringContainsString("Page not found", (string) $response['body']); // Title + $this->assertStringContainsString("Go to homepage", (string) $response['body']); // Button + $this->assertStringNotContainsString("Powered by", (string) $response['body']); // Brand $this->cleanupSite($siteId); } @@ -2227,7 +2229,7 @@ class SitesCustomServerTest extends Scope ])); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Index page", $response['body']); + $this->assertStringContainsString("Index page", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/contact', array_merge([ 'content-type' => 'application/json', @@ -2235,7 +2237,7 @@ class SitesCustomServerTest extends Scope ])); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Contact page", $response['body']); + $this->assertStringContainsString("Contact page", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/non-existing', array_merge([ 'content-type' => 'application/json', @@ -2243,8 +2245,8 @@ class SitesCustomServerTest extends Scope ])); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Customized 404 page", $response['body']); - $this->assertStringNotContainsString("Powered by", $response['body']); //brand + $this->assertStringContainsString("Customized 404 page", (string) $response['body']); + $this->assertStringNotContainsString("Powered by", (string) $response['body']); //brand $this->cleanupSite($siteId); } @@ -2301,14 +2303,14 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro Blog", $response['body']); - $this->assertStringContainsString("Hello, Astronaut!", $response['body']); + $this->assertStringContainsString("Astro Blog", (string) $response['body']); + $this->assertStringContainsString("Hello, Astronaut!", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/about'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro Blog", $response['body']); - $this->assertStringContainsString("About Me", $response['body']); + $this->assertStringContainsString("Astro Blog", (string) $response['body']); + $this->assertStringContainsString("About Me", (string) $response['body']); $deployment = $this->getDeployment($siteId, $deployment['body']['$id']); $this->assertEquals(200, $deployment['headers']['status-code']); @@ -2372,14 +2374,14 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro Blog", $response['body']); - $this->assertStringContainsString("Hello, Astronaut!", $response['body']); + $this->assertStringContainsString("Astro Blog", (string) $response['body']); + $this->assertStringContainsString("Hello, Astronaut!", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/about'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro Blog", $response['body']); - $this->assertStringContainsString("About Me", $response['body']); + $this->assertStringContainsString("Astro Blog", (string) $response['body']); + $this->assertStringContainsString("About Me", (string) $response['body']); $deployment = $this->getDeployment($siteId, $deployment['body']['$id']); $this->assertEquals(200, $deployment['headers']['status-code']); @@ -2450,14 +2452,14 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro Blog", $response['body']); - $this->assertStringContainsString("Hello, Astronaut!", $response['body']); + $this->assertStringContainsString("Astro Blog", (string) $response['body']); + $this->assertStringContainsString("Hello, Astronaut!", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/about'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Astro Blog", $response['body']); - $this->assertStringContainsString("About Me", $response['body']); + $this->assertStringContainsString("Astro Blog", (string) $response['body']); + $this->assertStringContainsString("About Me", (string) $response['body']); $deployment = $this->getDeployment($siteId, $deployment['body']['$id']); $this->assertEquals(200, $deployment['headers']['status-code']); @@ -2502,7 +2504,7 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringNotContainsString("This domain is not connected to any Appwrite resource yet", $response['body']); + $this->assertStringNotContainsString("This domain is not connected to any Appwrite resource yet", (string) $response['body']); $site2 = $this->createSite([ 'siteId' => ID::unique(), @@ -2548,7 +2550,7 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(404, $response['headers']['status-code']); - $this->assertStringContainsString("This page is empty, but you can make it yours.", $response['body']); + $this->assertStringContainsString("This page is empty, but you can make it yours.", (string) $response['body']); $site = $this->createSite([ 'siteId' => ID::unique(), @@ -2606,15 +2608,15 @@ class SitesCustomServerTest extends Scope $proxyClient->setEndpoint('http://' . $siteDomain); $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Hello Appwrite", $response['body']); - $this->assertStringNotContainsString("Preview by", $response['body']); + $this->assertStringContainsString("Hello Appwrite", (string) $response['body']); + $this->assertStringNotContainsString("Preview by", (string) $response['body']); $contentLength = $response['headers']['content-length']; $proxyClient = new Client(); $proxyClient->setEndpoint('http://' . $deploymentDomain); $response = $proxyClient->call(Client::METHOD_GET, '/', followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $this->assertStringContainsString('/console/auth/preview', $response['headers']['location']); + $this->assertStringContainsString('/console/auth/preview', (string) $response['headers']['location']); $jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 900, 0); $apiKey = $jwtObj->encode([ @@ -2625,16 +2627,16 @@ class SitesCustomServerTest extends Scope 'x-appwrite-key' => API_KEY_EPHEMERAL . '_' . $apiKey, ]); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Hello Appwrite", $response['body']); - $this->assertStringContainsString("Preview by", $response['body']); + $this->assertStringContainsString("Hello Appwrite", (string) $response['body']); + $this->assertStringContainsString("Preview by", (string) $response['body']); $this->assertGreaterThan($contentLength, $response['headers']['content-length']); $response = $proxyClient->call(Client::METHOD_GET, '/non-existing-path', followRedirects: false, headers: [ 'x-appwrite-key' => API_KEY_EPHEMERAL . '_' . $apiKey, ]); $this->assertEquals(404, $response['headers']['status-code']); - $this->assertStringContainsString("Page not found", $response['body']); - $this->assertStringNotContainsString("Preview by", $response['body']); + $this->assertStringContainsString("Page not found", (string) $response['body']); + $this->assertStringNotContainsString("Preview by", (string) $response['body']); $this->assertGreaterThan($contentLength, $response['headers']['content-length']); $this->cleanupSite($siteId); @@ -2732,7 +2734,7 @@ class SitesCustomServerTest extends Scope $buildMd5 = \md5($response['body']); - $this->assertNotEquals($deploymentMd5, $buildMd5); + $this->assertNotSame($deploymentMd5, $buildMd5); $this->cleanupSite($siteId); } @@ -2768,7 +2770,7 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/logs-inline'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Inline logs printed.", $response['body']); + $this->assertStringContainsString("Inline logs printed.", (string) $response['body']); // Poll for execution logs to be written (async) // Filter by requestPath to avoid picking up screenshot worker executions @@ -2790,13 +2792,13 @@ class SitesCustomServerTest extends Scope $this->assertNotEmpty($logs['body']['executions'], 'Execution logs were not available within timeout'); $this->assertNotNull($logs['body']['executions'][0]['logs'], 'Execution logs content was not populated within timeout'); $this->assertEquals(200, $logs['headers']['status-code']); - $this->assertStringContainsString($deploymentId, $logs['body']['executions'][0]['deploymentId']); - $this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']); - $this->assertStringContainsString("/logs-inline", $logs['body']['executions'][0]['requestPath']); - $this->assertStringContainsString("Log1", $logs['body']['executions'][0]['logs']); - $this->assertStringContainsString("Log2", $logs['body']['executions'][0]['logs']); - $this->assertStringContainsString("Error1", $logs['body']['executions'][0]['errors']); - $this->assertStringContainsString("Error2", $logs['body']['executions'][0]['errors']); + $this->assertStringContainsString($deploymentId, (string) $logs['body']['executions'][0]['deploymentId']); + $this->assertStringContainsString("GET", (string) $logs['body']['executions'][0]['requestMethod']); + $this->assertStringContainsString("/logs-inline", (string) $logs['body']['executions'][0]['requestPath']); + $this->assertStringContainsString("Log1", (string) $logs['body']['executions'][0]['logs']); + $this->assertStringContainsString("Log2", (string) $logs['body']['executions'][0]['logs']); + $this->assertStringContainsString("Error1", (string) $logs['body']['executions'][0]['errors']); + $this->assertStringContainsString("Error2", (string) $logs['body']['executions'][0]['errors']); $log1Id = $logs['body']['executions'][0]['$id']; $this->assertNotEmpty($log1Id); @@ -2820,7 +2822,7 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/logs-action'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Action logs printed.", $response['body']); + $this->assertStringContainsString("Action logs printed.", (string) $response['body']); $logs = null; $start = \time(); @@ -2838,13 +2840,13 @@ class SitesCustomServerTest extends Scope $this->assertNotEmpty($logs['body']['executions'], 'Action execution logs were not available within timeout'); $this->assertNotNull($logs['body']['executions'][0]['logs'], 'Action execution logs content was not populated within timeout'); $this->assertEquals(200, $logs['headers']['status-code']); - $this->assertStringContainsString($deploymentId, $logs['body']['executions'][0]['deploymentId']); - $this->assertStringContainsString("GET", $logs['body']['executions'][0]['requestMethod']); - $this->assertStringContainsString("/logs-action", $logs['body']['executions'][0]['requestPath']); - $this->assertStringContainsString("Log1", $logs['body']['executions'][0]['logs']); - $this->assertStringContainsString("Log2", $logs['body']['executions'][0]['logs']); - $this->assertStringContainsString("Error1", $logs['body']['executions'][0]['errors']); - $this->assertStringContainsString("Error2", $logs['body']['executions'][0]['errors']); + $this->assertStringContainsString($deploymentId, (string) $logs['body']['executions'][0]['deploymentId']); + $this->assertStringContainsString("GET", (string) $logs['body']['executions'][0]['requestMethod']); + $this->assertStringContainsString("/logs-action", (string) $logs['body']['executions'][0]['requestPath']); + $this->assertStringContainsString("Log1", (string) $logs['body']['executions'][0]['logs']); + $this->assertStringContainsString("Log2", (string) $logs['body']['executions'][0]['logs']); + $this->assertStringContainsString("Error1", (string) $logs['body']['executions'][0]['errors']); + $this->assertStringContainsString("Error2", (string) $logs['body']['executions'][0]['errors']); $log2Id = $logs['body']['executions'][0]['$id']; $this->assertNotEmpty($log2Id); @@ -2870,7 +2872,7 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($proxyClient) { $response = $proxyClient->call(Client::METHOD_GET, '/logs-inline'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Inline logs printed.", $response['body']); + $this->assertStringContainsString("Inline logs printed.", (string) $response['body']); }, 15_000, 500); // Poll for the NEW log entry (after logging was disabled) to appear @@ -2902,7 +2904,7 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/logs-action'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Action logs printed.", $response['body']); + $this->assertStringContainsString("Action logs printed.", (string) $response['body']); // Poll for the NEW log entry for /logs-action $start = \time(); @@ -2957,7 +2959,7 @@ class SitesCustomServerTest extends Scope $this->assertNotEmpty($deploymentId1); $response = $proxyClient->call(Client::METHOD_GET, '/not-found'); - $this->assertStringContainsString("Customized 404 page", $response['body']); + $this->assertStringContainsString("Customized 404 page", (string) $response['body']); $site = $this->updateSite([ '$id' => $siteId, @@ -3016,7 +3018,7 @@ class SitesCustomServerTest extends Scope }, 120000, 500); $response = $proxyClient->call(Client::METHOD_GET, '/not-found'); - $this->assertStringContainsString("Index page", $response['body']); + $this->assertStringContainsString("Index page", (string) $response['body']); $deployment = $this->getDeployment($siteId, $deploymentId2); $this->assertEquals(200, $deployment['headers']['status-code']); @@ -3066,7 +3068,7 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString('Hello Appwrite', $response['body']); + $this->assertStringContainsString('Hello Appwrite', (string) $response['body']); $deploymentId2 = $this->setupDeployment($siteId, [ 'code' => $this->packageSite('static-spa'), @@ -3081,7 +3083,7 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString('Index page', $response['body']); + $this->assertStringContainsString('Index page', (string) $response['body']); $site = $this->getSite($siteId); $this->assertEquals(200, $site['headers']['status-code']); @@ -3101,7 +3103,7 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString('Hello Appwrite', $response['body']); + $this->assertStringContainsString('Hello Appwrite', (string) $response['body']); $deployment = $this->deleteDeployment($siteId, $deploymentId2); $this->assertEquals(204, $deployment['headers']['status-code']); @@ -3139,10 +3141,10 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/contact', followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $this->assertStringContainsString('/console/auth/preview', $response['headers']['location']); - $this->assertStringContainsString('projectId=' . $this->getProject()['$id'], $response['headers']['location']); - $this->assertStringContainsString('origin=', $response['headers']['location']); - $this->assertStringContainsString('path=%2Fcontact', $response['headers']['location']); + $this->assertStringContainsString('/console/auth/preview', (string) $response['headers']['location']); + $this->assertStringContainsString('projectId=' . $this->getProject()['$id'], (string) $response['headers']['location']); + $this->assertStringContainsString('origin=', (string) $response['headers']['location']); + $this->assertStringContainsString('path=%2Fcontact', (string) $response['headers']['location']); $session = $this->client->call(Client::METHOD_POST, '/account/sessions/email', array_merge([ 'origin' => 'http://localhost', @@ -3172,11 +3174,11 @@ class SitesCustomServerTest extends Scope ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); $this->assertArrayHasKey('set-cookie', $response['headers']); - $this->assertStringContainsString('a_jwt_console=', $response['headers']['set-cookie']); + $this->assertStringContainsString('a_jwt_console=', (string) $response['headers']['set-cookie']); // due to swoole update; no more httponly - $this->assertStringContainsString('HttpOnly', $response['headers']['set-cookie']); - $this->assertStringContainsString('domain=' . $domain, $response['headers']['set-cookie']); - $this->assertStringContainsString('path=/', $response['headers']['set-cookie']); + $this->assertStringContainsString('HttpOnly', (string) $response['headers']['set-cookie']); + $this->assertStringContainsString('domain=' . $domain, (string) $response['headers']['set-cookie']); + $this->assertStringContainsString('path=/', (string) $response['headers']['set-cookie']); $this->assertNotEmpty($response['cookies']['a_jwt_console']); $this->assertEquals($jwt['body']['jwt'], $response['cookies']['a_jwt_console']); @@ -3184,8 +3186,8 @@ class SitesCustomServerTest extends Scope 'cookie' => 'a_jwt_console=' . $jwt['body']['jwt'] ], followRedirects: false); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Contact page", $response['body']); - $this->assertStringContainsString("Preview by", $response['body']); + $this->assertStringContainsString("Contact page", (string) $response['body']); + $this->assertStringContainsString("Preview by", (string) $response['body']); // Failure: Session missing (old bad, new ok) $session = $this->client->call(Client::METHOD_DELETE, '/account/sessions/current', array_merge([ @@ -3200,7 +3202,7 @@ class SitesCustomServerTest extends Scope 'cookie' => 'a_jwt_console=' . $jwt['body']['jwt'] ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $this->assertStringContainsString('/console/auth/preview', $response['headers']['location']); + $this->assertStringContainsString('/console/auth/preview', (string) $response['headers']['location']); // Failure: User missing $cookie = 'a_session_console=' .$this->getRoot()['session']; @@ -3217,8 +3219,8 @@ class SitesCustomServerTest extends Scope 'cookie' => 'a_jwt_console=' . $jwt['body']['jwt'] ], followRedirects: false); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Contact page", $response['body']); - $this->assertStringContainsString("Preview by", $response['body']); + $this->assertStringContainsString("Contact page", (string) $response['body']); + $this->assertStringContainsString("Preview by", (string) $response['body']); $user = $this->client->call(Client::METHOD_PATCH, '/account/status', array_merge([ 'origin' => 'http://localhost', @@ -3233,7 +3235,7 @@ class SitesCustomServerTest extends Scope 'cookie' => 'a_jwt_console=' . $jwt['body']['jwt'] ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $this->assertStringContainsString('/console/auth/preview', $response['headers']['location']); + $this->assertStringContainsString('/console/auth/preview', (string) $response['headers']['location']); // Failure: Membership missing $email = \uniqid() . 'newuser@appwrite.io'; @@ -3273,7 +3275,7 @@ class SitesCustomServerTest extends Scope 'cookie' => 'a_jwt_console=' . $jwt['body']['jwt'] ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $this->assertStringContainsString('/console/auth/preview', $response['headers']['location']); + $this->assertStringContainsString('/console/auth/preview', (string) $response['headers']['location']); $this->cleanupSite($siteId); } @@ -3347,7 +3349,7 @@ class SitesCustomServerTest extends Scope }, 100000, 500); $response = $proxyClient->call(Client::METHOD_GET, '/'); - $this->assertStringContainsString('This page is empty, activate a deployment to make it live.', $response['body']); + $this->assertStringContainsString('This page is empty, activate a deployment to make it live.', (string) $response['body']); $this->cleanupSite($siteId); } @@ -3378,18 +3380,18 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($proxyClient) { $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString('Sub-directory index', $response['body']); + $this->assertStringContainsString('Sub-directory index', (string) $response['body']); }, 30000, 500); $this->assertEventually(function () use ($proxyClient) { $response1 = $proxyClient->call(Client::METHOD_GET, '/project1'); $this->assertEquals(200, $response1['headers']['status-code']); - $this->assertStringContainsString('Sub-directory project1', $response1['body']); + $this->assertStringContainsString('Sub-directory project1', (string) $response1['body']); }, 30000, 500); $response2 = $proxyClient->call(Client::METHOD_GET, '/project1/'); $this->assertEquals(200, $response2['headers']['status-code']); - $this->assertStringContainsString('Sub-directory project1', $response2['body']); + $this->assertStringContainsString('Sub-directory project1', (string) $response2['body']); $this->cleanupSite($siteId); } @@ -3418,8 +3420,8 @@ class SitesCustomServerTest extends Scope $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals(200, $deployment['headers']['status-code']); - $this->assertStringContainsString('Hello one', $deployment['body']['buildLogs']); - $this->assertStringContainsString('Hello two', $deployment['body']['buildLogs']); + $this->assertStringContainsString('Hello one', (string) $deployment['body']['buildLogs']); + $this->assertStringContainsString('Hello two', (string) $deployment['body']['buildLogs']); $this->cleanupSite($siteId); } @@ -3435,8 +3437,8 @@ class SitesCustomServerTest 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']); $siteId = $this->setupSite([ 'siteId' => ID::unique(), @@ -3488,20 +3490,20 @@ class SitesCustomServerTest extends Scope 'canceled' => 'Deployment build canceled', default => 'Deployment is still building', }; - $this->assertStringContainsString($expectedMessage, $response['body']); + $this->assertStringContainsString($expectedMessage, (string) $response['body']); $expectedCta = match ($status) { 'failed' => 'View logs', 'canceled' => 'View deployments', default => 'Reload', }; - $this->assertStringContainsString($expectedCta, $response['body']); + $this->assertStringContainsString($expectedCta, (string) $response['body']); // check site domain for no active deployments $proxyClient->setEndpoint('http://' . $domain); $response = $proxyClient->call(Client::METHOD_GET, '/'); $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']); $deployment = $this->createDeployment($siteId, [ 'code' => $this->packageSite('static-single-file'), @@ -3523,9 +3525,9 @@ class SitesCustomServerTest extends Scope 'x-appwrite-key' => API_KEY_EPHEMERAL . '_' . $apiKey, ]); $this->assertEquals(400, $response['headers']['status-code']); - $this->assertStringContainsString("Deployment is still building", $response['body']); - $this->assertStringContainsString("View logs", $response['body']); - $this->assertStringContainsString("Reload", $response['body']); + $this->assertStringContainsString("Deployment is still building", (string) $response['body']); + $this->assertStringContainsString("View logs", (string) $response['body']); + $this->assertStringContainsString("Reload", (string) $response['body']); $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); @@ -3538,8 +3540,8 @@ class SitesCustomServerTest extends Scope 'x-appwrite-key' => API_KEY_EPHEMERAL . '_' . $apiKey, ]); $this->assertEquals(400, $response['headers']['status-code']); - $this->assertStringContainsString("Deployment build failed", $response['body']); - $this->assertStringContainsString("View logs", $response['body']); + $this->assertStringContainsString("Deployment build failed", (string) $response['body']); + $this->assertStringContainsString("View logs", (string) $response['body']); $this->cleanupSite($siteId); } @@ -3574,7 +3576,7 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status does not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); - $this->assertStringContainsString('Error:', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('Error:', (string) $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); }, 100000, 500); $this->cleanupSite($siteId); @@ -3604,7 +3606,7 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status does not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); - $this->assertStringContainsString('Error:', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('Error:', (string) $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); }, 100000, 500); $this->cleanupSite($siteId); @@ -3633,7 +3635,7 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals('failed', $deployment['body']['status'], 'Deployment status does not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); - $this->assertStringContainsString('No such file or directory', $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); + $this->assertStringContainsString('No such file or directory', (string) $deployment['body']['buildLogs'], 'Deployment logs do not match: ' . json_encode($deployment['body'], JSON_PRETTY_PRINT)); }, 100000, 500); $this->cleanupSite($siteId); @@ -3675,8 +3677,8 @@ class SitesCustomServerTest extends Scope $deployment = $this->getDeployment($siteId, $deploymentId); $this->assertEquals(200, $deployment['headers']['status-code']); - $this->assertStringContainsString('custom error', $deployment['body']['buildLogs']); - $this->assertStringContainsString('Adapter mismatch', $deployment['body']['buildLogs']); + $this->assertStringContainsString('custom error', (string) $deployment['body']['buildLogs']); + $this->assertStringContainsString('Adapter mismatch', (string) $deployment['body']['buildLogs']); $this->cleanupSite($siteId); } @@ -3754,29 +3756,29 @@ class SitesCustomServerTest extends Scope $response = $proxyClient->call(Client::METHOD_GET, '/'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Homepage OK", $response['body']); + $this->assertStringContainsString("Homepage OK", (string) $response['body']); $response = $proxyClient->call(Client::METHOD_GET, '/ssr'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("SSR OK", $response['body']); + $this->assertStringContainsString("SSR OK", (string) $response['body']); $originalBody = $response['body']; $response = $proxyClient->call(Client::METHOD_GET, '/ssr'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("SSR OK", $response['body']); + $this->assertStringContainsString("SSR OK", (string) $response['body']); $this->assertNotEquals($originalBody, $response['body']); // Includes Date.now() $response = $proxyClient->call(Client::METHOD_GET, '/ssr-custom'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Custom SSR OK", $response['body']); + $this->assertStringContainsString("Custom SSR OK", (string) $response['body']); $originalBody = $response['body']; $response = $proxyClient->call(Client::METHOD_GET, '/ssr-custom'); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertStringContainsString("Custom SSR OK", $response['body']); + $this->assertStringContainsString("Custom SSR OK", (string) $response['body']); $this->assertNotEquals($originalBody, $response['body']); // Includes Date.now() $response = $proxyClient->call(Client::METHOD_GET, '/non-existing'); $this->assertEquals(500, $response['headers']['status-code']); - $this->assertStringContainsString("Custom error", $response['body']); + $this->assertStringContainsString("Custom error", (string) $response['body']); $this->cleanupSite($siteId); } @@ -3815,7 +3817,7 @@ class SitesCustomServerTest extends Scope $this->assertEventually(function () use ($siteId, $deploymentId) { $deployment = $this->getDeployment($siteId, $deploymentId); // TODO: This assertion is not testing what we set in create function, because build worker currently overrides to minimal build specs - $this->assertStringContainsString('2048:1', $deployment['body']['buildLogs']); + $this->assertStringContainsString('2048:1', (string) $deployment['body']['buildLogs']); }, 10000, 500); // Check if the sites specifications are correctly set in executions diff --git a/tests/e2e/Services/Storage/StorageConsoleClientTest.php b/tests/e2e/Services/Storage/StorageConsoleClientTest.php index 2c39a12f09..9d2a639631 100644 --- a/tests/e2e/Services/Storage/StorageConsoleClientTest.php +++ b/tests/e2e/Services/Storage/StorageConsoleClientTest.php @@ -1,5 +1,7 @@ '32h' ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); /** * Test for SUCCESS @@ -40,7 +42,7 @@ class StorageConsoleClientTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(7, count($response['body'])); + $this->assertCount(7, $response['body']); $this->assertEquals('24h', $response['body']['range']); $this->assertIsNumeric($response['body']['bucketsTotal']); $this->assertIsNumeric($response['body']['filesTotal']); @@ -99,7 +101,7 @@ class StorageConsoleClientTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(7, count($response['body'])); + $this->assertCount(7, $response['body']); $this->assertEquals('24h', $response['body']['range']); $this->assertIsNumeric($response['body']['filesTotal']); $this->assertIsNumeric($response['body']['filesStorageTotal']); diff --git a/tests/e2e/Services/Storage/StorageCustomClientTest.php b/tests/e2e/Services/Storage/StorageCustomClientTest.php index 5d677021f1..7f188241b4 100644 --- a/tests/e2e/Services/Storage/StorageCustomClientTest.php +++ b/tests/e2e/Services/Storage/StorageCustomClientTest.php @@ -1,5 +1,7 @@ assertEquals($file['headers']['status-code'], 201); + $this->assertEquals(201, $file['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file['body']['$createdAt'])); $this->assertEquals('permissions.png', $file['body']['name']); @@ -200,7 +202,7 @@ class StorageCustomClientTest extends Scope ]); $fileId = $file['body']['$id']; - $this->assertEquals($file['headers']['status-code'], 201); + $this->assertEquals(201, $file['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file['body']['$createdAt'])); $this->assertEquals('permissions.png', $file['body']['name']); @@ -286,7 +288,7 @@ class StorageCustomClientTest extends Scope ]); $fileId = $file['body']['$id']; - $this->assertEquals($file['headers']['status-code'], 201); + $this->assertEquals(201, $file['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file['body']['$createdAt'])); $this->assertEquals('permissions.png', $file['body']['name']); @@ -338,7 +340,7 @@ class StorageCustomClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', [ 'content-type' => 'multipart/form-data', @@ -348,7 +350,7 @@ class StorageCustomClientTest extends Scope 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'), ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ 'content-type' => 'application/json', @@ -357,14 +359,14 @@ class StorageCustomClientTest extends Scope 'permissions' => [], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); /** * Test for SUCCESS @@ -411,7 +413,7 @@ class StorageCustomClientTest extends Scope ]); $fileId = $file['body']['$id']; - $this->assertEquals($file['headers']['status-code'], 201); + $this->assertEquals(201, $file['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file['body']['$createdAt'])); $this->assertEquals('permissions.png', $file['body']['name']); @@ -482,14 +484,14 @@ class StorageCustomClientTest extends Scope $this->assertEquals(401, $file['headers']['status-code']); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $email = ID::unique() . '@localhost.test'; $password = 'password'; @@ -501,7 +503,7 @@ class StorageCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $user2['session'], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', [ 'content-type' => 'multipart/form-data', @@ -512,7 +514,7 @@ class StorageCustomClientTest extends Scope 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'), ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ 'content-type' => 'application/json', @@ -522,7 +524,7 @@ class StorageCustomClientTest extends Scope 'permissions' => [], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ 'content-type' => 'application/json', @@ -530,7 +532,7 @@ class StorageCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $user2['session'], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); /** * Test for SUCCESS @@ -589,7 +591,7 @@ class StorageCustomClientTest extends Scope ]); $fileId = $file['body']['$id']; - $this->assertEquals($file['headers']['status-code'], 201); + $this->assertEquals(201, $file['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file['body']['$createdAt'])); $this->assertEquals('permissions.png', $file['body']['name']); @@ -682,7 +684,7 @@ class StorageCustomClientTest extends Scope 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'), ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); // Team 2 update failure $file = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ @@ -693,7 +695,7 @@ class StorageCustomClientTest extends Scope 'permissions' => [], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); // Team 2 delete failure $file = $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ @@ -702,7 +704,7 @@ class StorageCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $user2['session'], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); /** * Test for SUCCESS @@ -751,7 +753,7 @@ class StorageCustomClientTest extends Scope ]); $fileId = $file1['body']['$id']; - $this->assertEquals($file1['headers']['status-code'], 201); + $this->assertEquals(201, $file1['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file1['body']['$createdAt'])); $this->assertEquals('permissions.png', $file1['body']['name']); @@ -840,7 +842,7 @@ class StorageCustomClientTest extends Scope ]); $fileId = $file1['body']['$id']; - $this->assertEquals($file1['headers']['status-code'], 201); + $this->assertEquals(201, $file1['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file1['body']['$createdAt'])); $this->assertEquals('permissions.png', $file1['body']['name']); @@ -929,7 +931,7 @@ class StorageCustomClientTest extends Scope ]); $fileId = $file1['body']['$id']; - $this->assertEquals($file1['headers']['status-code'], 201); + $this->assertEquals(201, $file1['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file1['body']['$createdAt'])); $this->assertEquals('permissions.png', $file1['body']['name']); @@ -992,7 +994,7 @@ class StorageCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $user2['session'], ]); - $this->assertEquals($file['headers']['status-code'], 404); + $this->assertEquals(404, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId . '/files', [ 'content-type' => 'multipart/form-data', @@ -1003,7 +1005,7 @@ class StorageCustomClientTest extends Scope 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'), ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ 'content-type' => 'application/json', @@ -1013,7 +1015,7 @@ class StorageCustomClientTest extends Scope 'permissions' => [], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); $file = $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ 'content-type' => 'application/json', @@ -1021,7 +1023,7 @@ class StorageCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $user2['session'], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); } public function testFileTeamPermissions(): void @@ -1068,7 +1070,7 @@ class StorageCustomClientTest extends Scope ]); $fileId = $file['body']['$id']; - $this->assertEquals($file['headers']['status-code'], 201); + $this->assertEquals(201, $file['headers']['status-code']); $this->assertNotEmpty($fileId); $this->assertEquals(true, (new DatetimeValidator())->isValid($file['body']['$createdAt'])); $this->assertEquals('permissions.png', $file['body']['name']); @@ -1171,7 +1173,7 @@ class StorageCustomClientTest extends Scope 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'), ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); // Team 2 update failure $file = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ @@ -1182,7 +1184,7 @@ class StorageCustomClientTest extends Scope 'permissions' => [], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); // Team 2 delete failure $file = $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucketId . '/files/' . $fileId, [ @@ -1191,7 +1193,7 @@ class StorageCustomClientTest extends Scope 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $user2['session'], ]); - $this->assertEquals($file['headers']['status-code'], 401); + $this->assertEquals(401, $file['headers']['status-code']); /** * Test for SUCCESS @@ -1300,7 +1302,7 @@ class StorageCustomClientTest extends Scope 'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'permissions.png'), ]); - $this->assertEquals($file['headers']['status-code'], 201); + $this->assertEquals(201, $file['headers']['status-code']); $this->assertNotEmpty($file['body']['$id']); $this->assertContains(Permission::read(Role::user($this->getUser()['$id'])), $file['body']['$permissions']); $this->assertContains(Permission::update(Role::user($this->getUser()['$id'])), $file['body']['$permissions']); @@ -1332,9 +1334,9 @@ class StorageCustomClientTest extends Scope $this->assertEquals(401, $file['headers']['status-code']); $this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']); - $this->assertStringContainsString('any', $file['body']['message']); - $this->assertStringContainsString('users', $file['body']['message']); - $this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']); + $this->assertStringContainsString('any', (string) $file['body']['message']); + $this->assertStringContainsString('users', (string) $file['body']['message']); + $this->assertStringContainsString('user:' . $this->getUser()['$id'], (string) $file['body']['message']); $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $data['bucketId'] . '/files', array_merge([ 'content-type' => 'multipart/form-data', @@ -1351,9 +1353,9 @@ class StorageCustomClientTest extends Scope $this->assertEquals(401, $file['headers']['status-code']); $this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']); - $this->assertStringContainsString('any', $file['body']['message']); - $this->assertStringContainsString('users', $file['body']['message']); - $this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']); + $this->assertStringContainsString('any', (string) $file['body']['message']); + $this->assertStringContainsString('users', (string) $file['body']['message']); + $this->assertStringContainsString('user:' . $this->getUser()['$id'], (string) $file['body']['message']); $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $data['bucketId'] . '/files', array_merge([ 'content-type' => 'multipart/form-data', @@ -1371,9 +1373,9 @@ class StorageCustomClientTest extends Scope $this->assertEquals(401, $file['headers']['status-code']); $this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']); - $this->assertStringContainsString('any', $file['body']['message']); - $this->assertStringContainsString('users', $file['body']['message']); - $this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']); + $this->assertStringContainsString('any', (string) $file['body']['message']); + $this->assertStringContainsString('users', (string) $file['body']['message']); + $this->assertStringContainsString('user:' . $this->getUser()['$id'], (string) $file['body']['message']); } public function testUpdateFileAbusePermissions(): void @@ -1393,9 +1395,9 @@ class StorageCustomClientTest extends Scope $this->assertEquals(401, $file['headers']['status-code']); $this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']); - $this->assertStringContainsString('any', $file['body']['message']); - $this->assertStringContainsString('users', $file['body']['message']); - $this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']); + $this->assertStringContainsString('any', (string) $file['body']['message']); + $this->assertStringContainsString('users', (string) $file['body']['message']); + $this->assertStringContainsString('user:' . $this->getUser()['$id'], (string) $file['body']['message']); $file = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $data['bucketId'] . '/files/' . $data['fileId'], array_merge([ 'content-type' => 'application/json', @@ -1409,9 +1411,9 @@ class StorageCustomClientTest extends Scope $this->assertEquals(401, $file['headers']['status-code']); $this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']); - $this->assertStringContainsString('any', $file['body']['message']); - $this->assertStringContainsString('users', $file['body']['message']); - $this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']); + $this->assertStringContainsString('any', (string) $file['body']['message']); + $this->assertStringContainsString('users', (string) $file['body']['message']); + $this->assertStringContainsString('user:' . $this->getUser()['$id'], (string) $file['body']['message']); $file = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $data['bucketId'] . '/files/' . $data['fileId'], array_merge([ 'content-type' => 'application/json', @@ -1426,9 +1428,9 @@ class StorageCustomClientTest extends Scope $this->assertEquals(401, $file['headers']['status-code']); $this->assertStringStartsWith('Permissions must be one of:', $file['body']['message']); - $this->assertStringContainsString('any', $file['body']['message']); - $this->assertStringContainsString('users', $file['body']['message']); - $this->assertStringContainsString('user:' . $this->getUser()['$id'], $file['body']['message']); + $this->assertStringContainsString('any', (string) $file['body']['message']); + $this->assertStringContainsString('users', (string) $file['body']['message']); + $this->assertStringContainsString('user:' . $this->getUser()['$id'], (string) $file['body']['message']); } public function testCreateBucketTransformationsDisabled(): void @@ -1481,7 +1483,7 @@ class StorageCustomClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], ]); $this->assertEquals(403, $preview['headers']['status-code']); - $this->assertStringContainsString('Image transformations are disabled for the requested bucket.', $preview['body']['message']); + $this->assertStringContainsString('Image transformations are disabled for the requested bucket.', (string) $preview['body']['message']); // Delete the bucket $response = $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucket['body']['$id'], [ @@ -1521,7 +1523,7 @@ class StorageCustomClientTest extends Scope ]); $this->assertSame(201, $file['headers']['status-code']); $this->assertSame('gzip', $file['body']['compression']); - $this->assertSame(true, $file['body']['encryption']); + $this->assertTrue($file['body']['encryption']); // Get file $file = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucket['body']['$id'] . '/files/' . $file['body']['$id'], [ @@ -1530,7 +1532,7 @@ class StorageCustomClientTest extends Scope ]); $this->assertSame(200, $file['headers']['status-code']); $this->assertSame('gzip', $file['body']['compression']); - $this->assertSame(true, $file['body']['encryption']); + $this->assertTrue($file['body']['encryption']); // List files $files = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucket['body']['$id'] . '/files', [ @@ -1540,7 +1542,7 @@ class StorageCustomClientTest extends Scope $this->assertSame(200, $files['headers']['status-code']); $this->assertSame(1, $files['body']['total']); $this->assertSame('gzip', $files['body']['files'][0]['compression']); - $this->assertSame(true, $files['body']['files'][0]['encryption']); + $this->assertTrue($files['body']['files'][0]['encryption']); // Update the bucket $bucket = $this->client->call(Client::METHOD_PUT, '/storage/buckets/' . $bucket['body']['$id'], [ @@ -1560,7 +1562,7 @@ class StorageCustomClientTest extends Scope ]); $this->assertSame(200, $file['headers']['status-code']); $this->assertSame('gzip', $file['body']['compression']); - $this->assertSame(true, $file['body']['encryption']); + $this->assertTrue($file['body']['encryption']); // Create 2nd file $file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucket['body']['$id'] . '/files', [ @@ -1573,7 +1575,7 @@ class StorageCustomClientTest extends Scope ]); $this->assertSame(201, $file['headers']['status-code']); $this->assertSame('none', $file['body']['compression']); - $this->assertSame(false, $file['body']['encryption']); + $this->assertFalse($file['body']['encryption']); // Get file $file = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucket['body']['$id'] . '/files/' . $file['body']['$id'], [ @@ -1582,7 +1584,7 @@ class StorageCustomClientTest extends Scope ]); $this->assertSame(200, $file['headers']['status-code']); $this->assertSame('none', $file['body']['compression']); - $this->assertSame(false, $file['body']['encryption']); + $this->assertFalse($file['body']['encryption']); // List files $files = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucket['body']['$id'] . '/files', [ @@ -1592,9 +1594,9 @@ class StorageCustomClientTest extends Scope $this->assertSame(200, $files['headers']['status-code']); $this->assertSame(2, $files['body']['total']); $this->assertSame('none', $files['body']['files'][1]['compression']); - $this->assertSame(false, $files['body']['files'][1]['encryption']); + $this->assertFalse($files['body']['files'][1]['encryption']); $this->assertSame('gzip', $files['body']['files'][0]['compression']); - $this->assertSame(true, $files['body']['files'][0]['encryption']); + $this->assertTrue($files['body']['files'][0]['encryption']); // Delete the bucket $response = $this->client->call(Client::METHOD_DELETE, '/storage/buckets/' . $bucket['body']['$id'], [ diff --git a/tests/e2e/Services/Storage/StorageCustomServerTest.php b/tests/e2e/Services/Storage/StorageCustomServerTest.php index 4d3e2668f2..a779dce169 100644 --- a/tests/e2e/Services/Storage/StorageCustomServerTest.php +++ b/tests/e2e/Services/Storage/StorageCustomServerTest.php @@ -1,5 +1,7 @@

INJECTED

'; - $this->assertStringContainsString('

INJECTED

', $lastEmail['html']); - $this->assertStringContainsString($encoded, $lastEmail['html']); + $this->assertStringContainsString('

INJECTED

', (string) $lastEmail['html']); + $this->assertStringContainsString($encoded, (string) $lastEmail['html']); $response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamUid . '/memberships/'.$response['body']['$id'], array_merge([ 'content-type' => 'application/json', diff --git a/tests/e2e/Services/Teams/TeamsCustomServerTest.php b/tests/e2e/Services/Teams/TeamsCustomServerTest.php index 52f480c524..a9280703bb 100644 --- a/tests/e2e/Services/Teams/TeamsCustomServerTest.php +++ b/tests/e2e/Services/Teams/TeamsCustomServerTest.php @@ -1,5 +1,7 @@ '2022-11-02', ]); $this->assertEquals(400, $token['headers']['status-code']); - $this->assertStringContainsString('Value must be valid date in the future', $token['body']['message']); + $this->assertStringContainsString('Value must be valid date in the future', (string) $token['body']['message']); // Success cases: With & without expiry $expireList = [null, date('Y-m-d', strtotime("tomorrow"))]; @@ -183,7 +185,7 @@ class TokensConsoleClientTest extends Scope 'expire' => '2022-11-02', ]); $this->assertEquals(400, $token['headers']['status-code']); - $this->assertStringContainsString('Value must be valid date in the future', $token['body']['message']); + $this->assertStringContainsString('Value must be valid date in the future', (string) $token['body']['message']); // Finite expiry $expiry = date('Y-m-d', strtotime("tomorrow")); diff --git a/tests/e2e/Services/Tokens/TokensCustomClientTest.php b/tests/e2e/Services/Tokens/TokensCustomClientTest.php index a7a1fa48a5..2a8691ea62 100644 --- a/tests/e2e/Services/Tokens/TokensCustomClientTest.php +++ b/tests/e2e/Services/Tokens/TokensCustomClientTest.php @@ -1,12 +1,14 @@ '2022-11-02', ]); $this->assertEquals(400, $token['headers']['status-code']); - $this->assertStringContainsString('Value must be valid date in the future', $token['body']['message']); + $this->assertStringContainsString('Value must be valid date in the future', (string) $token['body']['message']); // Success case: No expire date $token = $this->client->call(Client::METHOD_POST, '/tokens/buckets/' . $bucketId . '/files/' . $fileId, array_merge([ @@ -151,7 +153,7 @@ class TokensCustomServerTest extends Scope 'expire' => '2022-11-02', ]); $this->assertEquals(400, $token['headers']['status-code']); - $this->assertStringContainsString('Value must be valid date in the future', $token['body']['message']); + $this->assertStringContainsString('Value must be valid date in the future', (string) $token['body']['message']); // Success case: Finite expiry $expiry = date('Y-m-d', strtotime("tomorrow")); diff --git a/tests/e2e/Services/Users/UsersConsoleClientTest.php b/tests/e2e/Services/Users/UsersConsoleClientTest.php index 24e0f6868b..1ac901bf58 100644 --- a/tests/e2e/Services/Users/UsersConsoleClientTest.php +++ b/tests/e2e/Services/Users/UsersConsoleClientTest.php @@ -1,5 +1,7 @@ '32h', ]); - $this->assertEquals($response['headers']['status-code'], 400); + $this->assertEquals(400, $response['headers']['status-code']); /** * Test for SUCCESS @@ -39,7 +41,7 @@ class UsersConsoleClientTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(5, count($response['body'])); + $this->assertCount(5, $response['body']); $this->assertEquals('24h', $response['body']['range']); $this->assertIsNumeric($response['body']['usersTotal']); $this->assertIsNumeric($response['body']['sessionsTotal']); diff --git a/tests/e2e/Services/Users/UsersCustomServerTest.php b/tests/e2e/Services/Users/UsersCustomServerTest.php index 2442f1bf7d..0762bbef5c 100644 --- a/tests/e2e/Services/Users/UsersCustomServerTest.php +++ b/tests/e2e/Services/Users/UsersCustomServerTest.php @@ -1,12 +1,14 @@ assertEquals(200, $runtime['headers']['status-code']); - $this->assertEquals($runtime['body']['runtime'], 'ruby-3.3'); - $this->assertEquals($runtime['body']['commands'], 'bundle install && bundle exec rake build'); - $this->assertEquals($runtime['body']['entrypoint'], 'main.rb'); + $this->assertEquals('ruby-3.3', $runtime['body']['runtime']); + $this->assertEquals('bundle install && bundle exec rake build', $runtime['body']['commands']); + $this->assertEquals('main.rb', $runtime['body']['entrypoint']); /** * Test for FAILURE @@ -179,10 +181,10 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $framework['headers']['status-code']); - $this->assertEquals($framework['body']['framework'], 'sveltekit'); - $this->assertEquals($framework['body']['installCommand'], 'npm install'); - $this->assertEquals($framework['body']['buildCommand'], 'npm run build'); - $this->assertEquals($framework['body']['outputDirectory'], './build'); + $this->assertEquals('sveltekit', $framework['body']['framework']); + $this->assertEquals('npm install', $framework['body']['installCommand']); + $this->assertEquals('npm run build', $framework['body']['buildCommand']); + $this->assertEquals('./build', $framework['body']['outputDirectory']); $framework = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/detections', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -194,10 +196,10 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $framework['headers']['status-code']); - $this->assertEquals($framework['body']['framework'], 'astro'); - $this->assertEquals($framework['body']['installCommand'], 'npm install'); - $this->assertEquals($framework['body']['buildCommand'], 'npm run build'); - $this->assertEquals($framework['body']['outputDirectory'], './dist'); + $this->assertEquals('astro', $framework['body']['framework']); + $this->assertEquals('npm install', $framework['body']['installCommand']); + $this->assertEquals('npm run build', $framework['body']['buildCommand']); + $this->assertEquals('./dist', $framework['body']['outputDirectory']); $framework = $this->client->call(Client::METHOD_POST, '/vcs/github/installations/' . $installationId . '/detections', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -209,10 +211,10 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $framework['headers']['status-code']); - $this->assertEquals($framework['body']['framework'], 'remix'); - $this->assertEquals($framework['body']['installCommand'], 'npm install'); - $this->assertEquals($framework['body']['buildCommand'], 'npm run build'); - $this->assertEquals($framework['body']['outputDirectory'], './build'); + $this->assertEquals('remix', $framework['body']['framework']); + $this->assertEquals('npm install', $framework['body']['installCommand']); + $this->assertEquals('npm run build', $framework['body']['buildCommand']); + $this->assertEquals('./build', $framework['body']['outputDirectory']); /** * Test for FAILURE @@ -315,11 +317,11 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $repositories['headers']['status-code']); - $this->assertEquals($repositories['body']['total'], 4); - $this->assertEquals($repositories['body']['runtimeProviderRepositories'][0]['name'], 'starter-for-svelte'); - $this->assertEquals($repositories['body']['runtimeProviderRepositories'][0]['organization'], 'appwrite-test'); - $this->assertEquals($repositories['body']['runtimeProviderRepositories'][0]['provider'], 'github'); - $this->assertEquals($repositories['body']['runtimeProviderRepositories'][0]['runtime'], 'node-22'); + $this->assertEquals(4, $repositories['body']['total']); + $this->assertEquals('starter-for-svelte', $repositories['body']['runtimeProviderRepositories'][0]['name']); + $this->assertEquals('appwrite-test', $repositories['body']['runtimeProviderRepositories'][0]['organization']); + $this->assertEquals('github', $repositories['body']['runtimeProviderRepositories'][0]['provider']); + $this->assertEquals('node-22', $repositories['body']['runtimeProviderRepositories'][0]['runtime']); $searchedRepositories = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -328,9 +330,9 @@ class VCSConsoleClientTest extends Scope 'type' => 'runtime' ]); $this->assertEquals(200, $searchedRepositories['headers']['status-code']); - $this->assertEquals($searchedRepositories['body']['total'], 1); - $this->assertEquals($searchedRepositories['body']['runtimeProviderRepositories'][0]['name'], 'function1.4'); - $this->assertEquals($searchedRepositories['body']['runtimeProviderRepositories'][0]['runtime'], 'node-2'); + $this->assertEquals(1, $searchedRepositories['body']['total']); + $this->assertEquals('function1.4', $searchedRepositories['body']['runtimeProviderRepositories'][0]['name']); + $this->assertEquals('node-2', $searchedRepositories['body']['runtimeProviderRepositories'][0]['runtime']); $searchedRepositories = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -339,9 +341,9 @@ class VCSConsoleClientTest extends Scope 'type' => 'runtime' ]); $this->assertEquals(200, $searchedRepositories['headers']['status-code']); - $this->assertEquals($searchedRepositories['body']['total'], 1); - $this->assertEquals($searchedRepositories['body']['runtimeProviderRepositories'][0]['name'], 'appwrite'); - $this->assertEquals($searchedRepositories['body']['runtimeProviderRepositories'][0]['runtime'], 'php-8.3'); + $this->assertEquals(1, $searchedRepositories['body']['total']); + $this->assertEquals('appwrite', $searchedRepositories['body']['runtimeProviderRepositories'][0]['name']); + $this->assertEquals('php-8.3', $searchedRepositories['body']['runtimeProviderRepositories'][0]['runtime']); $searchedRepositories = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -350,9 +352,9 @@ class VCSConsoleClientTest extends Scope 'type' => 'runtime' ]); $this->assertEquals(200, $searchedRepositories['headers']['status-code']); - $this->assertEquals($searchedRepositories['body']['total'], 1); - $this->assertEquals($searchedRepositories['body']['runtimeProviderRepositories'][0]['name'], 'ruby-starter'); - $this->assertEquals($searchedRepositories['body']['runtimeProviderRepositories'][0]['runtime'], 'ruby-3.3'); + $this->assertEquals(1, $searchedRepositories['body']['total']); + $this->assertEquals('ruby-starter', $searchedRepositories['body']['runtimeProviderRepositories'][0]['name']); + $this->assertEquals('ruby-3.3', $searchedRepositories['body']['runtimeProviderRepositories'][0]['runtime']); $repositories = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -361,11 +363,11 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $repositories['headers']['status-code']); - $this->assertEquals($repositories['body']['total'], 4); - $this->assertEquals($repositories['body']['frameworkProviderRepositories'][0]['name'], 'starter-for-svelte'); - $this->assertEquals($repositories['body']['frameworkProviderRepositories'][0]['organization'], 'appwrite-test'); - $this->assertEquals($repositories['body']['frameworkProviderRepositories'][0]['provider'], 'github'); - $this->assertEquals($repositories['body']['frameworkProviderRepositories'][0]['framework'], 'sveltekit'); + $this->assertEquals(4, $repositories['body']['total']); + $this->assertEquals('starter-for-svelte', $repositories['body']['frameworkProviderRepositories'][0]['name']); + $this->assertEquals('appwrite-test', $repositories['body']['frameworkProviderRepositories'][0]['organization']); + $this->assertEquals('github', $repositories['body']['frameworkProviderRepositories'][0]['provider']); + $this->assertEquals('sveltekit', $repositories['body']['frameworkProviderRepositories'][0]['framework']); $searchedRepositories = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -374,9 +376,9 @@ class VCSConsoleClientTest extends Scope 'type' => 'runtime' ]); $this->assertEquals(200, $searchedRepositories['headers']['status-code']); - $this->assertEquals($searchedRepositories['body']['total'], 1); - $this->assertEquals($searchedRepositories['body']['runtimeProviderRepositories'][0]['name'], 'appwrite'); - $this->assertEquals($searchedRepositories['body']['runtimeProviderRepositories'][0]['runtime'], 'other'); + $this->assertEquals(1, $searchedRepositories['body']['total']); + $this->assertEquals('appwrite', $searchedRepositories['body']['runtimeProviderRepositories'][0]['name']); + $this->assertEquals('other', $searchedRepositories['body']['runtimeProviderRepositories'][0]['runtime']); // with limit and offset $repositories = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories', array_merge([ @@ -456,7 +458,7 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $repositories['headers']['status-code']); - $this->assertEquals($repositories['body']['total'], 0); + $this->assertEquals(0, $repositories['body']['total']); } public function testGetRepository(): void @@ -472,18 +474,18 @@ class VCSConsoleClientTest extends Scope ], $this->getHeaders())); $this->assertEquals(200, $repository['headers']['status-code']); - $this->assertEquals($repository['body']['name'], 'ruby-starter'); - $this->assertEquals($repository['body']['organization'], 'appwrite-test'); - $this->assertEquals($repository['body']['private'], false); + $this->assertEquals('ruby-starter', $repository['body']['name']); + $this->assertEquals('appwrite-test', $repository['body']['organization']); + $this->assertEquals(false, $repository['body']['private']); $repository = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/' . $this->providerRepositoryId2, array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(200, $repository['headers']['status-code']); - $this->assertEquals($repository['body']['name'], 'function1.4'); - $this->assertEquals($repository['body']['organization'], 'appwrite-test'); - $this->assertEquals($repository['body']['private'], true); + $this->assertEquals('function1.4', $repository['body']['name']); + $this->assertEquals('appwrite-test', $repository['body']['organization']); + $this->assertEquals(true, $repository['body']['private']); /** * Test for FAILURE @@ -509,9 +511,9 @@ class VCSConsoleClientTest extends Scope ], $this->getHeaders())); $this->assertEquals(200, $repositoryBranches['headers']['status-code']); - $this->assertEquals($repositoryBranches['body']['total'], 2); - $this->assertEquals($repositoryBranches['body']['branches'][0]['name'], 'main'); - $this->assertEquals($repositoryBranches['body']['branches'][1]['name'], 'test'); + $this->assertEquals(2, $repositoryBranches['body']['total']); + $this->assertEquals('main', $repositoryBranches['body']['branches'][0]['name']); + $this->assertEquals('test', $repositoryBranches['body']['branches'][1]['name']); $repositoryBranches = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/' . $this->providerRepositoryId . '/branches', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -520,9 +522,9 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $repositoryBranches['headers']['status-code']); - $this->assertEquals($repositoryBranches['body']['total'], 1); + $this->assertEquals(1, $repositoryBranches['body']['total']); $this->assertCount(1, $repositoryBranches['body']['branches']); - $this->assertEquals($repositoryBranches['body']['branches'][0]['name'], 'test'); + $this->assertEquals('test', $repositoryBranches['body']['branches'][0]['name']); $repositoryBranches = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/' . $this->providerRepositoryId . '/branches', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -534,9 +536,9 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $repositoryBranches['headers']['status-code']); - $this->assertEquals($repositoryBranches['body']['total'], 2); + $this->assertEquals(2, $repositoryBranches['body']['total']); $this->assertCount(1, $repositoryBranches['body']['branches']); - $this->assertEquals($repositoryBranches['body']['branches'][0]['name'], 'test'); + $this->assertEquals('test', $repositoryBranches['body']['branches'][0]['name']); $repositoryBranches = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/' . $this->providerRepositoryId . '/branches', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -548,9 +550,9 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $repositoryBranches['headers']['status-code']); - $this->assertEquals($repositoryBranches['body']['total'], 2); + $this->assertEquals(2, $repositoryBranches['body']['total']); $this->assertCount(1, $repositoryBranches['body']['branches']); - $this->assertEquals($repositoryBranches['body']['branches'][0]['name'], 'test'); + $this->assertEquals('test', $repositoryBranches['body']['branches'][0]['name']); $repositoryBranches = $this->client->call(Client::METHOD_GET, '/vcs/github/installations/' . $installationId . '/providerRepositories/' . $this->providerRepositoryId . '/branches', array_merge([ 'x-appwrite-project' => $this->getProject()['$id'], @@ -562,9 +564,9 @@ class VCSConsoleClientTest extends Scope ]); $this->assertEquals(200, $repositoryBranches['headers']['status-code']); - $this->assertEquals($repositoryBranches['body']['total'], 2); + $this->assertEquals(2, $repositoryBranches['body']['total']); $this->assertCount(1, $repositoryBranches['body']['branches']); - $this->assertEquals($repositoryBranches['body']['branches'][0]['name'], 'main'); + $this->assertEquals('main', $repositoryBranches['body']['branches'][0]['name']); /** * Test for FAILURE @@ -696,6 +698,6 @@ class VCSConsoleClientTest extends Scope */ $result = $github->deleteRepository('appwrite-test', 'test-repo-1'); - $this->assertEquals($result, true); + $this->assertTrue($result); } } diff --git a/tests/e2e/Services/VCS/VCSCustomClientTest.php b/tests/e2e/Services/VCS/VCSCustomClientTest.php index 26ccc45990..3cab589b36 100644 --- a/tests/e2e/Services/VCS/VCSCustomClientTest.php +++ b/tests/e2e/Services/VCS/VCSCustomClientTest.php @@ -1,5 +1,7 @@ assertSame([AuthType::ADMIN, AuthType::KEY], $method->getAuth()); } - public static function advisorActionsProvider(): array + public static function advisorActionsProvider(): \Iterator { - return [ - 'get report' => [new GetReport()], - 'list reports' => [new ListReports()], - 'delete report' => [new DeleteReport()], - 'get insight' => [new GetInsight()], - 'list insights' => [new ListInsights()], - ]; + yield 'get report' => [new GetReport()]; + yield 'list reports' => [new ListReports()]; + yield 'delete report' => [new DeleteReport()]; + yield 'get insight' => [new GetInsight()]; + yield 'list insights' => [new ListInsights()]; } } diff --git a/tests/unit/Advisor/Validator/CTAsTest.php b/tests/unit/Advisor/Validator/CTAsTest.php index 5511910072..e0949999d5 100644 --- a/tests/unit/Advisor/Validator/CTAsTest.php +++ b/tests/unit/Advisor/Validator/CTAsTest.php @@ -1,11 +1,13 @@ assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_EPHEMERAL, $decoded->getType()); - $this->assertEquals(User::ROLE_KEYS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_EPHEMERAL, $decoded->getType()); + $this->assertSame(User::ROLE_KEYS, $decoded->getRole()); $this->assertEquals(\array_merge($scopes, $roleScopes), $decoded->getScopes()); - $this->assertEquals('Ephemeral Key', $decoded->getName()); + $this->assertSame('Ephemeral Key', $decoded->getName()); // Decode ephemeral key with extras $extra = [ @@ -57,14 +59,14 @@ class KeyTest extends TestCase user: new Document(), key: $key, ); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_EPHEMERAL, $decoded->getType()); - $this->assertEquals(User::ROLE_KEYS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_EPHEMERAL, $decoded->getType()); + $this->assertSame(User::ROLE_KEYS, $decoded->getRole()); $this->assertEquals(\array_merge($scopes, $roleScopes), $decoded->getScopes()); - $this->assertEquals('Ephemeral Key', $decoded->getName()); - $this->assertEquals(['metric123'], $decoded->getDisabledMetrics()); + $this->assertSame('Ephemeral Key', $decoded->getName()); + $this->assertSame(['metric123'], $decoded->getDisabledMetrics()); $this->assertEquals(true, $decoded->getHostnameOverride()); $this->assertEquals(true, $decoded->isBannerDisabled()); $this->assertEquals(true, $decoded->isProjectCheckDisabled()); @@ -79,13 +81,13 @@ class KeyTest extends TestCase user: new Document(), key: $invalidKey, ); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_EPHEMERAL, $decoded->getType()); - $this->assertEquals(User::ROLE_GUESTS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_EPHEMERAL, $decoded->getType()); + $this->assertSame(User::ROLE_GUESTS, $decoded->getRole()); $this->assertEquals($guestRoleScopes, $decoded->getScopes()); - $this->assertEquals('UNKNOWN', $decoded->getName()); + $this->assertSame('UNKNOWN', $decoded->getName()); // Decode expired ephemeral key $expiredKey = self::generateKey($projectId, $usage, $scopes, maxAge: 1, timestamp: time() - 60); @@ -96,13 +98,13 @@ class KeyTest extends TestCase user: new Document(), key: $expiredKey, ); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_EPHEMERAL, $decoded->getType()); - $this->assertEquals(User::ROLE_GUESTS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_EPHEMERAL, $decoded->getType()); + $this->assertSame(User::ROLE_GUESTS, $decoded->getRole()); $this->assertEquals($guestRoleScopes, $decoded->getScopes()); - $this->assertEquals('UNKNOWN', $decoded->getName()); + $this->assertSame('UNKNOWN', $decoded->getName()); // Decode standard key $scopes = ['custom.write']; @@ -119,13 +121,13 @@ class KeyTest extends TestCase user: new Document(), key: 'standard_abcd1234', ); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_STANDARD, $decoded->getType()); - $this->assertEquals(User::ROLE_KEYS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_STANDARD, $decoded->getType()); + $this->assertSame(User::ROLE_KEYS, $decoded->getRole()); $this->assertEquals(\array_merge($scopes, $roleScopes), $decoded->getScopes()); - $this->assertEquals('Standard key', $decoded->getName()); + $this->assertSame('Standard key', $decoded->getName()); // Decode deprecated standard key $scopes = ['custom.write']; @@ -142,13 +144,13 @@ class KeyTest extends TestCase user: new Document(), key: 'abcd1234', ); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_STANDARD, $decoded->getType()); - $this->assertEquals(User::ROLE_KEYS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_STANDARD, $decoded->getType()); + $this->assertSame(User::ROLE_KEYS, $decoded->getRole()); $this->assertEquals(\array_merge($scopes, $roleScopes), $decoded->getScopes()); - $this->assertEquals('Standard key', $decoded->getName()); + $this->assertSame('Standard key', $decoded->getName()); // Decode invalid standard key $scopes = ['custom.write']; @@ -165,13 +167,13 @@ class KeyTest extends TestCase user: new Document(), key: 'standard_efgh5678', ); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_STANDARD, $decoded->getType()); - $this->assertEquals(User::ROLE_GUESTS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_STANDARD, $decoded->getType()); + $this->assertSame(User::ROLE_GUESTS, $decoded->getRole()); $this->assertEquals($guestRoleScopes, $decoded->getScopes()); - $this->assertEquals('UNKNOWN', $decoded->getName()); + $this->assertSame('UNKNOWN', $decoded->getName()); // Decode expired standard key $scopes = ['custom.write']; @@ -190,13 +192,13 @@ class KeyTest extends TestCase key: 'standard_abcd1234', ); $this->assertEquals(true, $decoded->isExpired()); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_STANDARD, $decoded->getType()); - $this->assertEquals(User::ROLE_KEYS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_STANDARD, $decoded->getType()); + $this->assertSame(User::ROLE_KEYS, $decoded->getRole()); $this->assertEquals(\array_merge($scopes, $roleScopes), $decoded->getScopes()); - $this->assertEquals('Standard key', $decoded->getName()); + $this->assertSame('Standard key', $decoded->getName()); // Decode account key $userId = 'user123'; @@ -214,13 +216,13 @@ class KeyTest extends TestCase ]]), key: 'account_abcd1234', ); - $this->assertEquals('', $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals($userId, $decoded->getUserId()); - $this->assertEquals(API_KEY_ACCOUNT, $decoded->getType()); - $this->assertEquals(User::ROLE_USERS, $decoded->getRole()); - $this->assertEquals($scopes, $decoded->getScopes()); - $this->assertEquals('Account key', $decoded->getName()); + $this->assertSame('', $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame($userId, $decoded->getUserId()); + $this->assertSame(API_KEY_ACCOUNT, $decoded->getType()); + $this->assertSame(User::ROLE_USERS, $decoded->getRole()); + $this->assertSame($scopes, $decoded->getScopes()); + $this->assertSame('Account key', $decoded->getName()); // Decode invalid account key $scopes = ['teams.write']; @@ -237,13 +239,13 @@ class KeyTest extends TestCase ]]), key: 'account_efgh5678', ); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_ACCOUNT, $decoded->getType()); - $this->assertEquals(User::ROLE_GUESTS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_ACCOUNT, $decoded->getType()); + $this->assertSame(User::ROLE_GUESTS, $decoded->getRole()); $this->assertEquals($guestRoleScopes, $decoded->getScopes()); - $this->assertEquals('UNKNOWN', $decoded->getName()); + $this->assertSame('UNKNOWN', $decoded->getName()); // Decode expired account key $scopes = ['teams.write']; @@ -261,13 +263,13 @@ class KeyTest extends TestCase key: 'account_abcd1234', ); $this->assertEquals(true, $decoded->isExpired()); - $this->assertEquals('', $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals($userId, $decoded->getUserId()); - $this->assertEquals(API_KEY_ACCOUNT, $decoded->getType()); - $this->assertEquals(User::ROLE_USERS, $decoded->getRole()); - $this->assertEquals($scopes, $decoded->getScopes()); - $this->assertEquals('Account key', $decoded->getName()); + $this->assertSame('', $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame($userId, $decoded->getUserId()); + $this->assertSame(API_KEY_ACCOUNT, $decoded->getType()); + $this->assertSame(User::ROLE_USERS, $decoded->getRole()); + $this->assertSame($scopes, $decoded->getScopes()); + $this->assertSame('Account key', $decoded->getName()); // Decode organization key $teamId = 'team123'; @@ -285,13 +287,13 @@ class KeyTest extends TestCase user: new Document(), key: 'organization_abcd1234', ); - $this->assertEquals('', $decoded->getProjectId()); - $this->assertEquals($teamId, $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_ORGANIZATION, $decoded->getType()); - $this->assertEquals(User::ROLE_KEYS, $decoded->getRole()); - $this->assertEquals($scopes, $decoded->getScopes()); - $this->assertEquals('Organization key', $decoded->getName()); + $this->assertSame('', $decoded->getProjectId()); + $this->assertSame($teamId, $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_ORGANIZATION, $decoded->getType()); + $this->assertSame(User::ROLE_KEYS, $decoded->getRole()); + $this->assertSame($scopes, $decoded->getScopes()); + $this->assertSame('Organization key', $decoded->getName()); // Decode invalid organization key $scopes = ['projects.write']; @@ -308,13 +310,13 @@ class KeyTest extends TestCase user: new Document(), key: 'organization_efgh5678', ); - $this->assertEquals($projectId, $decoded->getProjectId()); - $this->assertEquals('', $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_ORGANIZATION, $decoded->getType()); - $this->assertEquals(User::ROLE_GUESTS, $decoded->getRole()); + $this->assertSame($projectId, $decoded->getProjectId()); + $this->assertSame('', $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_ORGANIZATION, $decoded->getType()); + $this->assertSame(User::ROLE_GUESTS, $decoded->getRole()); $this->assertEquals($guestRoleScopes, $decoded->getScopes()); - $this->assertEquals('UNKNOWN', $decoded->getName()); + $this->assertSame('UNKNOWN', $decoded->getName()); // Decode expired organization key $scopes = ['projects.write']; @@ -332,13 +334,13 @@ class KeyTest extends TestCase key: 'organization_abcd1234', ); $this->assertEquals(true, $decoded->isExpired()); - $this->assertEquals('', $decoded->getProjectId()); - $this->assertEquals($teamId, $decoded->getTeamId()); - $this->assertEquals('', $decoded->getUserId()); - $this->assertEquals(API_KEY_ORGANIZATION, $decoded->getType()); - $this->assertEquals(User::ROLE_KEYS, $decoded->getRole()); - $this->assertEquals($scopes, $decoded->getScopes()); - $this->assertEquals('Organization key', $decoded->getName()); + $this->assertSame('', $decoded->getProjectId()); + $this->assertSame($teamId, $decoded->getTeamId()); + $this->assertSame('', $decoded->getUserId()); + $this->assertSame(API_KEY_ORGANIZATION, $decoded->getType()); + $this->assertSame(User::ROLE_KEYS, $decoded->getRole()); + $this->assertSame($scopes, $decoded->getScopes()); + $this->assertSame('Organization key', $decoded->getName()); } private static function generateKey( diff --git a/tests/unit/Auth/Validator/PasswordDictionaryTest.php b/tests/unit/Auth/Validator/PasswordDictionaryTest.php index 60b5ca7ae3..7de5d83496 100644 --- a/tests/unit/Auth/Validator/PasswordDictionaryTest.php +++ b/tests/unit/Auth/Validator/PasswordDictionaryTest.php @@ -1,11 +1,13 @@ assertEquals($this->object->isValid('1'), false); // to check parent is being called - $this->assertEquals($this->object->isValid('123456'), false); - $this->assertEquals($this->object->isValid('password'), false); - $this->assertEquals($this->object->isValid('myPasswordIsRight'), true); + $this->assertFalse($this->object->isValid('1')); // to check parent is being called + $this->assertFalse($this->object->isValid('123456')); + $this->assertFalse($this->object->isValid('password')); + $this->assertTrue($this->object->isValid('myPasswordIsRight')); $pass = ''; // 256 chars for ($i = 0; $i < 256; $i++) { $pass .= 'p'; } - $this->assertEquals($this->object->isValid($pass), true); + $this->assertTrue($this->object->isValid($pass)); $pass .= 'p'; // 257 chars - $this->assertEquals($this->object->isValid($pass), false); + $this->assertFalse($this->object->isValid($pass)); } } diff --git a/tests/unit/Auth/Validator/PasswordStrengthTest.php b/tests/unit/Auth/Validator/PasswordStrengthTest.php index af49acb148..46f75e8145 100644 --- a/tests/unit/Auth/Validator/PasswordStrengthTest.php +++ b/tests/unit/Auth/Validator/PasswordStrengthTest.php @@ -1,11 +1,13 @@ assertEquals($this->object->isValid(false), false); - $this->assertEquals($this->object->isValid(null), false); - $this->assertEquals($this->object->isValid(''), false); - $this->assertEquals($this->object->isValid('1'), false); - $this->assertEquals($this->object->isValid('12'), false); - $this->assertEquals($this->object->isValid('123'), false); - $this->assertEquals($this->object->isValid('1234'), false); - $this->assertEquals($this->object->isValid('12345'), false); - $this->assertEquals($this->object->isValid('123456'), false); - $this->assertEquals($this->object->isValid('1234567'), false); - $this->assertEquals($this->object->isValid('WUnOZcn0piQMN8Mh31xw4KQPF0gcNGVA'), true); + $this->assertFalse($this->object->isValid(false)); + $this->assertFalse($this->object->isValid(null)); + $this->assertFalse($this->object->isValid('')); + $this->assertFalse($this->object->isValid('1')); + $this->assertFalse($this->object->isValid('12')); + $this->assertFalse($this->object->isValid('123')); + $this->assertFalse($this->object->isValid('1234')); + $this->assertFalse($this->object->isValid('12345')); + $this->assertFalse($this->object->isValid('123456')); + $this->assertFalse($this->object->isValid('1234567')); + $this->assertTrue($this->object->isValid('WUnOZcn0piQMN8Mh31xw4KQPF0gcNGVA')); } } diff --git a/tests/unit/Auth/Validator/PersonalDataTest.php b/tests/unit/Auth/Validator/PersonalDataTest.php index 1da5c458c0..7b495dd311 100644 --- a/tests/unit/Auth/Validator/PersonalDataTest.php +++ b/tests/unit/Auth/Validator/PersonalDataTest.php @@ -1,11 +1,13 @@ object = new PersonalData('userId', 'email@example.com', 'name', '+129492323', true); - $this->assertEquals($this->object->isValid('userId'), false); - $this->assertEquals($this->object->isValid('something.userId'), false); - $this->assertEquals($this->object->isValid('userId.something'), false); - $this->assertEquals($this->object->isValid('something.userId.something'), false); + $this->assertFalse($this->object->isValid('userId')); + $this->assertFalse($this->object->isValid('something.userId')); + $this->assertFalse($this->object->isValid('userId.something')); + $this->assertFalse($this->object->isValid('something.userId.something')); - $this->assertEquals($this->object->isValid('email@example.com'), false); - $this->assertEquals($this->object->isValid('something.email@example.com'), false); - $this->assertEquals($this->object->isValid('email@example.com.something'), false); - $this->assertEquals($this->object->isValid('something.email@example.com.something'), false); + $this->assertFalse($this->object->isValid('email@example.com')); + $this->assertFalse($this->object->isValid('something.email@example.com')); + $this->assertFalse($this->object->isValid('email@example.com.something')); + $this->assertFalse($this->object->isValid('something.email@example.com.something')); - $this->assertEquals($this->object->isValid('name'), false); - $this->assertEquals($this->object->isValid('something.name'), false); - $this->assertEquals($this->object->isValid('name.something'), false); - $this->assertEquals($this->object->isValid('something.name.something'), false); + $this->assertFalse($this->object->isValid('name')); + $this->assertFalse($this->object->isValid('something.name')); + $this->assertFalse($this->object->isValid('name.something')); + $this->assertFalse($this->object->isValid('something.name.something')); - $this->assertEquals($this->object->isValid('+129492323'), false); - $this->assertEquals($this->object->isValid('something.+129492323'), false); - $this->assertEquals($this->object->isValid('+129492323.something'), false); - $this->assertEquals($this->object->isValid('something.+129492323.something'), false); + $this->assertFalse($this->object->isValid('+129492323')); + $this->assertFalse($this->object->isValid('something.+129492323')); + $this->assertFalse($this->object->isValid('+129492323.something')); + $this->assertFalse($this->object->isValid('something.+129492323.something')); - $this->assertEquals($this->object->isValid('129492323'), false); - $this->assertEquals($this->object->isValid('something.129492323'), false); - $this->assertEquals($this->object->isValid('129492323.something'), false); - $this->assertEquals($this->object->isValid('something.129492323.something'), false); + $this->assertFalse($this->object->isValid('129492323')); + $this->assertFalse($this->object->isValid('something.129492323')); + $this->assertFalse($this->object->isValid('129492323.something')); + $this->assertFalse($this->object->isValid('something.129492323.something')); - $this->assertEquals($this->object->isValid('email'), false); - $this->assertEquals($this->object->isValid('something.email'), false); - $this->assertEquals($this->object->isValid('email.something'), false); - $this->assertEquals($this->object->isValid('something.email.something'), false); + $this->assertFalse($this->object->isValid('email')); + $this->assertFalse($this->object->isValid('something.email')); + $this->assertFalse($this->object->isValid('email.something')); + $this->assertFalse($this->object->isValid('something.email.something')); /** Test for success */ - $this->assertEquals($this->object->isValid('893pu5egerfsv3rgersvd'), true); + $this->assertTrue($this->object->isValid('893pu5egerfsv3rgersvd')); } public function testNotStrict(): void { $this->object = new PersonalData('userId', 'email@example.com', 'name', '+129492323', false); - $this->assertEquals($this->object->isValid('userId'), false); - $this->assertEquals($this->object->isValid('USERID'), false); - $this->assertEquals($this->object->isValid('something.USERID'), false); - $this->assertEquals($this->object->isValid('USERID.something'), false); - $this->assertEquals($this->object->isValid('something.USERID.something'), false); + $this->assertFalse($this->object->isValid('userId')); + $this->assertFalse($this->object->isValid('USERID')); + $this->assertFalse($this->object->isValid('something.USERID')); + $this->assertFalse($this->object->isValid('USERID.something')); + $this->assertFalse($this->object->isValid('something.USERID.something')); - $this->assertEquals($this->object->isValid('email@example.com'), false); - $this->assertEquals($this->object->isValid('EMAIL@EXAMPLE.COM'), false); - $this->assertEquals($this->object->isValid('something.EMAIL@EXAMPLE.COM'), false); - $this->assertEquals($this->object->isValid('EMAIL@EXAMPLE.COM.something'), false); - $this->assertEquals($this->object->isValid('something.EMAIL@EXAMPLE.COM.something'), false); + $this->assertFalse($this->object->isValid('email@example.com')); + $this->assertFalse($this->object->isValid('EMAIL@EXAMPLE.COM')); + $this->assertFalse($this->object->isValid('something.EMAIL@EXAMPLE.COM')); + $this->assertFalse($this->object->isValid('EMAIL@EXAMPLE.COM.something')); + $this->assertFalse($this->object->isValid('something.EMAIL@EXAMPLE.COM.something')); - $this->assertEquals($this->object->isValid('name'), false); - $this->assertEquals($this->object->isValid('NAME'), false); - $this->assertEquals($this->object->isValid('something.NAME'), false); - $this->assertEquals($this->object->isValid('NAME.something'), false); - $this->assertEquals($this->object->isValid('something.NAME.something'), false); + $this->assertFalse($this->object->isValid('name')); + $this->assertFalse($this->object->isValid('NAME')); + $this->assertFalse($this->object->isValid('something.NAME')); + $this->assertFalse($this->object->isValid('NAME.something')); + $this->assertFalse($this->object->isValid('something.NAME.something')); - $this->assertEquals($this->object->isValid('+129492323'), false); - $this->assertEquals($this->object->isValid('129492323'), false); + $this->assertFalse($this->object->isValid('+129492323')); + $this->assertFalse($this->object->isValid('129492323')); - $this->assertEquals($this->object->isValid('email'), false); - $this->assertEquals($this->object->isValid('EMAIL'), false); - $this->assertEquals($this->object->isValid('something.EMAIL'), false); - $this->assertEquals($this->object->isValid('EMAIL.something'), false); - $this->assertEquals($this->object->isValid('something.EMAIL.something'), false); + $this->assertFalse($this->object->isValid('email')); + $this->assertFalse($this->object->isValid('EMAIL')); + $this->assertFalse($this->object->isValid('something.EMAIL')); + $this->assertFalse($this->object->isValid('EMAIL.something')); + $this->assertFalse($this->object->isValid('something.EMAIL.something')); } } diff --git a/tests/unit/Auth/Validator/PhoneTest.php b/tests/unit/Auth/Validator/PhoneTest.php index b7730641c3..4392d960e6 100644 --- a/tests/unit/Auth/Validator/PhoneTest.php +++ b/tests/unit/Auth/Validator/PhoneTest.php @@ -1,11 +1,13 @@ assertEquals($this->object->isValid(false), false); - $this->assertEquals($this->object->isValid(null), false); - $this->assertEquals($this->object->isValid(''), false); - $this->assertEquals($this->object->isValid('+1'), false); - $this->assertEquals($this->object->isValid('+14'), false); - $this->assertEquals($this->object->isValid('+141'), false); - $this->assertEquals($this->object->isValid('+1415'), false); - $this->assertEquals($this->object->isValid('+14155'), false); - $this->assertEquals($this->object->isValid('+141555'), false); - $this->assertEquals($this->object->isValid('8989829304'), false); - $this->assertEquals($this->object->isValid('786-307-3615'), false); - $this->assertEquals($this->object->isValid('+16308A520397'), false); - $this->assertEquals($this->object->isValid('+0415553452342'), false); - $this->assertEquals($this->object->isValid('+14 155 5524564'), false); - $this->assertEquals($this->object->isValid('+1415555245634543'), false); - $this->assertEquals($this->object->isValid('+8020000000'), false); // when country code is not present - $this->assertEquals($this->object->isValid(+14155552456), false); + $this->assertFalse($this->object->isValid(false)); + $this->assertFalse($this->object->isValid(null)); + $this->assertFalse($this->object->isValid('')); + $this->assertFalse($this->object->isValid('+1')); + $this->assertFalse($this->object->isValid('+14')); + $this->assertFalse($this->object->isValid('+141')); + $this->assertFalse($this->object->isValid('+1415')); + $this->assertFalse($this->object->isValid('+14155')); + $this->assertFalse($this->object->isValid('+141555')); + $this->assertFalse($this->object->isValid('8989829304')); + $this->assertFalse($this->object->isValid('786-307-3615')); + $this->assertFalse($this->object->isValid('+16308A520397')); + $this->assertFalse($this->object->isValid('+0415553452342')); + $this->assertFalse($this->object->isValid('+14 155 5524564')); + $this->assertFalse($this->object->isValid('+1415555245634543')); + $this->assertFalse($this->object->isValid('+8020000000')); // when country code is not present + $this->assertFalse($this->object->isValid(+14155552456)); - $this->assertEquals($this->object->isValid('+1415555'), true); - $this->assertEquals($this->object->isValid('+14155552'), true); - $this->assertEquals($this->object->isValid('+141555526'), true); - $this->assertEquals($this->object->isValid('+16308520394'), true); - $this->assertEquals($this->object->isValid('+163085205339'), true); - $this->assertEquals($this->object->isValid('+5511552563253'), true); - $this->assertEquals($this->object->isValid('+55115525632534'), true); - $this->assertEquals($this->object->isValid('+919367788755111'), true); + $this->assertTrue($this->object->isValid('+1415555')); + $this->assertTrue($this->object->isValid('+14155552')); + $this->assertTrue($this->object->isValid('+141555526')); + $this->assertTrue($this->object->isValid('+16308520394')); + $this->assertTrue($this->object->isValid('+163085205339')); + $this->assertTrue($this->object->isValid('+5511552563253')); + $this->assertTrue($this->object->isValid('+55115525632534')); + $this->assertTrue($this->object->isValid('+919367788755111')); } } diff --git a/tests/unit/Detector/DetectorTest.php b/tests/unit/Detector/DetectorTest.php index 12a803de8c..7d7383ba5a 100644 --- a/tests/unit/Detector/DetectorTest.php +++ b/tests/unit/Detector/DetectorTest.php @@ -1,11 +1,13 @@ assertCount(16, $this->object->getServices()); - $this->assertEquals('appwrite', $this->object->getService('appwrite')->getContainerName()); - $this->assertEquals('', $this->object->getService('appwrite')->getImageVersion()); + $this->assertSame('appwrite', $this->object->getService('appwrite')->getContainerName()); + $this->assertSame('', $this->object->getService('appwrite')->getImageVersion()); $this->assertEquals('3.6', $this->object->getService('traefik')->getImageVersion()); - $this->assertEquals(['2080' => '80', '2443' => '443', '8080' => '8080'], $this->object->getService('traefik')->getPorts()); + $this->assertSame(['2080' => '80', '2443' => '443', '8080' => '8080'], $this->object->getService('traefik')->getPorts()); } public function testNetworks(): void diff --git a/tests/unit/Docker/EnvTest.php b/tests/unit/Docker/EnvTest.php index e6c9b8cadf..4f11d31947 100644 --- a/tests/unit/Docker/EnvTest.php +++ b/tests/unit/Docker/EnvTest.php @@ -1,12 +1,14 @@ object->setVar('_APP_TEST', 'value4'); - $this->assertEquals('value1', $this->object->getVar('_APP_X')); - $this->assertEquals('value2', $this->object->getVar('_APP_Y')); - $this->assertEquals('value3', $this->object->getVar('_APP_Z')); - $this->assertEquals('value5=', $this->object->getVar('_APP_W')); - $this->assertEquals('value4', $this->object->getVar('_APP_TEST')); + $this->assertSame('value1', $this->object->getVar('_APP_X')); + $this->assertSame('value2', $this->object->getVar('_APP_Y')); + $this->assertSame('value3', $this->object->getVar('_APP_Z')); + $this->assertSame('value5=', $this->object->getVar('_APP_W')); + $this->assertSame('value4', $this->object->getVar('_APP_TEST')); } public function testExport(): void { - $this->assertEquals("_APP_X=value1 + $this->assertSame("_APP_X=value1 _APP_Y=value2 _APP_Z=value3 _APP_W=value5= diff --git a/tests/unit/Event/EventTest.php b/tests/unit/Event/EventTest.php index 471dd5ad08..6f15c80b9a 100644 --- a/tests/unit/Event/EventTest.php +++ b/tests/unit/Event/EventTest.php @@ -1,5 +1,7 @@ assertEquals($this->queue, $this->object->getQueue()); + $this->assertSame($this->queue, $this->object->getQueue()); $this->object->setQueue('demo'); - $this->assertEquals('demo', $this->object->getQueue()); + $this->assertSame('demo', $this->object->getQueue()); $this->object->setQueue($this->queue); } public function testClass(): void { - $this->assertEquals('TestsV1', $this->object->getClass()); + $this->assertSame('TestsV1', $this->object->getClass()); $this->object->setClass('TestsV2'); - $this->assertEquals('TestsV2', $this->object->getClass()); + $this->assertSame('TestsV2', $this->object->getClass()); $this->object->setClass('TestsV1'); } diff --git a/tests/unit/Event/Validator/EventValidatorTest.php b/tests/unit/Event/Validator/EventValidatorTest.php index 6885d20bfb..32f4ab22a7 100644 --- a/tests/unit/Event/Validator/EventValidatorTest.php +++ b/tests/unit/Event/Validator/EventValidatorTest.php @@ -1,11 +1,13 @@ 'proj456', 'sitesDomain' => 'appwrite.network' ]); - $this->assertStringNotContainsString('/', $domain); + $this->assertStringNotContainsString('/', (string) $domain); $this->assertStringStartsWith('branch-feature-test-', $domain); $this->assertStringEndsWith('.appwrite.network', $domain); diff --git a/tests/unit/Functions/Validator/HeadersTest.php b/tests/unit/Functions/Validator/HeadersTest.php index 563131d480..9cc48c9bb3 100644 --- a/tests/unit/Functions/Validator/HeadersTest.php +++ b/tests/unit/Functions/Validator/HeadersTest.php @@ -1,11 +1,13 @@ 'headerValue', ]; - $this->assertEquals($this->object->isValid($headers), true); + $this->assertTrue($this->object->isValid($headers)); $headers = [ 'headerKey' => 'headerValue', 'x-appwrite-key' => 'headerValue', ]; - $this->assertEquals($this->object->isValid($headers), false); + $this->assertFalse($this->object->isValid($headers)); $headers = [ 'headerKey' => 'headerValue', 'headerKey2' => 'headerValue2', ]; - $this->assertEquals($this->object->isValid($headers), true); + $this->assertTrue($this->object->isValid($headers)); $headers = [ 'headerKey' => 'headerValue', 'x-appwrite-project' => 'headerValue', 'headerKey2' => 'headerValue2', ]; - $this->assertEquals($this->object->isValid($headers), false); + $this->assertFalse($this->object->isValid($headers)); $headers = [ 'header/////Key' => 'headerValue', ]; - $this->assertEquals($this->object->isValid($headers), false); + $this->assertFalse($this->object->isValid($headers)); $headers = [ 'Content-Type' => 'application/json', 'X-Custom-Header' => 'value' ]; - $this->assertEquals($this->object->isValid($headers), true); + $this->assertTrue($this->object->isValid($headers)); $headers = [ 'X-Custom-Header_With-Hyphens_and_Underscores' => 'value' diff --git a/tests/unit/General/CollectionsTest.php b/tests/unit/General/CollectionsTest.php index 73a9ccd0c2..d90905abda 100644 --- a/tests/unit/General/CollectionsTest.php +++ b/tests/unit/General/CollectionsTest.php @@ -1,10 +1,12 @@ assertEquals(1, $occurrences); + $this->assertSame(1, $occurrences); } } } diff --git a/tests/unit/General/ExtensionsTest.php b/tests/unit/General/ExtensionsTest.php index f415816e56..e78e13a169 100644 --- a/tests/unit/General/ExtensionsTest.php +++ b/tests/unit/General/ExtensionsTest.php @@ -1,10 +1,12 @@ response->getModel(Response::MODEL_TABLE); $type = Mapper::model(\ucfirst($model->getType())); $this->assertInstanceOf(NamedType::class, $type); - $this->assertEquals('Table', $type->name()); + $this->assertSame('Table', $type->name()); } } diff --git a/tests/unit/Messaging/MessagingChannelsTest.php b/tests/unit/Messaging/MessagingChannelsTest.php index af6592ef92..c2769226e2 100644 --- a/tests/unit/Messaging/MessagingChannelsTest.php +++ b/tests/unit/Messaging/MessagingChannelsTest.php @@ -1,5 +1,7 @@ assertStringEndsWith($index, $receiverId); + $this->assertStringEndsWith((string) $index, (string) $receiverId); } } } @@ -238,7 +240,7 @@ class MessagingChannelsTest extends TestCase /** * Making sure the right clients receive the event. */ - $this->assertStringEndsWith($index, $receiverId); + $this->assertStringEndsWith((string) $index, (string) $receiverId); } } } @@ -272,7 +274,7 @@ class MessagingChannelsTest extends TestCase /** * Making sure the right clients receive the event. */ - $this->assertStringEndsWith($index, $receiver); + $this->assertStringEndsWith((string) $index, (string) $receiver); } } } @@ -307,7 +309,7 @@ class MessagingChannelsTest extends TestCase /** * Making sure the right clients receive the event. */ - $this->assertStringEndsWith($index, $receiver); + $this->assertStringEndsWith((string) $index, (string) $receiver); } $role = empty($index % 2) @@ -340,7 +342,7 @@ class MessagingChannelsTest extends TestCase /** * Making sure the right clients receive the event. */ - $this->assertStringEndsWith($index, $receiver); + $this->assertStringEndsWith((string) $index, (string) $receiver); } } } diff --git a/tests/unit/Messaging/MessagingFanoutTest.php b/tests/unit/Messaging/MessagingFanoutTest.php index 02b1ee55d4..78172a5a0e 100644 --- a/tests/unit/Messaging/MessagingFanoutTest.php +++ b/tests/unit/Messaging/MessagingFanoutTest.php @@ -1,5 +1,7 @@ getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::guests()->toString()]; $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::users()->toString()]; @@ -111,7 +113,7 @@ class MessagingGuestTest extends TestCase $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['project'] = '2'; diff --git a/tests/unit/Messaging/MessagingTest.php b/tests/unit/Messaging/MessagingTest.php index 12c99a83ef..f9075adea2 100644 --- a/tests/unit/Messaging/MessagingTest.php +++ b/tests/unit/Messaging/MessagingTest.php @@ -1,5 +1,7 @@ getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::users()->toString()]; $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::user(ID::custom('123'))->toString()]; $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::team(ID::custom('abc'))->toString()]; $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::team(ID::custom('abc'), 'administrator')->toString()]; $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::team(ID::custom('abc'), 'moderator')->toString()]; $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::team(ID::custom('def'))->toString()]; $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::team(ID::custom('def'), 'guest')->toString()]; $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['roles'] = [Role::user(ID::custom('456'))->toString()]; @@ -128,7 +130,7 @@ class MessagingTest extends TestCase $receivers = array_keys($realtime->getSubscribers($event)); $this->assertCount(1, $receivers); - $this->assertEquals(1, $receivers[0]); + $this->assertSame(1, $receivers[0]); $event['project'] = '2'; @@ -217,7 +219,7 @@ class MessagingTest extends TestCase ], ]; $receivers = array_keys($realtime->getSubscribers($event)); - $this->assertEquals([1], $receivers); + $this->assertSame([1], $receivers); // Channels recomputed: sub-a's channel is gone $this->assertSame(['files'], $realtime->connections[1]['channels']); @@ -250,7 +252,7 @@ class MessagingTest extends TestCase 'channels' => ['documents'], ], ]; - $this->assertEquals([1], array_keys($realtime->getSubscribers($event))); + $this->assertSame([1], array_keys($realtime->getSubscribers($event))); } public function testUnsubscribeSubscriptionKeepsConnectionWhenLastSubRemoved(): void @@ -301,7 +303,7 @@ class MessagingTest extends TestCase 'channels' => ['files'], ], ]; - $this->assertEquals([1], array_keys($realtime->getSubscribers($event))); + $this->assertSame([1], array_keys($realtime->getSubscribers($event))); } public function testSubscribeAfterOnOpenEmptySentinelPreservesUnion(): void diff --git a/tests/unit/Migration/MigrationVersionsTest.php b/tests/unit/Migration/MigrationVersionsTest.php index 3c8bae7222..a97a582bd9 100644 --- a/tests/unit/Migration/MigrationVersionsTest.php +++ b/tests/unit/Migration/MigrationVersionsTest.php @@ -1,11 +1,13 @@ ['http://127.0.0.1/iam', 'private or reserved'], - 'loopback v6' => ['http://[::1]/iam', 'private or reserved'], - 'link-local imds' => ['http://169.254.169.254/latest/', 'private or reserved'], - 'private rfc1918 a' => ['http://10.0.0.5/secret', 'private or reserved'], - 'private rfc1918 b' => ['http://192.168.1.1/admin', 'private or reserved'], - 'private rfc1918 c' => ['http://172.16.0.1/x', 'private or reserved'], - 'cgnat' => ['http://100.64.0.1/x', 'private or reserved'], - 'ipv4-mapped loopback' => ['http://[::ffff:127.0.0.1]/x', 'private or reserved'], - '6to4 imds' => ['http://[2002:a9fe:a9fe::]/x', 'private or reserved'], - 'file scheme' => ['file:///etc/passwd', "Scheme 'file' is not allowed"], - 'gopher scheme' => ['gopher://attacker/x', "Scheme 'gopher' is not allowed"], - 'ftp scheme' => ['ftp://internal/file', "Scheme 'ftp' is not allowed"], - 'no scheme' => ['example.com/path', "Scheme '' is not allowed"], - 'malformed no host' => ['http:///path', 'Malformed URL'], - 'unknown psl' => ['http://not-a-real-tld.notreal/x', 'not a known public domain'], - ]; + yield 'loopback v4' => ['http://127.0.0.1/iam', 'private or reserved']; + yield 'loopback v6' => ['http://[::1]/iam', 'private or reserved']; + yield 'link-local imds' => ['http://169.254.169.254/latest/', 'private or reserved']; + yield 'private rfc1918 a' => ['http://10.0.0.5/secret', 'private or reserved']; + yield 'private rfc1918 b' => ['http://192.168.1.1/admin', 'private or reserved']; + yield 'private rfc1918 c' => ['http://172.16.0.1/x', 'private or reserved']; + yield 'cgnat' => ['http://100.64.0.1/x', 'private or reserved']; + yield 'ipv4-mapped loopback' => ['http://[::ffff:127.0.0.1]/x', 'private or reserved']; + yield '6to4 imds' => ['http://[2002:a9fe:a9fe::]/x', 'private or reserved']; + yield 'file scheme' => ['file:///etc/passwd', "Scheme 'file' is not allowed"]; + yield 'gopher scheme' => ['gopher://attacker/x', "Scheme 'gopher' is not allowed"]; + yield 'ftp scheme' => ['ftp://internal/file', "Scheme 'ftp' is not allowed"]; + yield 'no scheme' => ['example.com/path', "Scheme '' is not allowed"]; + yield 'malformed no host' => ['http:///path', 'Malformed URL']; + yield 'unknown psl' => ['http://not-a-real-tld.notreal/x', 'not a known public domain']; } public function testFetchFollowsPublicRedirect(): void diff --git a/tests/unit/Network/Validators/DNSTest.php b/tests/unit/Network/Validators/DNSTest.php index 845d01e723..45e11d7029 100644 --- a/tests/unit/Network/Validators/DNSTest.php +++ b/tests/unit/Network/Validators/DNSTest.php @@ -1,12 +1,14 @@ assertEquals(false, $validator->isValid('')); $this->assertEquals(false, $validator->isValid(null)); - $this->assertEquals('string', $validator->getType()); + $this->assertSame('string', $validator->getType()); } public function testMultipleDNSServers(): void @@ -23,7 +25,7 @@ class DNSTest extends TestCase $this->assertEquals(false, $validator->isValid('')); $this->assertEquals(false, $validator->isValid(null)); - $this->assertEquals('string', $validator->getType()); + $this->assertSame('string', $validator->getType()); } public function testValidationFailure(): void diff --git a/tests/unit/Network/Validators/OriginTest.php b/tests/unit/Network/Validators/OriginTest.php index 64ce71951b..6c5d7a878c 100644 --- a/tests/unit/Network/Validators/OriginTest.php +++ b/tests/unit/Network/Validators/OriginTest.php @@ -1,11 +1,13 @@ assertEquals(false, $validator->isValid('appwrite-callback-456://')); $this->assertEquals(false, $validator->isValid('appwrite-ios://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new iOS platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new iOS platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('appwrite-android://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Android platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new Android platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('appwrite-macos://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new macOS platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new macOS platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('appwrite-linux://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Linux platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new Linux platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('appwrite-windows://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Windows platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new Windows platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('chrome-extension://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Web (Chrome Extension) platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new Web (Chrome Extension) platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('moz-extension://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Web (Firefox Extension) platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new Web (Firefox Extension) platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('safari-web-extension://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Web (Safari Extension) platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new Web (Safari Extension) platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('ms-browser-extension://com.company.appname')); - $this->assertEquals('Invalid Origin. Register your new client (com.company.appname) as a new Web (Edge Extension) platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (com.company.appname) as a new Web (Edge Extension) platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(true, $validator->isValid('tauri://localhost')); $this->assertEquals(false, $validator->isValid('tauri://example.com')); - $this->assertEquals('Invalid Origin. Register your new client (example.com) as a new Web (Tauri) platform on your project console dashboard', $validator->getDescription()); + $this->assertSame('Invalid Origin. Register your new client (example.com) as a new Web (Tauri) platform on your project console dashboard', $validator->getDescription()); $this->assertEquals(false, $validator->isValid('random-scheme://localhost')); - $this->assertEquals('Invalid Scheme. The scheme used (random-scheme) in the Origin (random-scheme://localhost) is not supported. If you are using a custom scheme, please change it to `appwrite-callback-`', $validator->getDescription()); + $this->assertSame('Invalid Scheme. The scheme used (random-scheme) in the Origin (random-scheme://localhost) is not supported. If you are using a custom scheme, please change it to `appwrite-callback-`', $validator->getDescription()); } public function testGetAllowedHostnames(): void @@ -88,7 +90,7 @@ class OriginTest extends TestCase allowedSchemes: ['exp'] ); - $this->assertEquals(['appwrite.io', 'localhost'], $validator->getAllowedHostnames()); + $this->assertSame(['appwrite.io', 'localhost'], $validator->getAllowedHostnames()); } public function testGetAllowedSchemes(): void @@ -98,7 +100,7 @@ class OriginTest extends TestCase allowedSchemes: ['exp', 'appwrite-callback-123'] ); - $this->assertEquals(['exp', 'appwrite-callback-123'], $validator->getAllowedSchemes()); + $this->assertSame(['exp', 'appwrite-callback-123'], $validator->getAllowedSchemes()); } public function testSetAllowedHostnames(): void @@ -114,7 +116,7 @@ class OriginTest extends TestCase $result = $validator->setAllowedHostnames(['example.com']); $this->assertSame($validator, $result); - $this->assertEquals(['example.com'], $validator->getAllowedHostnames()); + $this->assertSame(['example.com'], $validator->getAllowedHostnames()); $this->assertEquals(true, $validator->isValid('https://example.com')); $this->assertEquals(false, $validator->isValid('https://appwrite.io')); } @@ -132,7 +134,7 @@ class OriginTest extends TestCase $result = $validator->setAllowedSchemes(['appwrite-callback-456']); $this->assertSame($validator, $result); - $this->assertEquals(['appwrite-callback-456'], $validator->getAllowedSchemes()); + $this->assertSame(['appwrite-callback-456'], $validator->getAllowedSchemes()); $this->assertEquals(true, $validator->isValid('appwrite-callback-456://')); $this->assertEquals(false, $validator->isValid('exp://')); } diff --git a/tests/unit/Network/Validators/PublicHostnameTest.php b/tests/unit/Network/Validators/PublicHostnameTest.php index 81c5708769..f5ca1c966d 100644 --- a/tests/unit/Network/Validators/PublicHostnameTest.php +++ b/tests/unit/Network/Validators/PublicHostnameTest.php @@ -1,12 +1,14 @@ assertFalse(PublicHostname::isPublicIp($ip)); } - public static function privateIpv4Addresses(): array + public static function privateIpv4Addresses(): \Iterator { - return [ - 'unspecified' => ['0.0.0.0'], - 'private 10/8' => ['10.0.0.1'], - 'private 172.16/12' => ['172.16.5.10'], - 'private 192.168/16' => ['192.168.1.1'], - 'cgnat' => ['100.64.0.1'], - 'loopback' => ['127.0.0.1'], - 'link-local imds' => ['169.254.169.254'], - 'gcp metadata' => ['169.254.169.254'], - 'multicast' => ['224.0.0.1'], - 'reserved 240/4' => ['240.0.0.1'], - 'broadcast' => ['255.255.255.255'], - 'test-net-1' => ['192.0.2.1'], - 'test-net-2' => ['198.51.100.1'], - 'test-net-3' => ['203.0.113.1'], - 'benchmark' => ['198.18.0.1'], - ]; + yield 'unspecified' => ['0.0.0.0']; + yield 'private 10/8' => ['10.0.0.1']; + yield 'private 172.16/12' => ['172.16.5.10']; + yield 'private 192.168/16' => ['192.168.1.1']; + yield 'cgnat' => ['100.64.0.1']; + yield 'loopback' => ['127.0.0.1']; + yield 'link-local imds' => ['169.254.169.254']; + yield 'gcp metadata' => ['169.254.169.254']; + yield 'multicast' => ['224.0.0.1']; + yield 'reserved 240/4' => ['240.0.0.1']; + yield 'broadcast' => ['255.255.255.255']; + yield 'test-net-1' => ['192.0.2.1']; + yield 'test-net-2' => ['198.51.100.1']; + yield 'test-net-3' => ['203.0.113.1']; + yield 'benchmark' => ['198.18.0.1']; } #[DataProvider('privateIpv6Addresses')] @@ -63,23 +63,21 @@ class PublicHostnameTest extends TestCase $this->assertFalse(PublicHostname::isPublicIp($ip)); } - public static function privateIpv6Addresses(): array + public static function privateIpv6Addresses(): \Iterator { - return [ - 'loopback' => ['::1'], - 'unspecified' => ['::'], - 'link-local' => ['fe80::1'], - 'unique-local' => ['fc00::1'], - 'unique-local fd' => ['fd12:3456:789a::1'], - 'multicast' => ['ff02::1'], - 'ipv4-mapped loopback' => ['::ffff:127.0.0.1'], - 'ipv4-mapped private' => ['::ffff:10.0.0.1'], - 'ipv4-mapped imds' => ['::ffff:169.254.169.254'], - '6to4 loopback' => ['2002:7f00:1::'], - '6to4 imds' => ['2002:a9fe:a9fe::'], - 'teredo' => ['2001:0:1::1'], - 'documentation' => ['2001:db8::1'], - ]; + yield 'loopback' => ['::1']; + yield 'unspecified' => ['::']; + yield 'link-local' => ['fe80::1']; + yield 'unique-local' => ['fc00::1']; + yield 'unique-local fd' => ['fd12:3456:789a::1']; + yield 'multicast' => ['ff02::1']; + yield 'ipv4-mapped loopback' => ['::ffff:127.0.0.1']; + yield 'ipv4-mapped private' => ['::ffff:10.0.0.1']; + yield 'ipv4-mapped imds' => ['::ffff:169.254.169.254']; + yield '6to4 loopback' => ['2002:7f00:1::']; + yield '6to4 imds' => ['2002:a9fe:a9fe::']; + yield 'teredo' => ['2001:0:1::1']; + yield 'documentation' => ['2001:db8::1']; } #[DataProvider('publicIpAddresses')] @@ -94,14 +92,12 @@ class PublicHostnameTest extends TestCase $this->assertTrue(PublicHostname::isPublicIp($ip)); } - public static function publicIpAddresses(): array + public static function publicIpAddresses(): \Iterator { - return [ - 'google dns' => ['8.8.8.8'], - 'cloudflare' => ['1.1.1.1'], - 'opendns' => ['208.67.222.222'], - 'public ipv6' => ['2606:4700:4700::1111'], - ]; + yield 'google dns' => ['8.8.8.8']; + yield 'cloudflare' => ['1.1.1.1']; + yield 'opendns' => ['208.67.222.222']; + yield 'public ipv6' => ['2606:4700:4700::1111']; } public function testRejectsMalformedInput(): void diff --git a/tests/unit/OpenSSL/OpenSSLTest.php b/tests/unit/OpenSSL/OpenSSLTest.php index 82386aaae0..d6a5b521d3 100644 --- a/tests/unit/OpenSSL/OpenSSLTest.php +++ b/tests/unit/OpenSSL/OpenSSLTest.php @@ -1,11 +1,13 @@ getAction('installerView'); - $this->assertEquals('installerView', View::getName()); - $this->assertEquals(Action::HTTP_REQUEST_METHOD_GET, $action->getHttpMethod()); - $this->assertEquals('/', $action->getHttpPath()); - $this->assertEquals(Action::TYPE_DEFAULT, $action->getType()); + $this->assertSame('installerView', View::getName()); + $this->assertSame(Action::HTTP_REQUEST_METHOD_GET, $action->getHttpMethod()); + $this->assertSame('/', $action->getHttpPath()); + $this->assertSame(Action::TYPE_DEFAULT, $action->getType()); $this->assertActionParams($action, ['step', 'partial']); $this->assertActionInjects($action, ['request', 'response', 'installerConfig', 'installerPaths']); } @@ -69,10 +71,10 @@ class ModuleTest extends TestCase { $action = $this->getAction('installerStatus'); - $this->assertEquals('installerStatus', Status::getName()); - $this->assertEquals(Action::HTTP_REQUEST_METHOD_GET, $action->getHttpMethod()); - $this->assertEquals('/install/status', $action->getHttpPath()); - $this->assertEquals(Action::TYPE_DEFAULT, $action->getType()); + $this->assertSame('installerStatus', Status::getName()); + $this->assertSame(Action::HTTP_REQUEST_METHOD_GET, $action->getHttpMethod()); + $this->assertSame('/install/status', $action->getHttpPath()); + $this->assertSame(Action::TYPE_DEFAULT, $action->getType()); $this->assertActionParams($action, ['installId']); $this->assertActionInjects($action, ['response', 'installerState']); } @@ -81,10 +83,10 @@ class ModuleTest extends TestCase { $action = $this->getAction('installerValidate'); - $this->assertEquals('installerValidate', Validate::getName()); - $this->assertEquals(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); - $this->assertEquals('/install/validate', $action->getHttpPath()); - $this->assertEquals(Action::TYPE_DEFAULT, $action->getType()); + $this->assertSame('installerValidate', Validate::getName()); + $this->assertSame(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); + $this->assertSame('/install/validate', $action->getHttpPath()); + $this->assertSame(Action::TYPE_DEFAULT, $action->getType()); $this->assertActionInjects($action, ['request', 'response']); } @@ -92,10 +94,10 @@ class ModuleTest extends TestCase { $action = $this->getAction('installerComplete'); - $this->assertEquals('installerComplete', Complete::getName()); - $this->assertEquals(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); - $this->assertEquals('/install/complete', $action->getHttpPath()); - $this->assertEquals(Action::TYPE_DEFAULT, $action->getType()); + $this->assertSame('installerComplete', Complete::getName()); + $this->assertSame(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); + $this->assertSame('/install/complete', $action->getHttpPath()); + $this->assertSame(Action::TYPE_DEFAULT, $action->getType()); $this->assertActionParams($action, ['installId', 'sessionId', 'sessionSecret', 'sessionExpire']); $this->assertActionInjects($action, ['request', 'response', 'installerState']); } @@ -104,10 +106,10 @@ class ModuleTest extends TestCase { $action = $this->getAction('installerShutdown'); - $this->assertEquals('installerShutdown', Shutdown::getName()); - $this->assertEquals(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); - $this->assertEquals('/install/shutdown', $action->getHttpPath()); - $this->assertEquals(Action::TYPE_DEFAULT, $action->getType()); + $this->assertSame('installerShutdown', Shutdown::getName()); + $this->assertSame(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); + $this->assertSame('/install/shutdown', $action->getHttpPath()); + $this->assertSame(Action::TYPE_DEFAULT, $action->getType()); $this->assertActionInjects($action, ['request', 'response', 'swooleServer']); } @@ -115,10 +117,10 @@ class ModuleTest extends TestCase { $action = $this->getAction('installerReset'); - $this->assertEquals('installerReset', Reset::getName()); - $this->assertEquals(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); - $this->assertEquals('/install/reset', $action->getHttpPath()); - $this->assertEquals(Action::TYPE_DEFAULT, $action->getType()); + $this->assertSame('installerReset', Reset::getName()); + $this->assertSame(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); + $this->assertSame('/install/reset', $action->getHttpPath()); + $this->assertSame(Action::TYPE_DEFAULT, $action->getType()); $this->assertActionParams($action, ['installId', 'hard']); $this->assertActionInjects($action, ['request', 'response', 'installerState', 'installerConfig']); } @@ -127,10 +129,10 @@ class ModuleTest extends TestCase { $action = $this->getAction('installerInstall'); - $this->assertEquals('installerInstall', Install::getName()); - $this->assertEquals(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); - $this->assertEquals('/install', $action->getHttpPath()); - $this->assertEquals(Action::TYPE_DEFAULT, $action->getType()); + $this->assertSame('installerInstall', Install::getName()); + $this->assertSame(Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod()); + $this->assertSame('/install', $action->getHttpPath()); + $this->assertSame(Action::TYPE_DEFAULT, $action->getType()); $this->assertActionParams($action, [ 'appDomain', 'httpPort', 'httpsPort', 'emailCertificates', 'opensslKey', 'assistantOpenAIKey', 'accountEmail', 'accountPassword', 'database', @@ -143,8 +145,8 @@ class ModuleTest extends TestCase { $error = new Error(); - $this->assertEquals('installerError', Error::getName()); - $this->assertEquals(Action::TYPE_ERROR, $error->getType()); + $this->assertSame('installerError', Error::getName()); + $this->assertSame(Action::TYPE_ERROR, $error->getType()); $this->assertIsCallable($error->getCallback()); } @@ -216,14 +218,14 @@ class ModuleTest extends TestCase public function testStaticGetNameValues(): void { - $this->assertEquals('installerView', View::getName()); - $this->assertEquals('installerStatus', Status::getName()); - $this->assertEquals('installerValidate', Validate::getName()); - $this->assertEquals('installerComplete', Complete::getName()); - $this->assertEquals('installerShutdown', Shutdown::getName()); - $this->assertEquals('installerReset', Reset::getName()); - $this->assertEquals('installerInstall', Install::getName()); - $this->assertEquals('installerError', Error::getName()); + $this->assertSame('installerView', View::getName()); + $this->assertSame('installerStatus', Status::getName()); + $this->assertSame('installerValidate', Validate::getName()); + $this->assertSame('installerComplete', Complete::getName()); + $this->assertSame('installerShutdown', Shutdown::getName()); + $this->assertSame('installerReset', Reset::getName()); + $this->assertSame('installerInstall', Install::getName()); + $this->assertSame('installerError', Error::getName()); } public function testActionInstanceTypes(): void @@ -246,7 +248,7 @@ class ModuleTest extends TestCase $getActions = ['installerView', 'installerStatus']; foreach ($getActions as $name) { $action = $this->getAction($name); - $this->assertEquals( + $this->assertSame( Action::HTTP_REQUEST_METHOD_GET, $action->getHttpMethod(), "Action '$name' should use GET method" @@ -259,7 +261,7 @@ class ModuleTest extends TestCase $postActions = ['installerValidate', 'installerComplete', 'installerShutdown', 'installerReset', 'installerInstall']; foreach ($postActions as $name) { $action = $this->getAction($name); - $this->assertEquals( + $this->assertSame( Action::HTTP_REQUEST_METHOD_POST, $action->getHttpMethod(), "Action '$name' should use POST method" diff --git a/tests/unit/Platform/Modules/Installer/Runtime/ConfigTest.php b/tests/unit/Platform/Modules/Installer/Runtime/ConfigTest.php index 113bce5277..7f0faafcbc 100644 --- a/tests/unit/Platform/Modules/Installer/Runtime/ConfigTest.php +++ b/tests/unit/Platform/Modules/Installer/Runtime/ConfigTest.php @@ -1,11 +1,13 @@ assertEquals('80', $config->getDefaultHttpPort()); $this->assertEquals('443', $config->getDefaultHttpsPort()); - $this->assertEquals('appwrite', $config->getOrganization()); - $this->assertEquals('appwrite', $config->getImage()); + $this->assertSame('appwrite', $config->getOrganization()); + $this->assertSame('appwrite', $config->getImage()); $this->assertFalse($config->getNoStart()); $this->assertFalse($config->isUpgrade()); $this->assertFalse($config->isLocal()); $this->assertNull($config->getHostPath()); $this->assertNull($config->getLockedDatabase()); - $this->assertEquals(['mongodb', 'mariadb'], $config->getEnabledDatabases()); + $this->assertSame(['mongodb', 'mariadb'], $config->getEnabledDatabases()); $this->assertEmpty($config->getVars()); } @@ -34,7 +36,7 @@ class ConfigTest extends TestCase $this->assertEquals('8080', $config->getDefaultHttpPort()); $this->assertTrue($config->isUpgrade()); - $this->assertEquals('myorg', $config->getOrganization()); + $this->assertSame('myorg', $config->getOrganization()); } public function testConstructorWithUnknownKeysTreatsAsVars(): void @@ -45,7 +47,7 @@ class ConfigTest extends TestCase ]; $config = new Config($vars); - $this->assertEquals($vars, $config->getVars()); + $this->assertSame($vars, $config->getVars()); // Defaults should remain $this->assertEquals('80', $config->getDefaultHttpPort()); } @@ -68,13 +70,13 @@ class ConfigTest extends TestCase $this->assertEquals('3000', $config->getDefaultHttpPort()); $this->assertEquals('3443', $config->getDefaultHttpsPort()); - $this->assertEquals('testorg', $config->getOrganization()); - $this->assertEquals('testimage', $config->getImage()); + $this->assertSame('testorg', $config->getOrganization()); + $this->assertSame('testimage', $config->getImage()); $this->assertTrue($config->getNoStart()); $this->assertTrue($config->isUpgrade()); $this->assertTrue($config->isLocal()); - $this->assertEquals('/home/user', $config->getHostPath()); - $this->assertEquals('mariadb', $config->getLockedDatabase()); + $this->assertSame('/home/user', $config->getHostPath()); + $this->assertSame('mariadb', $config->getLockedDatabase()); $this->assertCount(1, $config->getVars()); } @@ -93,7 +95,7 @@ class ConfigTest extends TestCase { $config = new Config(); $config->setHostPath('/some/path'); - $this->assertEquals('/some/path', $config->getHostPath()); + $this->assertSame('/some/path', $config->getHostPath()); $config->apply(['hostPath' => null]); $this->assertNull($config->getHostPath()); @@ -111,7 +113,7 @@ class ConfigTest extends TestCase $this->assertEquals('8080', $config->getDefaultHttpPort()); $this->assertEquals('8443', $config->getDefaultHttpsPort()); - $this->assertEquals('updated', $config->getOrganization()); + $this->assertSame('updated', $config->getOrganization()); } public function testToArrayRoundTrip(): void @@ -154,8 +156,8 @@ class ConfigTest extends TestCase $rebuilt = new Config($original->toArray()); - $this->assertEquals($original->getDefaultHttpPort(), $rebuilt->getDefaultHttpPort()); - $this->assertEquals($original->isLocal(), $rebuilt->isLocal()); + $this->assertSame($original->getDefaultHttpPort(), $rebuilt->getDefaultHttpPort()); + $this->assertSame($original->isLocal(), $rebuilt->isLocal()); $this->assertEquals($original->getLockedDatabase(), $rebuilt->getLockedDatabase()); $this->assertEquals($original->toArray(), $rebuilt->toArray()); } @@ -178,14 +180,14 @@ class ConfigTest extends TestCase { $config = new Config(); $config->setOrganization('myorg'); - $this->assertEquals('myorg', $config->getOrganization()); + $this->assertSame('myorg', $config->getOrganization()); } public function testSetAndGetImage(): void { $config = new Config(); $config->setImage('myimage'); - $this->assertEquals('myimage', $config->getImage()); + $this->assertSame('myimage', $config->getImage()); } public function testSetAndGetNoStart(): void @@ -219,7 +221,7 @@ class ConfigTest extends TestCase { $config = new Config(); $config->setHostPath('/some/path'); - $this->assertEquals('/some/path', $config->getHostPath()); + $this->assertSame('/some/path', $config->getHostPath()); $config->setHostPath(null); $this->assertNull($config->getHostPath()); } @@ -228,7 +230,7 @@ class ConfigTest extends TestCase { $config = new Config(); $config->setLockedDatabase('mariadb'); - $this->assertEquals('mariadb', $config->getLockedDatabase()); + $this->assertSame('mariadb', $config->getLockedDatabase()); $config->setLockedDatabase(null); $this->assertNull($config->getLockedDatabase()); } @@ -241,7 +243,7 @@ class ConfigTest extends TestCase ['name' => '_APP_DOMAIN', 'default' => 'localhost'], ]; $config->setVars($vars); - $this->assertEquals($vars, $config->getVars()); + $this->assertSame($vars, $config->getVars()); } public function testJsonRoundTrip(): void @@ -376,7 +378,7 @@ class ConfigTest extends TestCase $config->apply(['lockedDatabase' => '']); // hasValidStringValue returns false for empty string - $this->assertEquals('mariadb', $config->getLockedDatabase()); + $this->assertSame('mariadb', $config->getLockedDatabase()); } public function testApplyLockedDatabaseIgnoresNull(): void @@ -386,7 +388,7 @@ class ConfigTest extends TestCase $config->apply(['lockedDatabase' => null]); // hasValidStringValue returns false for null - $this->assertEquals('mongodb', $config->getLockedDatabase()); + $this->assertSame('mongodb', $config->getLockedDatabase()); } public function testApplyPortWithIntegerValue(): void @@ -451,7 +453,7 @@ class ConfigTest extends TestCase $this->assertEquals('1111', $config->getDefaultHttpPort()); $this->assertEquals('2222', $config->getDefaultHttpsPort()); - $this->assertEquals('org', $config->getOrganization()); + $this->assertSame('org', $config->getOrganization()); $this->assertTrue($config->isLocal()); } @@ -492,7 +494,7 @@ class ConfigTest extends TestCase public function testDefaultEnabledDatabases(): void { $config = new Config(); - $this->assertEquals(['mongodb', 'mariadb'], $config->getEnabledDatabases()); + $this->assertSame(['mongodb', 'mariadb'], $config->getEnabledDatabases()); $this->assertTrue($config->isDatabaseEnabled('mongodb')); $this->assertTrue($config->isDatabaseEnabled('mariadb')); $this->assertFalse($config->isDatabaseEnabled('postgresql')); @@ -502,7 +504,7 @@ class ConfigTest extends TestCase { $config = new Config(); $config->setEnabledDatabases(['mongodb', 'mariadb', 'postgresql']); - $this->assertEquals(['mongodb', 'mariadb', 'postgresql'], $config->getEnabledDatabases()); + $this->assertSame(['mongodb', 'mariadb', 'postgresql'], $config->getEnabledDatabases()); $this->assertTrue($config->isDatabaseEnabled('postgresql')); } @@ -510,7 +512,7 @@ class ConfigTest extends TestCase { $config = new Config(); $config->setEnabledDatabases(['mongodb', '', null, 42, 'mariadb']); - $this->assertEquals(['mongodb', 'mariadb'], $config->getEnabledDatabases()); + $this->assertSame(['mongodb', 'mariadb'], $config->getEnabledDatabases()); } public function testSetEnabledDatabasesEmptyArrayPreservesExisting(): void @@ -518,14 +520,14 @@ class ConfigTest extends TestCase $config = new Config(); $config->setEnabledDatabases(['mongodb', 'postgresql']); $config->setEnabledDatabases([]); - $this->assertEquals(['mongodb', 'postgresql'], $config->getEnabledDatabases()); + $this->assertSame(['mongodb', 'postgresql'], $config->getEnabledDatabases()); } public function testApplyEnabledDatabases(): void { $config = new Config(); $config->apply(['enabledDatabases' => ['mongodb', 'mariadb', 'postgresql']]); - $this->assertEquals(['mongodb', 'mariadb', 'postgresql'], $config->getEnabledDatabases()); + $this->assertSame(['mongodb', 'mariadb', 'postgresql'], $config->getEnabledDatabases()); $this->assertTrue($config->isDatabaseEnabled('postgresql')); } @@ -533,7 +535,7 @@ class ConfigTest extends TestCase { $config = new Config(); $config->apply(['enabledDatabases' => 'mongodb']); - $this->assertEquals(['mongodb', 'mariadb'], $config->getEnabledDatabases()); + $this->assertSame(['mongodb', 'mariadb'], $config->getEnabledDatabases()); } public function testEnabledDatabasesInToArray(): void @@ -549,6 +551,6 @@ class ConfigTest extends TestCase $config = new Config(); $config->setEnabledDatabases(['mongodb', 'postgresql']); $rebuilt = new Config($config->toArray()); - $this->assertEquals(['mongodb', 'postgresql'], $rebuilt->getEnabledDatabases()); + $this->assertSame(['mongodb', 'postgresql'], $rebuilt->getEnabledDatabases()); } } diff --git a/tests/unit/Platform/Modules/Installer/Runtime/StateTest.php b/tests/unit/Platform/Modules/Installer/Runtime/StateTest.php index c8cfd6d884..a76e6c38d9 100644 --- a/tests/unit/Platform/Modules/Installer/Runtime/StateTest.php +++ b/tests/unit/Platform/Modules/Installer/Runtime/StateTest.php @@ -1,5 +1,7 @@ assertEquals('abc123', $this->state->sanitizeInstallId('abc123')); + $this->assertSame('abc123', $this->state->sanitizeInstallId('abc123')); } public function testSanitizeInstallIdWithSpecialChars(): void { - $this->assertEquals('abc123', $this->state->sanitizeInstallId('abc!@#123')); + $this->assertSame('abc123', $this->state->sanitizeInstallId('abc!@#123')); } public function testSanitizeInstallIdWithHyphensAndUnderscores(): void { - $this->assertEquals('abc-123_def', $this->state->sanitizeInstallId('abc-123_def')); + $this->assertSame('abc-123_def', $this->state->sanitizeInstallId('abc-123_def')); } public function testSanitizeInstallIdTruncatesTo64Chars(): void { $long = str_repeat('a', 100); - $this->assertEquals(64, strlen($this->state->sanitizeInstallId($long))); + $this->assertSame(64, strlen($this->state->sanitizeInstallId($long))); } public function testSanitizeInstallIdWithEmptyString(): void { - $this->assertEquals('', $this->state->sanitizeInstallId('')); + $this->assertSame('', $this->state->sanitizeInstallId('')); } public function testSanitizeInstallIdWithNonString(): void { - $this->assertEquals('', $this->state->sanitizeInstallId(123)); - $this->assertEquals('', $this->state->sanitizeInstallId(null)); + $this->assertSame('', $this->state->sanitizeInstallId(123)); + $this->assertSame('', $this->state->sanitizeInstallId(null)); } public function testHashSensitiveValueProducesConsistentHash(): void { $hash1 = $this->state->hashSensitiveValue('secret'); $hash2 = $this->state->hashSensitiveValue('secret'); - $this->assertEquals($hash1, $hash2); + $this->assertSame($hash1, $hash2); } public function testHashSensitiveValueDifferentInputsDifferentHashes(): void { $hash1 = $this->state->hashSensitiveValue('secret1'); $hash2 = $this->state->hashSensitiveValue('secret2'); - $this->assertNotEquals($hash1, $hash2); + $this->assertNotSame($hash1, $hash2); } public function testHashSensitiveValueTrimsWhitespace(): void { $hash1 = $this->state->hashSensitiveValue('secret'); $hash2 = $this->state->hashSensitiveValue(' secret '); - $this->assertEquals($hash1, $hash2); + $this->assertSame($hash1, $hash2); } public function testHashSensitiveValueEmptyStringReturnsEmpty(): void { - $this->assertEquals('', $this->state->hashSensitiveValue('')); - $this->assertEquals('', $this->state->hashSensitiveValue(' ')); + $this->assertSame('', $this->state->hashSensitiveValue('')); + $this->assertSame('', $this->state->hashSensitiveValue(' ')); } public function testHashSensitiveValueReturnsSha256(): void { $hash = $this->state->hashSensitiveValue('test'); - $this->assertEquals(64, strlen($hash)); // SHA-256 produces 64 hex chars + $this->assertSame(64, strlen($hash)); // SHA-256 produces 64 hex chars $this->assertMatchesRegularExpression('/^[a-f0-9]{64}$/', $hash); } @@ -433,37 +435,37 @@ class StateTest extends TestCase public function testSanitizeInstallIdWithOnlySpecialChars(): void { - $this->assertEquals('', $this->state->sanitizeInstallId('!@#$%^&*()')); + $this->assertSame('', $this->state->sanitizeInstallId('!@#$%^&*()')); } public function testSanitizeInstallIdWithUnicode(): void { // Unicode letters are stripped byte-by-byte, only ASCII alphanum + hyphen + underscore kept // 'é' is 2 bytes (0xC3 0xA9), both stripped => 'héllo' becomes 'hllo' - $this->assertEquals('hllo', $this->state->sanitizeInstallId('héllo')); + $this->assertSame('hllo', $this->state->sanitizeInstallId('héllo')); } public function testSanitizeInstallIdWithExactly64Chars(): void { $exact = str_repeat('b', 64); - $this->assertEquals($exact, $this->state->sanitizeInstallId($exact)); - $this->assertEquals(64, strlen($this->state->sanitizeInstallId($exact))); + $this->assertSame($exact, $this->state->sanitizeInstallId($exact)); + $this->assertSame(64, strlen($this->state->sanitizeInstallId($exact))); } public function testSanitizeInstallIdWithBooleanInput(): void { - $this->assertEquals('', $this->state->sanitizeInstallId(true)); - $this->assertEquals('', $this->state->sanitizeInstallId(false)); + $this->assertSame('', $this->state->sanitizeInstallId(true)); + $this->assertSame('', $this->state->sanitizeInstallId(false)); } public function testSanitizeInstallIdWithArrayInput(): void { - $this->assertEquals('', $this->state->sanitizeInstallId([])); + $this->assertSame('', $this->state->sanitizeInstallId([])); } public function testSanitizeInstallIdPreservesCase(): void { - $this->assertEquals('AbCdEf', $this->state->sanitizeInstallId('AbCdEf')); + $this->assertSame('AbCdEf', $this->state->sanitizeInstallId('AbCdEf')); } public function testIsValidPortBoundaryValues(): void @@ -748,7 +750,7 @@ class StateTest extends TestCase @unlink(Server::INSTALLER_LOCK_FILE); $installId = 'lock-test-' . uniqid(); $result = $this->state->reserveGlobalLock($installId); - $this->assertEquals('ok', $result); + $this->assertSame('ok', $result); } public function testReserveGlobalLockSameIdCanRelock(): void @@ -757,11 +759,11 @@ class StateTest extends TestCase $installId = 'lock-relock-' . uniqid(); $result1 = $this->state->reserveGlobalLock($installId); - $this->assertEquals('ok', $result1); + $this->assertSame('ok', $result1); // Same ID can re-reserve $result2 = $this->state->reserveGlobalLock($installId); - $this->assertEquals('ok', $result2); + $this->assertSame('ok', $result2); } public function testReserveGlobalLockDifferentIdBlocked(): void @@ -771,11 +773,11 @@ class StateTest extends TestCase $installId2 = 'lock-id2-' . uniqid(); $result1 = $this->state->reserveGlobalLock($installId1); - $this->assertEquals('ok', $result1); + $this->assertSame('ok', $result1); // Different ID should be blocked $result2 = $this->state->reserveGlobalLock($installId2); - $this->assertEquals('locked', $result2); + $this->assertSame('locked', $result2); } public function testReserveGlobalLockAfterCompleted(): void @@ -789,7 +791,7 @@ class StateTest extends TestCase // After completion, a new install should be able to lock $result = $this->state->reserveGlobalLock($installId2); - $this->assertEquals('ok', $result); + $this->assertSame('ok', $result); } public function testReserveGlobalLockAfterError(): void @@ -803,7 +805,7 @@ class StateTest extends TestCase // After error, a new install should be able to lock $result = $this->state->reserveGlobalLock($installId2); - $this->assertEquals('ok', $result); + $this->assertSame('ok', $result); } public function testReserveGlobalLockExpiredLockAllowsNew(): void @@ -820,7 +822,7 @@ class StateTest extends TestCase $newId = 'lock-after-expired-' . uniqid(); $result = $this->state->reserveGlobalLock($newId); - $this->assertEquals('ok', $result); + $this->assertSame('ok', $result); } public function testUpdateGlobalLockUpdatesOwnLock(): void @@ -988,7 +990,7 @@ class StateTest extends TestCase // Newlines are not stripped by trim but surrounding whitespace is $hash1 = $this->state->hashSensitiveValue("line1\nline2"); $hash2 = $this->state->hashSensitiveValue("line1\nline2"); - $this->assertEquals($hash1, $hash2); + $this->assertSame($hash1, $hash2); $this->assertNotEmpty($hash1); } @@ -996,7 +998,7 @@ class StateTest extends TestCase { // A newline is not whitespace that trim() removes? Actually trim() removes \n // "\n" trimmed becomes "" => should return '' - $this->assertEquals('', $this->state->hashSensitiveValue("\n")); + $this->assertSame('', $this->state->hashSensitiveValue("\n")); } public function testIsValidEmailAddressWithUnicodeLocal(): void @@ -1098,7 +1100,7 @@ class StateTest extends TestCase // 1. Reserve lock $lockResult = $this->state->reserveGlobalLock($installId); - $this->assertEquals('ok', $lockResult); + $this->assertSame('ok', $lockResult); // 2. Write progress through multiple steps $this->state->writeProgressFile($installId, [ @@ -1143,6 +1145,6 @@ class StateTest extends TestCase $newId = 'lifecycle-new-' . uniqid(); $this->trackProgressFile($newId); $newResult = $this->state->reserveGlobalLock($newId); - $this->assertEquals('ok', $newResult); + $this->assertSame('ok', $newResult); } } diff --git a/tests/unit/Platform/Modules/Installer/Validator/AppDomainTest.php b/tests/unit/Platform/Modules/Installer/Validator/AppDomainTest.php index 0a360783ac..14c57f9ce9 100644 --- a/tests/unit/Platform/Modules/Installer/Validator/AppDomainTest.php +++ b/tests/unit/Platform/Modules/Installer/Validator/AppDomainTest.php @@ -1,11 +1,13 @@ assertEquals($this->validator::TYPE_STRING, $this->validator->getType()); + $this->assertSame($this->validator::TYPE_STRING, $this->validator->getType()); } public function testRejectsNonStringTypes(): void diff --git a/tests/unit/SDK/Specification/FormatTest.php b/tests/unit/SDK/Specification/FormatTest.php index ea9ed3bd43..51d99de429 100644 --- a/tests/unit/SDK/Specification/FormatTest.php +++ b/tests/unit/SDK/Specification/FormatTest.php @@ -31,7 +31,7 @@ class TestFormat extends Format } } -class FormatTest extends TestCase +final class FormatTest extends TestCase { private TestFormat $format; diff --git a/tests/unit/Task/Validator/CronTest.php b/tests/unit/Task/Validator/CronTest.php index 3809c825b5..94d71f352b 100644 --- a/tests/unit/Task/Validator/CronTest.php +++ b/tests/unit/Task/Validator/CronTest.php @@ -1,11 +1,13 @@ assertEquals($this->object->isValid('0 2 * * *'), true); // execute at 2am daily - $this->assertEquals($this->object->isValid('0 5,17 * * *'), true); // execute twice a day - $this->assertEquals($this->object->isValid('* * * * *'), true); // execute on every minutes + $this->assertEquals(true, $this->object->isValid('0 2 * * *')); // execute at 2am daily + $this->assertEquals(true, $this->object->isValid('0 5,17 * * *')); // execute twice a day + $this->assertEquals(true, $this->object->isValid('* * * * *')); // execute on every minutes // $this->assertEquals($this->object->isValid('0 17 * * sun'), true); // execute on every Sunday at 5 PM - $this->assertEquals($this->object->isValid('*/10 * * * *'), true); // execute on every 10 minutes - $this->assertEquals($this->object->isValid('*/5 22-23,0-3 * * *'), true); // execute every 5 minutes from 10pm to 3am + $this->assertEquals(true, $this->object->isValid('*/10 * * * *')); // execute on every 10 minutes + $this->assertEquals(true, $this->object->isValid('*/5 22-23,0-3 * * *')); // execute every 5 minutes from 10pm to 3am // $this->assertEquals($this->object->isValid('* * * jan,may,aug *'), true); // execute on selected months // $this->assertEquals($this->object->isValid('0 17 * * sun,fri'), true); // execute on selected days // $this->assertEquals($this->object->isValid('0 2 * * sun'), true); // execute on first sunday of every month - $this->assertEquals($this->object->isValid('0 */4 * * *'), true); // execute on every four hours + $this->assertEquals(true, $this->object->isValid('0 */4 * * *')); // execute on every four hours // $this->assertEquals($this->object->isValid('0 4,17 * * sun,mon'), true); // execute twice on every Sunday and Monday - $this->assertEquals($this->object->isValid('bad expression'), false); - $this->assertEquals($this->object->isValid('*/5 22-3 * * *'), false); - $this->assertEquals(null, false); - $this->assertEquals('', false); + $this->assertFalse($this->object->isValid('bad expression')); + $this->assertFalse($this->object->isValid('*/5 22-3 * * *')); } } diff --git a/tests/unit/Template/TemplateTest.php b/tests/unit/Template/TemplateTest.php index 1ca1595ca3..7dee6ca078 100644 --- a/tests/unit/Template/TemplateTest.php +++ b/tests/unit/Template/TemplateTest.php @@ -1,11 +1,13 @@ assertEquals($this->object->render(), 'Hello WORLD'); + $this->assertEquals('Hello WORLD', $this->object->render()); } public function testParseURL(): void { $url = $this->object->parseURL('https://appwrite.io/demo'); - $this->assertEquals($url['scheme'], 'https'); - $this->assertEquals($url['host'], 'appwrite.io'); - $this->assertEquals($url['path'], '/demo'); + $this->assertEquals('https', $url['scheme']); + $this->assertEquals('appwrite.io', $url['host']); + $this->assertEquals('/demo', $url['path']); } public function testUnParseURL(): void @@ -46,23 +48,23 @@ class TemplateTest extends TestCase $url['host'] = 'example.com'; $url['path'] = '/new'; - $this->assertEquals($this->object->unParseURL($url), 'http://example.com/new'); + $this->assertEquals('http://example.com/new', $this->object->unParseURL($url)); } public function testMergeQuery(): void { - $this->assertEquals($this->object->mergeQuery('key1=value1&key2=value2', ['key1' => 'value3', 'key4' => 'value4']), 'key1=value3&key2=value2&key4=value4'); + $this->assertEquals('key1=value3&key2=value2&key4=value4', $this->object->mergeQuery('key1=value1&key2=value2', ['key1' => 'value3', 'key4' => 'value4'])); } public function testFromCamelCaseToSnake(): void { - $this->assertEquals('app_write', Template::fromCamelCaseToSnake('appWrite')); - $this->assertEquals('app_write', Template::fromCamelCaseToSnake('App Write')); + $this->assertSame('app_write', Template::fromCamelCaseToSnake('appWrite')); + $this->assertSame('app_write', Template::fromCamelCaseToSnake('App Write')); } public function testFromCamelCaseToDash(): void { - $this->assertEquals('app-write', Template::fromCamelCaseToDash('appWrite')); - $this->assertEquals('app-write', Template::fromCamelCaseToDash('App Write')); + $this->assertSame('app-write', Template::fromCamelCaseToDash('appWrite')); + $this->assertSame('app-write', Template::fromCamelCaseToDash('App Write')); } } diff --git a/tests/unit/Transformation/TransformationTest.php b/tests/unit/Transformation/TransformationTest.php index a3169026a3..2b7cb568c3 100644 --- a/tests/unit/Transformation/TransformationTest.php +++ b/tests/unit/Transformation/TransformationTest.php @@ -1,5 +1,7 @@ setTraits(['mock' => true, 'content-type' => 'text/plain, text/html; charset=utf-8']); $this->assertTrue($transformer->transform()); - $this->assertStringContainsString("Hello world", $transformer->getOutput()); - $this->assertStringContainsString("Preview by", $transformer->getOutput()); - $this->assertStringContainsString("Mock:", $transformer->getOutput()); + $this->assertStringContainsString("Hello world", (string) $transformer->getOutput()); + $this->assertStringContainsString("Preview by", (string) $transformer->getOutput()); + $this->assertStringContainsString("Mock:", (string) $transformer->getOutput()); } } diff --git a/tests/unit/URL/URLTest.php b/tests/unit/URL/URLTest.php index 6558acc66c..169770811e 100644 --- a/tests/unit/URL/URLTest.php +++ b/tests/unit/URL/URLTest.php @@ -1,11 +1,13 @@ 'query=string¶m=value', ]); - $this->assertEquals('https://appwrite.io:8080/path?query=string¶m=value', $url); + $this->assertSame('https://appwrite.io:8080/path?query=string¶m=value', $url); $url = URL::unparse([ 'scheme' => 'https', @@ -54,7 +56,7 @@ class URLTest extends TestCase 'query' => 'query=string¶m=value', ]); - $this->assertEquals('https://appwrite.io/path?query=string¶m=value', $url); + $this->assertSame('https://appwrite.io/path?query=string¶m=value', $url); $url = URL::unparse([ 'scheme' => 'https', @@ -64,7 +66,7 @@ class URLTest extends TestCase 'query' => '', ]); - $this->assertEquals('https://appwrite.io/', $url); + $this->assertSame('https://appwrite.io/', $url); $url = URL::unparse([ 'scheme' => 'https', @@ -74,7 +76,7 @@ class URLTest extends TestCase 'fragment' => 'bottom', ]); - $this->assertEquals('https://appwrite.io/#bottom', $url); + $this->assertSame('https://appwrite.io/#bottom', $url); $url = URL::unparse([ 'scheme' => 'https', @@ -86,7 +88,7 @@ class URLTest extends TestCase 'fragment' => 'bottom', ]); - $this->assertEquals('https://eldad:fux@appwrite.io/#bottom', $url); + $this->assertSame('https://eldad:fux@appwrite.io/#bottom', $url); $url = URL::unparse([ 'scheme' => 'https', @@ -98,21 +100,21 @@ class URLTest extends TestCase 'fragment' => '', ]); - $this->assertEquals('https://appwrite.io/#', $url); + $this->assertSame('https://appwrite.io/#', $url); } public function testParseQuery(): void { $result = URL::parseQuery('param1=value1¶m2=value2'); - $this->assertEquals(['param1' => 'value1', 'param2' => 'value2'], $result); + $this->assertSame(['param1' => 'value1', 'param2' => 'value2'], $result); } public function testUnParseQuery(): void { $result = URL::unparseQuery(['param1' => 'value1', 'param2' => 'value2']); - $this->assertEquals('param1=value1¶m2=value2', $result); + $this->assertSame('param1=value1¶m2=value2', $result); } /** diff --git a/tests/unit/Utopia/Database/Documents/UserTest.php b/tests/unit/Utopia/Database/Documents/UserTest.php index 5bd73db132..c21c5f6272 100644 --- a/tests/unit/Utopia/Database/Documents/UserTest.php +++ b/tests/unit/Utopia/Database/Documents/UserTest.php @@ -1,5 +1,7 @@ assertEquals('token1', $user1->sessionVerify($secret, $proofForToken)); - $this->assertEquals($user1->sessionVerify('false-secret', $proofForToken), false); - $this->assertEquals($user2->sessionVerify($secret, $proofForToken), false); - $this->assertEquals($user2->sessionVerify('false-secret', $proofForToken), false); + $this->assertEquals(false, $user1->sessionVerify('false-secret', $proofForToken)); + $this->assertEquals(false, $user2->sessionVerify($secret, $proofForToken)); + $this->assertEquals(false, $user2->sessionVerify('false-secret', $proofForToken)); } public function testTokenVerify(): void @@ -162,11 +164,11 @@ class UserTest extends TestCase $this->assertEquals($user1->tokenVerify(TOKEN_TYPE_RECOVERY, $secret, $proofForToken), $tokens1[0]); $this->assertEquals($user1->tokenVerify(null, $secret, $proofForToken), $tokens1[0]); - $this->assertEquals($user1->tokenVerify(TOKEN_TYPE_RECOVERY, 'false-secret', $proofForToken), false); - $this->assertEquals($user2->tokenVerify(TOKEN_TYPE_RECOVERY, $secret, $proofForToken), false); - $this->assertEquals($user2->tokenVerify(TOKEN_TYPE_RECOVERY, 'false-secret', $proofForToken), false); - $this->assertEquals($user3->tokenVerify(TOKEN_TYPE_RECOVERY, $secret, $proofForToken), false); - $this->assertEquals($user3->tokenVerify(TOKEN_TYPE_RECOVERY, 'false-secret', $proofForToken), false); + $this->assertEquals(false, $user1->tokenVerify(TOKEN_TYPE_RECOVERY, 'false-secret', $proofForToken)); + $this->assertEquals(false, $user2->tokenVerify(TOKEN_TYPE_RECOVERY, $secret, $proofForToken)); + $this->assertEquals(false, $user2->tokenVerify(TOKEN_TYPE_RECOVERY, 'false-secret', $proofForToken)); + $this->assertEquals(false, $user3->tokenVerify(TOKEN_TYPE_RECOVERY, $secret, $proofForToken)); + $this->assertEquals(false, $user3->tokenVerify(TOKEN_TYPE_RECOVERY, 'false-secret', $proofForToken)); } public function testIsPrivilegedUser(): void diff --git a/tests/unit/Utopia/Database/Query/RuntimeQueryTest.php b/tests/unit/Utopia/Database/Query/RuntimeQueryTest.php index d5507327be..fd4da9bbfc 100644 --- a/tests/unit/Utopia/Database/Query/RuntimeQueryTest.php +++ b/tests/unit/Utopia/Database/Query/RuntimeQueryTest.php @@ -1,12 +1,14 @@ 'John', 'age' => 30]; $result = $this->compileAndFilter([], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testFilterWithNoMatchingQuery(): void @@ -45,7 +47,7 @@ class RuntimeQueryTest extends TestCase $queries = [Query::equal('name', ['John'])]; $payload = ['name' => 'John', 'age' => 30]; $result = $this->compileAndFilter($queries, $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } // TYPE_EQUAL tests @@ -54,7 +56,7 @@ class RuntimeQueryTest extends TestCase $query = Query::equal('name', ['John']); $payload = ['name' => 'John']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testEqualNoMatch(): void @@ -70,7 +72,7 @@ class RuntimeQueryTest extends TestCase $query = Query::equal('status', ['active', 'pending', 'approved']); $payload = ['status' => 'active']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testEqualMultipleValuesNoMatch(): void @@ -86,7 +88,7 @@ class RuntimeQueryTest extends TestCase $query = Query::equal('age', [30, 25, 35]); $payload = ['age' => 30]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testEqualBooleanValues(): void @@ -111,7 +113,7 @@ class RuntimeQueryTest extends TestCase $query = Query::notEqual('name', ['Jane']); $payload = ['name' => 'John']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testNotEqualNoMatch(): void @@ -129,7 +131,7 @@ class RuntimeQueryTest extends TestCase $query = Query::notEqual('status', ['rejected', 'cancelled']); $payload = ['status' => 'active']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); $query = Query::notEqual('status', ['active', 'pending']); $payload = ['status' => 'active']; @@ -143,7 +145,7 @@ class RuntimeQueryTest extends TestCase $query = Query::lessThan('age', 30); $payload = ['age' => 25]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testLesserNoMatch(): void @@ -169,7 +171,7 @@ class RuntimeQueryTest extends TestCase $query = Query::lessThan('age', 30); $payload = ['age' => 25]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testLesserStringComparison(): void @@ -177,7 +179,7 @@ class RuntimeQueryTest extends TestCase $query = Query::lessThan('name', 'M'); $payload = ['name' => 'A']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } // TYPE_LESSER_EQUAL tests @@ -186,7 +188,7 @@ class RuntimeQueryTest extends TestCase $query = Query::lessThanEqual('age', 30); $payload = ['age' => 25]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testLesserEqualExactMatch(): void @@ -194,7 +196,7 @@ class RuntimeQueryTest extends TestCase $query = Query::lessThanEqual('age', 30); $payload = ['age' => 30]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testLesserEqualNoMatch(): void @@ -211,7 +213,7 @@ class RuntimeQueryTest extends TestCase $query = Query::lessThanEqual('age', 30); $payload = ['age' => 30]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } // TYPE_GREATER tests @@ -220,7 +222,7 @@ class RuntimeQueryTest extends TestCase $query = Query::greaterThan('age', 30); $payload = ['age' => 35]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testGreaterNoMatch(): void @@ -245,7 +247,7 @@ class RuntimeQueryTest extends TestCase $query = Query::greaterThan('age', 20); $payload = ['age' => 35]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } // TYPE_GREATER_EQUAL tests @@ -254,7 +256,7 @@ class RuntimeQueryTest extends TestCase $query = Query::greaterThanEqual('age', 30); $payload = ['age' => 35]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testGreaterEqualExactMatch(): void @@ -262,7 +264,7 @@ class RuntimeQueryTest extends TestCase $query = Query::greaterThanEqual('age', 30); $payload = ['age' => 30]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testGreaterEqualNoMatch(): void @@ -279,7 +281,7 @@ class RuntimeQueryTest extends TestCase $query = Query::greaterThanEqual('age', 20); $payload = ['age' => 30]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } // TYPE_IS_NULL tests @@ -313,7 +315,7 @@ class RuntimeQueryTest extends TestCase $query = Query::isNotNull('description'); $payload = ['description' => 'Some text']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testIsNotNullNoMatch(): void @@ -341,7 +343,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['name' => 'John', 'age' => 30]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testAndOneFails(): void @@ -375,7 +377,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['status' => 'active', 'age' => 25, 'email' => 'test@example.com']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testAndNestedAnd(): void @@ -389,7 +391,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['name' => 'John', 'age' => 30, 'status' => 'active']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } // TYPE_OR tests @@ -401,7 +403,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['name' => 'John']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testOrAllMatch(): void @@ -412,7 +414,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['status' => 'active']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testOrAllFail(): void @@ -435,7 +437,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['status' => 'pending']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testOrNestedOr(): void @@ -449,7 +451,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['name' => 'Bob']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testOrWithDifferentAttributes(): void @@ -460,7 +462,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['name' => 'Jane', 'email' => 'john@example.com']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testOrWithMissingAttributeInOneBranch(): void @@ -473,7 +475,7 @@ class RuntimeQueryTest extends TestCase // Payload only has email, not name - should still match via email branch $payload = ['email' => 'john@example.com']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testOrWithMissingAttributeNoMatch(): void @@ -501,7 +503,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['type' => 'user', 'status' => 'active']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testOrAndCombination(): void @@ -518,7 +520,7 @@ class RuntimeQueryTest extends TestCase ]); $payload = ['name' => 'John', 'age' => 30]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } // Edge cases @@ -530,7 +532,7 @@ class RuntimeQueryTest extends TestCase ]; $payload = ['name' => 'John', 'age' => 30]; $result = $this->compileAndFilter($queries, $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testMultipleQueriesFirstMatches(): void @@ -582,7 +584,7 @@ class RuntimeQueryTest extends TestCase $payload = ['name' => 'John']; $result = $this->compileAndFilter([$query], $payload); // Empty AND should return true (all conditions pass vacuously) - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testEmptyOrQuery(): void @@ -600,7 +602,7 @@ class RuntimeQueryTest extends TestCase $query = Query::equal('count', [0]); $payload = ['count' => 0]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testEqualWithEmptyString(): void @@ -608,7 +610,7 @@ class RuntimeQueryTest extends TestCase $query = Query::equal('name', ['']); $payload = ['name' => '']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testEqualWithFalse(): void @@ -624,7 +626,7 @@ class RuntimeQueryTest extends TestCase $query = Query::greaterThan('score', 8.5); $payload = ['score' => 9.2]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testComparisonWithStringNumbers(): void @@ -632,7 +634,7 @@ class RuntimeQueryTest extends TestCase $query = Query::lessThan('version', '10'); $payload = ['version' => '9']; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } // TYPE_SELECT tests - select("*") means "listen to all events" @@ -703,7 +705,7 @@ class RuntimeQueryTest extends TestCase $query = Query::select(['*']); $payload = ['name' => 'John', 'age' => 30]; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testFilterWithSelectAllAndOtherQueriesReturnsPayload(): void @@ -716,7 +718,7 @@ class RuntimeQueryTest extends TestCase $payload = ['name' => 'John', 'age' => 30]; $result = $this->compileAndFilter($queries, $payload); // select("*") takes precedence - returns payload - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } public function testFilterWithSelectAllOnEmptyPayload(): void @@ -724,6 +726,6 @@ class RuntimeQueryTest extends TestCase $query = Query::select(['*']); $payload = []; $result = $this->compileAndFilter([$query], $payload); - $this->assertEquals($payload, $result); + $this->assertSame($payload, $result); } } diff --git a/tests/unit/Utopia/Database/Validator/CompoundUIDTest.php b/tests/unit/Utopia/Database/Validator/CompoundUIDTest.php index b443cf590b..3547d511a5 100644 --- a/tests/unit/Utopia/Database/Validator/CompoundUIDTest.php +++ b/tests/unit/Utopia/Database/Validator/CompoundUIDTest.php @@ -1,11 +1,13 @@ assertEquals($this->object->isValid('123:456'), true); - $this->assertEquals($this->object->isValid('123'), false); - $this->assertEquals($this->object->isValid('123:_456'), false); - $this->assertEquals($this->object->isValid('dasda asdasd'), false); - $this->assertEquals($this->object->isValid('dasda:asdasd'), true); - $this->assertEquals($this->object->isValid('_asdas:dasdas'), false); - $this->assertEquals($this->object->isValid('as$$5da:sdasdas'), false); - $this->assertEquals($this->object->isValid(false), false); - $this->assertEquals($this->object->isValid(null), false); - $this->assertEquals($this->object->isValid('socialAccountForYoutubeAndRestSubscribers:12345'), false); - $this->assertEquals($this->object->isValid('socialAccountForYoutubeAndRSubscriber:12345'), false); - $this->assertEquals($this->object->isValid('socialAccount:ForYoutubeSubscribe'), true); - $this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscribe:socialAccountForYoutubeSubscribe'), true); + $this->assertTrue($this->object->isValid('123:456')); + $this->assertFalse($this->object->isValid('123')); + $this->assertFalse($this->object->isValid('123:_456')); + $this->assertFalse($this->object->isValid('dasda asdasd')); + $this->assertTrue($this->object->isValid('dasda:asdasd')); + $this->assertFalse($this->object->isValid('_asdas:dasdas')); + $this->assertFalse($this->object->isValid('as$$5da:sdasdas')); + $this->assertFalse($this->object->isValid(false)); + $this->assertFalse($this->object->isValid(null)); + $this->assertFalse($this->object->isValid('socialAccountForYoutubeAndRestSubscribers:12345')); + $this->assertFalse($this->object->isValid('socialAccountForYoutubeAndRSubscriber:12345')); + $this->assertTrue($this->object->isValid('socialAccount:ForYoutubeSubscribe')); + $this->assertTrue($this->object->isValid('socialAccountForYoutubeSubscribe:socialAccountForYoutubeSubscribe')); } } diff --git a/tests/unit/Utopia/Database/Validator/CustomIdTest.php b/tests/unit/Utopia/Database/Validator/CustomIdTest.php index e8c37a3f72..fea3ea49f6 100644 --- a/tests/unit/Utopia/Database/Validator/CustomIdTest.php +++ b/tests/unit/Utopia/Database/Validator/CustomIdTest.php @@ -1,11 +1,13 @@ assertEquals($this->object->isValid('unique()'), true); - $this->assertEquals($this->object->isValid('unique)'), false); - $this->assertEquals($this->object->isValid('else()'), false); - $this->assertEquals($this->object->isValid('dasda asdasd'), false); - $this->assertEquals($this->object->isValid('dasda_asdasd'), true); - $this->assertEquals($this->object->isValid('asdasdasdas'), true); - $this->assertEquals($this->object->isValid('_asdasdasdas'), false); - $this->assertEquals($this->object->isValid('as$$5dasdasdas'), false); - $this->assertEquals($this->object->isValid(false), false); - $this->assertEquals($this->object->isValid(null), false); - $this->assertEquals($this->object->isValid('socialAccountForYoutubeAndRestSubscribers'), false); - $this->assertEquals($this->object->isValid('socialAccountForYoutubeAndRSubscriber'), false); - $this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscribe'), true); - $this->assertEquals($this->object->isValid('socialAccountForYoutubeSubscrib'), true); + $this->assertTrue($this->object->isValid('unique()')); + $this->assertFalse($this->object->isValid('unique)')); + $this->assertFalse($this->object->isValid('else()')); + $this->assertFalse($this->object->isValid('dasda asdasd')); + $this->assertTrue($this->object->isValid('dasda_asdasd')); + $this->assertTrue($this->object->isValid('asdasdasdas')); + $this->assertFalse($this->object->isValid('_asdasdasdas')); + $this->assertFalse($this->object->isValid('as$$5dasdasdas')); + $this->assertFalse($this->object->isValid(false)); + $this->assertFalse($this->object->isValid(null)); + $this->assertFalse($this->object->isValid('socialAccountForYoutubeAndRestSubscribers')); + $this->assertFalse($this->object->isValid('socialAccountForYoutubeAndRSubscriber')); + $this->assertTrue($this->object->isValid('socialAccountForYoutubeSubscribe')); + $this->assertTrue($this->object->isValid('socialAccountForYoutubeSubscrib')); } } diff --git a/tests/unit/Utopia/Database/Validator/ProjectIdTest.php b/tests/unit/Utopia/Database/Validator/ProjectIdTest.php index 02a30ab346..12eb544afd 100644 --- a/tests/unit/Utopia/Database/Validator/ProjectIdTest.php +++ b/tests/unit/Utopia/Database/Validator/ProjectIdTest.php @@ -1,12 +1,14 @@ ['unique()', true], - 'dashes' => ['as12-df34', true], - '36 chars' => [\str_repeat('a', 36), true], - 'uppercase' => ['ABC', false], - 'underscore' => ['under_score', false], - 'leading dash' => ['-dash', false], - 'too long' => [\str_repeat('a', 37), false], - ]; + yield 'unique()' => ['unique()', true]; + yield 'dashes' => ['as12-df34', true]; + yield '36 chars' => [\str_repeat('a', 36), true]; + yield 'uppercase' => ['ABC', false]; + yield 'underscore' => ['under_score', false]; + yield 'leading dash' => ['-dash', false]; + yield 'too long' => [\str_repeat('a', 37), false]; } #[DataProvider('provideTest')] public function testValues(string $input, bool $expected): void { - $this->assertEquals($this->object->isValid($input), $expected); + $this->assertSame($this->object->isValid($input), $expected); } public function testCustomMaxLength(): void diff --git a/tests/unit/Utopia/Database/Validator/Queries/CollectionTest.php b/tests/unit/Utopia/Database/Validator/Queries/CollectionTest.php index cdeccef1bd..14331ff853 100644 --- a/tests/unit/Utopia/Database/Validator/Queries/CollectionTest.php +++ b/tests/unit/Utopia/Database/Validator/Queries/CollectionTest.php @@ -1,5 +1,7 @@ assertEquals($validator->isValid([]), true); + $this->assertTrue($validator->isValid([])); } public function testValid(): void diff --git a/tests/unit/Utopia/Database/Validator/Queries/UsersTest.php b/tests/unit/Utopia/Database/Validator/Queries/UsersTest.php index 327ae185cb..4ae58fbbcd 100644 --- a/tests/unit/Utopia/Database/Validator/Queries/UsersTest.php +++ b/tests/unit/Utopia/Database/Validator/Queries/UsersTest.php @@ -1,12 +1,14 @@ [ - [ - 'data' => 'Lorem ipsum' - ], - [ - 'body' => 'Lorem ipsum' - ], + yield 'data' => [ + [ + 'data' => 'Lorem ipsum' ], - 'no data' => [ - [], - [ - 'body' => '' - ], + [ + 'body' => 'Lorem ipsum' + ], + ]; + yield 'no data' => [ + [], + [ + 'body' => '' ], ]; } diff --git a/tests/unit/Utopia/Request/Filters/V17Test.php b/tests/unit/Utopia/Request/Filters/V17Test.php index afc363c582..b026e1f04b 100644 --- a/tests/unit/Utopia/Request/Filters/V17Test.php +++ b/tests/unit/Utopia/Request/Filters/V17Test.php @@ -1,5 +1,7 @@ [ - [ - 'userId' => 'test', - 'secret' => 'test', - 'password' => '123456', - 'passwordAgain' => '123456' - ], - [ - 'userId' => 'test', - 'secret' => 'test', - 'password' => '123456', - ] + yield 'remove passwordAgain' => [ + [ + 'userId' => 'test', + 'secret' => 'test', + 'password' => '123456', + 'passwordAgain' => '123456' + ], + [ + 'userId' => 'test', + 'secret' => 'test', + 'password' => '123456', ] ]; } @@ -52,25 +52,23 @@ class V17Test extends TestCase $this->assertEquals($expected, $result); } - public static function createQueryProvider(): array + public static function createQueryProvider(): \Iterator { - return [ - 'convert queries' => [ - [ - 'queries' => [ - 'cursorAfter("exampleId")', - 'search("name", ["example"])', - 'isNotNull("name")' - ] - ], - [ - 'queries' => [ - '{"method":"cursorAfter","values":["exampleId"]}', - '{"method":"search","attribute":"name","values":["example"]}', - '{"method":"isNotNull","attribute":"name"}' - ] - ], - ] + yield 'convert queries' => [ + [ + 'queries' => [ + 'cursorAfter("exampleId")', + 'search("name", ["example"])', + 'isNotNull("name")' + ] + ], + [ + 'queries' => [ + '{"method":"cursorAfter","values":["exampleId"]}', + '{"method":"search","attribute":"name","values":["example"]}', + '{"method":"isNotNull","attribute":"name"}' + ] + ], ]; } diff --git a/tests/unit/Utopia/Request/Filters/V18Test.php b/tests/unit/Utopia/Request/Filters/V18Test.php index e4f3f0043b..aefe9607f8 100644 --- a/tests/unit/Utopia/Request/Filters/V18Test.php +++ b/tests/unit/Utopia/Request/Filters/V18Test.php @@ -1,5 +1,7 @@ [ - [ - 'type' => 'totp', - 'otp' => 1230 - ], - [ - 'type' => 'totp' - ] + yield 'remove otp' => [ + [ + 'type' => 'totp', + 'otp' => 1230 + ], + [ + 'type' => 'totp' ] ]; } diff --git a/tests/unit/Utopia/Request/Filters/V19Test.php b/tests/unit/Utopia/Request/Filters/V19Test.php index b302ee6a5f..60d2083f7d 100644 --- a/tests/unit/Utopia/Request/Filters/V19Test.php +++ b/tests/unit/Utopia/Request/Filters/V19Test.php @@ -1,5 +1,7 @@ [ - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0', - 'templateRepository' => 'github.com/appwrite/templates', - 'templateOwner' => 'appwrite', - 'templateRootDirectory' => 'functions/node', - 'templateVersion' => '1.0.0' - ], - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0' - ] + yield 'remove template fields' => [ + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0', + 'templateRepository' => 'github.com/appwrite/templates', + 'templateOwner' => 'appwrite', + 'templateRootDirectory' => 'functions/node', + 'templateVersion' => '1.0.0' + ], + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0' ] ]; } - public static function functionsListExecutionsProvider(): array + public static function functionsListExecutionsProvider(): \Iterator { - return [ - 'remove search field' => [ - [ - 'functionId' => 'test-function', - 'search' => 'test query', - 'limit' => 10 - ], - [ - 'functionId' => 'test-function', - 'limit' => 10 - ] + yield 'remove search field' => [ + [ + 'functionId' => 'test-function', + 'search' => 'test query', + 'limit' => 10 + ], + [ + 'functionId' => 'test-function', + 'limit' => 10 ] ]; } diff --git a/tests/unit/Utopia/Request/Filters/V21Test.php b/tests/unit/Utopia/Request/Filters/V21Test.php index f514de71ee..fc766a383d 100644 --- a/tests/unit/Utopia/Request/Filters/V21Test.php +++ b/tests/unit/Utopia/Request/Filters/V21Test.php @@ -1,5 +1,7 @@ [ - [ - 'templateId' => 'template123', - 'version' => '1.0.0', - ], - [ - 'templateId' => 'template123', - 'type' => 'tag', - 'reference' => '1.0.0', - ] + yield 'convert version to type and reference' => [ + [ + 'templateId' => 'template123', + 'version' => '1.0.0', ], - 'handle version with semver string' => [ - [ - 'version' => 'v2.3.1', - 'templateId' => 'template456', - ], - [ - 'type' => 'tag', - 'reference' => 'v2.3.1', - 'templateId' => 'template456', - ] + [ + 'templateId' => 'template123', + 'type' => 'tag', + 'reference' => '1.0.0', + ] + ]; + yield 'handle version with semver string' => [ + [ + 'version' => 'v2.3.1', + 'templateId' => 'template456', ], - 'skip conversion when version is empty string' => [ - [ - 'templateId' => 'template123', - 'version' => '', - ], - [ - 'templateId' => 'template123', - 'version' => '', - ] + [ + 'type' => 'tag', + 'reference' => 'v2.3.1', + 'templateId' => 'template456', + ] + ]; + yield 'skip conversion when version is empty string' => [ + [ + 'templateId' => 'template123', + 'version' => '', ], - 'skip conversion when version is missing' => [ - [ - 'templateId' => 'template123', - ], - [ - 'templateId' => 'template123', - ] + [ + 'templateId' => 'template123', + 'version' => '', + ] + ]; + yield 'skip conversion when version is missing' => [ + [ + 'templateId' => 'template123', ], - 'preserve other fields when converting version' => [ - [ - 'templateId' => 'template123', - 'version' => '3.0.0', - 'activate' => true, - 'buildCommand' => 'npm run build', - ], - [ - 'templateId' => 'template123', - 'type' => 'tag', - 'reference' => '3.0.0', - 'activate' => true, - 'buildCommand' => 'npm run build', - ] + [ + 'templateId' => 'template123', + ] + ]; + yield 'preserve other fields when converting version' => [ + [ + 'templateId' => 'template123', + 'version' => '3.0.0', + 'activate' => true, + 'buildCommand' => 'npm run build', ], + [ + 'templateId' => 'template123', + 'type' => 'tag', + 'reference' => '3.0.0', + 'activate' => true, + 'buildCommand' => 'npm run build', + ] ]; } @@ -94,38 +94,36 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function sitesCreateTemplateDeploymentProvider(): array + public static function sitesCreateTemplateDeploymentProvider(): \Iterator { - return [ - 'convert version to type and reference' => [ - [ - 'templateId' => 'site-template123', - 'version' => '2.0.0', - ], - [ - 'templateId' => 'site-template123', - 'type' => 'tag', - 'reference' => '2.0.0', - ] + yield 'convert version to type and reference' => [ + [ + 'templateId' => 'site-template123', + 'version' => '2.0.0', ], - 'skip conversion when version is empty' => [ - [ - 'templateId' => 'site-template123', - 'version' => '', - ], - [ - 'templateId' => 'site-template123', - 'version' => '', - ] + [ + 'templateId' => 'site-template123', + 'type' => 'tag', + 'reference' => '2.0.0', + ] + ]; + yield 'skip conversion when version is empty' => [ + [ + 'templateId' => 'site-template123', + 'version' => '', ], - 'skip conversion when version is missing' => [ - [ - 'templateId' => 'site-template123', - ], - [ - 'templateId' => 'site-template123', - ] + [ + 'templateId' => 'site-template123', + 'version' => '', + ] + ]; + yield 'skip conversion when version is missing' => [ + [ + 'templateId' => 'site-template123', ], + [ + 'templateId' => 'site-template123', + ] ]; } @@ -139,59 +137,57 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function functionsCreateProvider(): array + public static function functionsCreateProvider(): \Iterator { - return [ - 'convert specification to buildSpecification and runtimeSpecification' => [ - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0', - 'specification' => 's-1vcpu-512mb', - ], - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-512mb', - ] + yield 'convert specification to buildSpecification and runtimeSpecification' => [ + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0', + 'specification' => 's-1vcpu-512mb', ], - 'skip conversion when specification is empty' => [ - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0', - 'specification' => '', - ], - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0', - 'specification' => '', - ] + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-512mb', + ] + ]; + yield 'skip conversion when specification is empty' => [ + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0', + 'specification' => '', ], - 'skip conversion when specification is missing' => [ - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0', - ], - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0', - ] + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0', + 'specification' => '', + ] + ]; + yield 'skip conversion when specification is missing' => [ + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0', ], - 'preserve other fields when converting specification' => [ - [ - 'name' => 'test-function', - 'specification' => 's-2vcpu-1gb', - 'timeout' => 30, - 'enabled' => true, - ], - [ - 'name' => 'test-function', - 'buildSpecification' => 's-2vcpu-1gb', - 'runtimeSpecification' => 's-2vcpu-1gb', - 'timeout' => 30, - 'enabled' => true, - ] + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0', + ] + ]; + yield 'preserve other fields when converting specification' => [ + [ + 'name' => 'test-function', + 'specification' => 's-2vcpu-1gb', + 'timeout' => 30, + 'enabled' => true, ], + [ + 'name' => 'test-function', + 'buildSpecification' => 's-2vcpu-1gb', + 'runtimeSpecification' => 's-2vcpu-1gb', + 'timeout' => 30, + 'enabled' => true, + ] ]; } @@ -205,40 +201,38 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function sitesCreateProvider(): array + public static function sitesCreateProvider(): \Iterator { - return [ - 'convert specification to buildSpecification and runtimeSpecification' => [ - [ - 'name' => 'test-site', - 'framework' => 'nextjs', - 'specification' => 's-1vcpu-512mb', - ], - [ - 'name' => 'test-site', - 'framework' => 'nextjs', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-512mb', - ] + yield 'convert specification to buildSpecification and runtimeSpecification' => [ + [ + 'name' => 'test-site', + 'framework' => 'nextjs', + 'specification' => 's-1vcpu-512mb', ], - 'skip conversion when specification is empty' => [ - [ - 'name' => 'test-site', - 'specification' => '', - ], - [ - 'name' => 'test-site', - 'specification' => '', - ] + [ + 'name' => 'test-site', + 'framework' => 'nextjs', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-512mb', + ] + ]; + yield 'skip conversion when specification is empty' => [ + [ + 'name' => 'test-site', + 'specification' => '', ], - 'skip conversion when specification is missing' => [ - [ - 'name' => 'test-site', - ], - [ - 'name' => 'test-site', - ] + [ + 'name' => 'test-site', + 'specification' => '', + ] + ]; + yield 'skip conversion when specification is missing' => [ + [ + 'name' => 'test-site', ], + [ + 'name' => 'test-site', + ] ]; } @@ -252,28 +246,26 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function functionsUpdateProvider(): array + public static function functionsUpdateProvider(): \Iterator { - return [ - 'convert specification to buildSpecification and runtimeSpecification' => [ - [ - 'name' => 'updated-function', - 'specification' => 's-2vcpu-1gb', - ], - [ - 'name' => 'updated-function', - 'buildSpecification' => 's-2vcpu-1gb', - 'runtimeSpecification' => 's-2vcpu-1gb', - ] + yield 'convert specification to buildSpecification and runtimeSpecification' => [ + [ + 'name' => 'updated-function', + 'specification' => 's-2vcpu-1gb', ], - 'skip conversion when specification is missing' => [ - [ - 'name' => 'updated-function', - ], - [ - 'name' => 'updated-function', - ] + [ + 'name' => 'updated-function', + 'buildSpecification' => 's-2vcpu-1gb', + 'runtimeSpecification' => 's-2vcpu-1gb', + ] + ]; + yield 'skip conversion when specification is missing' => [ + [ + 'name' => 'updated-function', ], + [ + 'name' => 'updated-function', + ] ]; } @@ -287,28 +279,26 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function sitesUpdateProvider(): array + public static function sitesUpdateProvider(): \Iterator { - return [ - 'convert specification to buildSpecification and runtimeSpecification' => [ - [ - 'name' => 'updated-site', - 'specification' => 's-2vcpu-1gb', - ], - [ - 'name' => 'updated-site', - 'buildSpecification' => 's-2vcpu-1gb', - 'runtimeSpecification' => 's-2vcpu-1gb', - ] + yield 'convert specification to buildSpecification and runtimeSpecification' => [ + [ + 'name' => 'updated-site', + 'specification' => 's-2vcpu-1gb', ], - 'skip conversion when specification is missing' => [ - [ - 'name' => 'updated-site', - ], - [ - 'name' => 'updated-site', - ] + [ + 'name' => 'updated-site', + 'buildSpecification' => 's-2vcpu-1gb', + 'runtimeSpecification' => 's-2vcpu-1gb', + ] + ]; + yield 'skip conversion when specification is missing' => [ + [ + 'name' => 'updated-site', ], + [ + 'name' => 'updated-site', + ] ]; } @@ -322,47 +312,45 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function unmatchedModelProvider(): array + public static function unmatchedModelProvider(): \Iterator { - return [ - 'unmatched model passes through unchanged' => [ - 'databases.create', - [ - 'name' => 'test-database', - 'databaseId' => 'db123', - ], - [ - 'name' => 'test-database', - 'databaseId' => 'db123', - ] + yield 'unmatched model passes through unchanged' => [ + 'databases.create', + [ + 'name' => 'test-database', + 'databaseId' => 'db123', ], - 'empty content for unmatched model' => [ - 'users.list', - [], - [] + [ + 'name' => 'test-database', + 'databaseId' => 'db123', + ] + ]; + yield 'empty content for unmatched model' => [ + 'users.list', + [], + [] + ]; + yield 'content with specification for unmatched model is not converted' => [ + 'deployments.create', + [ + 'specification' => 's-1vcpu-512mb', + 'name' => 'test', ], - 'content with specification for unmatched model is not converted' => [ - 'deployments.create', - [ - 'specification' => 's-1vcpu-512mb', - 'name' => 'test', - ], - [ - 'specification' => 's-1vcpu-512mb', - 'name' => 'test', - ] - ], - 'content with version for unmatched model is not converted' => [ - 'databases.createDocument', - [ - 'version' => '1.0.0', - 'data' => 'test', - ], - [ - 'version' => '1.0.0', - 'data' => 'test', - ] + [ + 'specification' => 's-1vcpu-512mb', + 'name' => 'test', + ] + ]; + yield 'content with version for unmatched model is not converted' => [ + 'databases.createDocument', + [ + 'version' => '1.0.0', + 'data' => 'test', ], + [ + 'version' => '1.0.0', + 'data' => 'test', + ] ]; } diff --git a/tests/unit/Utopia/RequestTest.php b/tests/unit/Utopia/RequestTest.php index 2247ff71f1..c6a082d7fc 100644 --- a/tests/unit/Utopia/RequestTest.php +++ b/tests/unit/Utopia/RequestTest.php @@ -1,5 +1,7 @@ [ - [ - 'buildLogs' => 'Compiling source files...', - ], - [ - 'buildStdout' => 'Compiling source files...', - 'buildStderr' => '', - ], + yield 'buildStdout and buildStderr' => [ + [ + 'buildLogs' => 'Compiling source files...', ], - 'size and buildSize' => [ - [ - 'size' => 20, - 'buildSize' => 40 - ], - [ - 'size' => 60 - ], + [ + 'buildStdout' => 'Compiling source files...', + 'buildStderr' => '', ], - - 'size and buildSize missing' => [ - [ - 'size' => 20 - ], - [ - 'size' => 20 - ], + ]; + yield 'size and buildSize' => [ + [ + 'size' => 20, + 'buildSize' => 40 ], - - 'empty no errors' => [ - [ - ], - [ - ], + [ + 'size' => 60 + ], + ]; + yield 'size and buildSize missing' => [ + [ + 'size' => 20 + ], + [ + 'size' => 20 + ], + ]; + yield 'empty no errors' => [ + [ + ], + [ ], ]; } @@ -73,40 +71,38 @@ class V16Test extends TestCase $this->assertEquals($expected, $result); } - public static function executionProvider(): array + public static function executionProvider(): \Iterator { - return [ - 'statusCode' => [ - [ - 'responseStatusCode' => 200, - ], - [ - 'statusCode' => 200, - ], + yield 'statusCode' => [ + [ + 'responseStatusCode' => 200, ], - 'response' => [ - [ - 'responseBody' => 'Sample response.', - ], - [ - 'response' => 'Sample response.', - ], + [ + 'statusCode' => 200, ], - 'stdout' => [ - [ - 'logs' => 'Sample log.', - ], - [ - 'stdout' => 'Sample log.', - ], + ]; + yield 'response' => [ + [ + 'responseBody' => 'Sample response.', ], - 'stderr' => [ - [ - 'errors' => 'Sample error.', - ], - [ - 'stderr' => 'Sample error.', - ], + [ + 'response' => 'Sample response.', + ], + ]; + yield 'stdout' => [ + [ + 'logs' => 'Sample log.', + ], + [ + 'stdout' => 'Sample log.', + ], + ]; + yield 'stderr' => [ + [ + 'errors' => 'Sample error.', + ], + [ + 'stderr' => 'Sample error.', ], ]; } @@ -121,18 +117,16 @@ class V16Test extends TestCase $this->assertEquals($expected, $result); } - public static function functionProvider(): array + public static function functionProvider(): \Iterator { - return [ - 'empty schedule' => [ - [ - 'schedule' => '', - ], - [ - 'schedule' => '', - 'schedulePrevious' => '', - 'scheduleNext' => '', - ], + yield 'empty schedule' => [ + [ + 'schedule' => '', + ], + [ + 'schedule' => '', + 'schedulePrevious' => '', + 'scheduleNext' => '', ], ]; } @@ -168,39 +162,37 @@ class V16Test extends TestCase $this->assertEquals($expected, $result); } - public static function projectProvider(): array + public static function projectProvider(): \Iterator { - return [ - 'oAuthProviders' => [ - [ - 'oAuthProviders' => [ - [ - 'key' => 'github', - 'name' => 'GitHub', - 'appId' => 'client_id', - 'secret' => 'client_secret', - 'enabled' => true, - ], + yield 'oAuthProviders' => [ + [ + 'oAuthProviders' => [ + [ + 'key' => 'github', + 'name' => 'GitHub', + 'appId' => 'client_id', + 'secret' => 'client_secret', + 'enabled' => true, ], ], - [ - 'oAuthProviders' => [ - [ - 'name' => 'Github', - 'appId' => 'client_id', - 'secret' => 'client_secret', - 'enabled' => true, - ], - ], - 'domains' => [], - ], ], - 'domains' => [ - [ - ], - [ - 'domains' => [], + [ + 'oAuthProviders' => [ + [ + 'name' => 'Github', + 'appId' => 'client_id', + 'secret' => 'client_secret', + 'enabled' => true, + ], ], + 'domains' => [], + ], + ]; + yield 'domains' => [ + [ + ], + [ + 'domains' => [], ], ]; } @@ -215,16 +207,14 @@ class V16Test extends TestCase $this->assertEquals($expected, $result); } - public static function variableProvider(): array + public static function variableProvider(): \Iterator { - return [ - 'functionId' => [ - [ - 'resourceId' => '5e5ea5c16897e', - ], - [ - 'functionId' => '5e5ea5c16897e', - ], + yield 'functionId' => [ + [ + 'resourceId' => '5e5ea5c16897e', + ], + [ + 'functionId' => '5e5ea5c16897e', ], ]; } diff --git a/tests/unit/Utopia/Response/Filters/V17Test.php b/tests/unit/Utopia/Response/Filters/V17Test.php index 0bdc4de53e..ffc4bcdf14 100644 --- a/tests/unit/Utopia/Response/Filters/V17Test.php +++ b/tests/unit/Utopia/Response/Filters/V17Test.php @@ -1,5 +1,7 @@ [ - [ - 'oAuthProviders' => [ - [ - 'key' => 'github', - 'name' => 'GitHub', - 'appId' => 'client_id', - 'secret' => 'client_secret', - 'enabled' => true, - ], + yield 'rename providers' => [ + [ + 'oAuthProviders' => [ + [ + 'key' => 'github', + 'name' => 'GitHub', + 'appId' => 'client_id', + 'secret' => 'client_secret', + 'enabled' => true, ], ], - [ - 'providers' => [ - [ - 'key' => 'github', - 'name' => 'GitHub', - 'appId' => 'client_id', - 'secret' => 'client_secret', - 'enabled' => true, - ], + ], + [ + 'providers' => [ + [ + 'key' => 'github', + 'name' => 'GitHub', + 'appId' => 'client_id', + 'secret' => 'client_secret', + 'enabled' => true, ], ], ], @@ -61,16 +61,14 @@ class V17Test extends TestCase $this->assertEquals($expected, $result); } - public static function userProvider(): array + public static function userProvider(): \Iterator { - return [ - 'remove targets' => [ - [ - 'targets' => 'test', - 'mfa' => 'test', - ], - [ - ], + yield 'remove targets' => [ + [ + 'targets' => 'test', + 'mfa' => 'test', + ], + [ ], ]; } @@ -85,15 +83,13 @@ class V17Test extends TestCase $this->assertEquals($expected, $result); } - public static function tokenProvider(): array + public static function tokenProvider(): \Iterator { - return [ - 'remove securityPhrase' => [ - [ - 'phrase' => 'Lorum Ipsum', - ], - [ - ], + yield 'remove securityPhrase' => [ + [ + 'phrase' => 'Lorum Ipsum', + ], + [ ], ]; } @@ -108,15 +104,13 @@ class V17Test extends TestCase $this->assertEquals($expected, $result); } - public static function membershipProvider(): array + public static function membershipProvider(): \Iterator { - return [ - 'remove mfa' => [ - [ - 'mfa' => 'test', - ], - [ - ], + yield 'remove mfa' => [ + [ + 'mfa' => 'test', + ], + [ ], ]; } @@ -131,17 +125,15 @@ class V17Test extends TestCase $this->assertEquals($expected, $result); } - public static function sessionProvider(): array + public static function sessionProvider(): \Iterator { - return [ - 'remove factors and secrets' => [ - [ - 'factors' => 'test', - 'secret' => 'test', - ], - [ - ], - ] + yield 'remove factors and secrets' => [ + [ + 'factors' => 'test', + 'secret' => 'test', + ], + [ + ], ]; } diff --git a/tests/unit/Utopia/Response/Filters/V18Test.php b/tests/unit/Utopia/Response/Filters/V18Test.php index 2e09b34515..fdef9c592a 100644 --- a/tests/unit/Utopia/Response/Filters/V18Test.php +++ b/tests/unit/Utopia/Response/Filters/V18Test.php @@ -1,5 +1,7 @@ [ - [ - 'scopes' => [ - 'example_scope', - 'example_scope2', - ], + yield 'remove scopes' => [ + [ + 'scopes' => [ + 'example_scope', + 'example_scope2', ], - [ - ] ], + [ + ] ]; } @@ -48,55 +48,53 @@ class V18Test extends TestCase } - public static function executionProvider(): array + public static function executionProvider(): \Iterator { - return [ - 'remove scheduledAt' => [ - [ - 'scheduledAt' => '2024-07-13T09:00:00.000Z', - ], - [ - ] + yield 'remove scheduledAt' => [ + [ + 'scheduledAt' => '2024-07-13T09:00:00.000Z', ], - 'update 404 status' => [ - [ - 'statusCode' => '404', - 'status' => 'completed' - ], - [ - 'statusCode' => '404', - 'status' => 'failed' - ] + [ + ] + ]; + yield 'update 404 status' => [ + [ + 'statusCode' => '404', + 'status' => 'completed' ], - 'update 400 status' => [ - [ - 'statusCode' => '400', - 'status' => 'completed' - ], - [ - 'statusCode' => '400', - 'status' => 'failed' - ] + [ + 'statusCode' => '404', + 'status' => 'failed' + ] + ]; + yield 'update 400 status' => [ + [ + 'statusCode' => '400', + 'status' => 'completed' ], - 'dont update 200 status' => [ - [ - 'statusCode' => '200', - 'status' => 'completed' - ], - [ - 'statusCode' => '200', - 'status' => 'completed' - ] + [ + 'statusCode' => '400', + 'status' => 'failed' + ] + ]; + yield 'dont update 200 status' => [ + [ + 'statusCode' => '200', + 'status' => 'completed' ], - 'dont update 500 status' => [ - [ - 'statusCode' => '500', - 'status' => 'failed' - ], - [ - 'statusCode' => '500', - 'status' => 'failed' - ] + [ + 'statusCode' => '200', + 'status' => 'completed' + ] + ]; + yield 'dont update 500 status' => [ + [ + 'statusCode' => '500', + 'status' => 'failed' + ], + [ + 'statusCode' => '500', + 'status' => 'failed' ] ]; } @@ -111,22 +109,20 @@ class V18Test extends TestCase $this->assertEquals($expected, $result); } - public static function projectProvider(): array + public static function projectProvider(): \Iterator { - return [ - 'remove authMockNumbers and authSessionAlerts' => [ - [ - 'authMockNumbers' => [ - 'example_mock_number', - 'example_mock_number2', - ], - 'authSessionAlerts' => [ - 'example_alert', - 'example_alert2', - ], + yield 'remove authMockNumbers and authSessionAlerts' => [ + [ + 'authMockNumbers' => [ + 'example_mock_number', + 'example_mock_number2', ], - [ - ] + 'authSessionAlerts' => [ + 'example_alert', + 'example_alert2', + ], + ], + [ ] ]; } @@ -141,15 +137,13 @@ class V18Test extends TestCase $this->assertEquals($expected, $result); } - public static function runtimeProvider(): array + public static function runtimeProvider(): \Iterator { - return [ - 'remove key' => [ - [ - 'key' => 'example_key', - ], - [ - ] + yield 'remove key' => [ + [ + 'key' => 'example_key', + ], + [ ] ]; } diff --git a/tests/unit/Utopia/Response/Filters/V19Test.php b/tests/unit/Utopia/Response/Filters/V19Test.php index a53dbfe355..830fa3d0c1 100644 --- a/tests/unit/Utopia/Response/Filters/V19Test.php +++ b/tests/unit/Utopia/Response/Filters/V19Test.php @@ -1,5 +1,7 @@ [ - [ - 'deploymentId' => 'deployment123', - ], - [ - 'deployment' => 'deployment123', - ] + yield 'change deploymentId to deployment' => [ + [ + 'deploymentId' => 'deployment123', ], - 'handle empty deploymentId' => [ - [ - 'name' => 'test-function', - ], - [ - 'deployment' => '', - 'name' => 'test-function', - ] + [ + 'deployment' => 'deployment123', + ] + ]; + yield 'handle empty deploymentId' => [ + [ + 'name' => 'test-function', ], + [ + 'deployment' => '', + 'name' => 'test-function', + ] ]; } @@ -54,47 +54,45 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function functionListProvider(): array + public static function functionListProvider(): \Iterator { - return [ - 'convert list of functions' => [ - [ - 'total' => 2, - 'functions' => [ - [ - 'deploymentId' => 'deployment123', - 'name' => 'function-1', - ], - [ - 'deploymentId' => 'deployment456', - 'name' => 'function-2', - ], + yield 'convert list of functions' => [ + [ + 'total' => 2, + 'functions' => [ + [ + 'deploymentId' => 'deployment123', + 'name' => 'function-1', + ], + [ + 'deploymentId' => 'deployment456', + 'name' => 'function-2', ], ], - [ - 'total' => 2, - 'functions' => [ - [ - 'deployment' => 'deployment123', - 'name' => 'function-1', - ], - [ - 'deployment' => 'deployment456', - 'name' => 'function-2', - ], + ], + [ + 'total' => 2, + 'functions' => [ + [ + 'deployment' => 'deployment123', + 'name' => 'function-1', + ], + [ + 'deployment' => 'deployment456', + 'name' => 'function-2', ], - ] - ], - 'handle empty function list' => [ - [ - 'total' => 0, - 'functions' => [], ], - [ - 'total' => 0, - 'functions' => [], - ] + ] + ]; + yield 'handle empty function list' => [ + [ + 'total' => 0, + 'functions' => [], ], + [ + 'total' => 0, + 'functions' => [], + ] ]; } @@ -108,31 +106,29 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function deploymentProvider(): array + public static function deploymentProvider(): \Iterator { - return [ - 'rename sourceSize to size and buildDuration to buildTime' => [ - [ - 'sourceSize' => 1024, - 'buildDuration' => 60, - 'id' => 'deployment123', - ], - [ - 'size' => 1024, - 'buildTime' => 60, - 'id' => 'deployment123', - ] + yield 'rename sourceSize to size and buildDuration to buildTime' => [ + [ + 'sourceSize' => 1024, + 'buildDuration' => 60, + 'id' => 'deployment123', ], - 'handle missing sourceSize and buildDuration' => [ - [ - 'id' => 'deployment123', - ], - [ - 'size' => '', - 'buildTime' => '', - 'id' => 'deployment123', - ] + [ + 'size' => 1024, + 'buildTime' => 60, + 'id' => 'deployment123', + ] + ]; + yield 'handle missing sourceSize and buildDuration' => [ + [ + 'id' => 'deployment123', ], + [ + 'size' => '', + 'buildTime' => '', + 'id' => 'deployment123', + ] ]; } @@ -146,31 +142,29 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function proxyRuleProvider(): array + public static function proxyRuleProvider(): \Iterator { - return [ - 'rename deployment resource fields' => [ - [ - 'deploymentResourceType' => 'function', - 'deploymentResourceId' => 'func123', - 'domain' => 'example.com', - ], - [ - 'resourceType' => 'function', - 'resourceId' => 'func123', - 'domain' => 'example.com', - ] + yield 'rename deployment resource fields' => [ + [ + 'deploymentResourceType' => 'function', + 'deploymentResourceId' => 'func123', + 'domain' => 'example.com', ], - 'handle missing deployment resource fields' => [ - [ - 'domain' => 'example.com', - ], - [ - 'resourceType' => '', - 'resourceId' => '', - 'domain' => 'example.com', - ] + [ + 'resourceType' => 'function', + 'resourceId' => 'func123', + 'domain' => 'example.com', + ] + ]; + yield 'handle missing deployment resource fields' => [ + [ + 'domain' => 'example.com', ], + [ + 'resourceType' => '', + 'resourceId' => '', + 'domain' => 'example.com', + ] ]; } @@ -184,26 +178,24 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function migrationProvider(): array + public static function migrationProvider(): \Iterator { - return [ - 'remove resourceId field' => [ - [ - 'resourceId' => 'resource123', - 'status' => 'completed', - ], - [ - 'status' => 'completed', - ] + yield 'remove resourceId field' => [ + [ + 'resourceId' => 'resource123', + 'status' => 'completed', ], - 'handle content without resourceId' => [ - [ - 'status' => 'completed', - ], - [ - 'status' => 'completed', - ] + [ + 'status' => 'completed', + ] + ]; + yield 'handle content without resourceId' => [ + [ + 'status' => 'completed', ], + [ + 'status' => 'completed', + ] ]; } @@ -217,26 +209,24 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function projectProvider(): array + public static function projectProvider(): \Iterator { - return [ - 'remove devKeys field' => [ - [ - 'devKeys' => ['key1', 'key2'], - 'name' => 'test-project', - ], - [ - 'name' => 'test-project', - ] + yield 'remove devKeys field' => [ + [ + 'devKeys' => ['key1', 'key2'], + 'name' => 'test-project', ], - 'handle content without devKeys' => [ - [ - 'name' => 'test-project', - ], - [ - 'name' => 'test-project', - ] + [ + 'name' => 'test-project', + ] + ]; + yield 'handle content without devKeys' => [ + [ + 'name' => 'test-project', ], + [ + 'name' => 'test-project', + ] ]; } @@ -250,26 +240,24 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function providerRepositoryProvider(): array + public static function providerRepositoryProvider(): \Iterator { - return [ - 'remove runtime field' => [ - [ - 'runtime' => 'nodejs', - 'name' => 'test-repo', - ], - [ - 'name' => 'test-repo', - ] + yield 'remove runtime field' => [ + [ + 'runtime' => 'nodejs', + 'name' => 'test-repo', ], - 'handle content without runtime' => [ - [ - 'name' => 'test-repo', - ], - [ - 'name' => 'test-repo', - ] + [ + 'name' => 'test-repo', + ] + ]; + yield 'handle content without runtime' => [ + [ + 'name' => 'test-repo', ], + [ + 'name' => 'test-repo', + ] ]; } @@ -283,26 +271,24 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function templateVariableProvider(): array + public static function templateVariableProvider(): \Iterator { - return [ - 'remove secret field' => [ - [ - 'secret' => 'secret-value', - 'name' => 'test-variable', - ], - [ - 'name' => 'test-variable', - ] + yield 'remove secret field' => [ + [ + 'secret' => 'secret-value', + 'name' => 'test-variable', ], - 'handle content without secret' => [ - [ - 'name' => 'test-variable', - ], - [ - 'name' => 'test-variable', - ] + [ + 'name' => 'test-variable', + ] + ]; + yield 'handle content without secret' => [ + [ + 'name' => 'test-variable', ], + [ + 'name' => 'test-variable', + ] ]; } @@ -316,30 +302,28 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function usageFunctionProvider(): array + public static function usageFunctionProvider(): \Iterator { - return [ - 'remove build-related fields' => [ - [ - 'buildsSuccessTotal' => 10, - 'buildsFailedTotal' => 2, - 'buildsTimeAverage' => 30, - 'buildsSuccess' => 5, - 'buildsFailed' => 1, - 'executions' => 100, - ], - [ - 'executions' => 100, - ] + yield 'remove build-related fields' => [ + [ + 'buildsSuccessTotal' => 10, + 'buildsFailedTotal' => 2, + 'buildsTimeAverage' => 30, + 'buildsSuccess' => 5, + 'buildsFailed' => 1, + 'executions' => 100, ], - 'handle content without build fields' => [ - [ - 'executions' => 100, - ], - [ - 'executions' => 100, - ] + [ + 'executions' => 100, + ] + ]; + yield 'handle content without build fields' => [ + [ + 'executions' => 100, ], + [ + 'executions' => 100, + ] ]; } @@ -353,29 +337,27 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function usageFunctionsProvider(): array + public static function usageFunctionsProvider(): \Iterator { - return [ - 'remove build-related fields' => [ - [ - 'buildsSuccessTotal' => 20, - 'buildsFailedTotal' => 4, - 'buildsSuccess' => 10, - 'buildsFailed' => 2, - 'executions' => 200, - ], - [ - 'executions' => 200, - ] + yield 'remove build-related fields' => [ + [ + 'buildsSuccessTotal' => 20, + 'buildsFailedTotal' => 4, + 'buildsSuccess' => 10, + 'buildsFailed' => 2, + 'executions' => 200, ], - 'handle content without build fields' => [ - [ - 'executions' => 200, - ], - [ - 'executions' => 200, - ] + [ + 'executions' => 200, + ] + ]; + yield 'handle content without build fields' => [ + [ + 'executions' => 200, ], + [ + 'executions' => 200, + ] ]; } @@ -389,26 +371,24 @@ class V19Test extends TestCase $this->assertEquals($expected, $result); } - public static function variableProvider(): array + public static function variableProvider(): \Iterator { - return [ - 'remove secret field' => [ - [ - 'secret' => 'secret-value', - 'name' => 'test-variable', - ], - [ - 'name' => 'test-variable', - ] + yield 'remove secret field' => [ + [ + 'secret' => 'secret-value', + 'name' => 'test-variable', ], - 'handle content without secret' => [ - [ - 'name' => 'test-variable', - ], - [ - 'name' => 'test-variable', - ] + [ + 'name' => 'test-variable', + ] + ]; + yield 'handle content without secret' => [ + [ + 'name' => 'test-variable', ], + [ + 'name' => 'test-variable', + ] ]; } diff --git a/tests/unit/Utopia/Response/Filters/V21Test.php b/tests/unit/Utopia/Response/Filters/V21Test.php index a049b70d84..6c7aacab58 100644 --- a/tests/unit/Utopia/Response/Filters/V21Test.php +++ b/tests/unit/Utopia/Response/Filters/V21Test.php @@ -1,5 +1,7 @@ [ - [ - 'name' => 'test-function', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - 'runtime' => 'node-18.0', - ], - [ - 'name' => 'test-function', - 'specification' => 's-1vcpu-512mb', - 'runtime' => 'node-18.0', - ] + yield 'merge buildSpecification and runtimeSpecification into specification' => [ + [ + 'name' => 'test-function', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', + 'runtime' => 'node-18.0', ], - 'use buildSpecification when present' => [ - [ - 'buildSpecification' => 's-2vcpu-1gb', - 'runtimeSpecification' => 's-1vcpu-512mb', - ], - [ - 'specification' => 's-2vcpu-1gb', - ] + [ + 'name' => 'test-function', + 'specification' => 's-1vcpu-512mb', + 'runtime' => 'node-18.0', + ] + ]; + yield 'use buildSpecification when present' => [ + [ + 'buildSpecification' => 's-2vcpu-1gb', + 'runtimeSpecification' => 's-1vcpu-512mb', ], - 'fallback to specification when buildSpecification is missing' => [ - [ - 'specification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], - [ - 'specification' => 's-1vcpu-512mb', - ] + [ + 'specification' => 's-2vcpu-1gb', + ] + ]; + yield 'fallback to specification when buildSpecification is missing' => [ + [ + 'specification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', ], - 'handle missing both buildSpecification and specification' => [ - [ - 'name' => 'test-function', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], - [ - 'name' => 'test-function', - 'specification' => null, - ] + [ + 'specification' => 's-1vcpu-512mb', + ] + ]; + yield 'handle missing both buildSpecification and specification' => [ + [ + 'name' => 'test-function', + 'runtimeSpecification' => 's-1vcpu-256mb', ], - 'handle no spec fields at all' => [ - [ - 'name' => 'test-function', - 'runtime' => 'node-18.0', - ], - [ - 'name' => 'test-function', - 'specification' => null, - 'runtime' => 'node-18.0', - ] + [ + 'name' => 'test-function', + 'specification' => null, + ] + ]; + yield 'handle no spec fields at all' => [ + [ + 'name' => 'test-function', + 'runtime' => 'node-18.0', ], - 'handle empty buildSpecification string' => [ - [ - 'buildSpecification' => '', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], - [ - 'specification' => '', - ] + [ + 'name' => 'test-function', + 'specification' => null, + 'runtime' => 'node-18.0', + ] + ]; + yield 'handle empty buildSpecification string' => [ + [ + 'buildSpecification' => '', + 'runtimeSpecification' => 's-1vcpu-256mb', ], + [ + 'specification' => '', + ] ]; } @@ -97,68 +97,66 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function functionListProvider(): array + public static function functionListProvider(): \Iterator { - return [ - 'convert list of functions' => [ - [ - 'total' => 2, - 'functions' => [ - [ - 'name' => 'function-1', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], - [ - 'name' => 'function-2', - 'buildSpecification' => 's-2vcpu-1gb', - 'runtimeSpecification' => 's-1vcpu-512mb', - ], + yield 'convert list of functions' => [ + [ + 'total' => 2, + 'functions' => [ + [ + 'name' => 'function-1', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', + ], + [ + 'name' => 'function-2', + 'buildSpecification' => 's-2vcpu-1gb', + 'runtimeSpecification' => 's-1vcpu-512mb', ], ], - [ - 'total' => 2, - 'functions' => [ - [ - 'name' => 'function-1', - 'specification' => 's-1vcpu-512mb', - ], - [ - 'name' => 'function-2', - 'specification' => 's-2vcpu-1gb', - ], + ], + [ + 'total' => 2, + 'functions' => [ + [ + 'name' => 'function-1', + 'specification' => 's-1vcpu-512mb', ], - ] - ], - 'handle empty function list' => [ - [ - 'total' => 0, - 'functions' => [], - ], - [ - 'total' => 0, - 'functions' => [], - ] - ], - 'handle single function in list' => [ - [ - 'total' => 1, - 'functions' => [ - [ - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], + [ + 'name' => 'function-2', + 'specification' => 's-2vcpu-1gb', ], ], - [ - 'total' => 1, - 'functions' => [ - [ - 'specification' => 's-1vcpu-512mb', - ], - ], - ] + ] + ]; + yield 'handle empty function list' => [ + [ + 'total' => 0, + 'functions' => [], ], + [ + 'total' => 0, + 'functions' => [], + ] + ]; + yield 'handle single function in list' => [ + [ + 'total' => 1, + 'functions' => [ + [ + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', + ], + ], + ], + [ + 'total' => 1, + 'functions' => [ + [ + 'specification' => 's-1vcpu-512mb', + ], + ], + ] ]; } @@ -172,61 +170,59 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function siteProvider(): array + public static function siteProvider(): \Iterator { - return [ - 'merge buildSpecification and runtimeSpecification into specification' => [ - [ - 'name' => 'test-site', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - 'framework' => 'nextjs', - ], - [ - 'name' => 'test-site', - 'specification' => 's-1vcpu-512mb', - 'framework' => 'nextjs', - ] + yield 'merge buildSpecification and runtimeSpecification into specification' => [ + [ + 'name' => 'test-site', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', + 'framework' => 'nextjs', ], - 'use buildSpecification when present' => [ - [ - 'buildSpecification' => 's-2vcpu-1gb', - 'runtimeSpecification' => 's-1vcpu-512mb', - ], - [ - 'specification' => 's-2vcpu-1gb', - ] + [ + 'name' => 'test-site', + 'specification' => 's-1vcpu-512mb', + 'framework' => 'nextjs', + ] + ]; + yield 'use buildSpecification when present' => [ + [ + 'buildSpecification' => 's-2vcpu-1gb', + 'runtimeSpecification' => 's-1vcpu-512mb', ], - 'fallback to specification when buildSpecification is missing' => [ - [ - 'specification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], - [ - 'specification' => 's-1vcpu-512mb', - ] + [ + 'specification' => 's-2vcpu-1gb', + ] + ]; + yield 'fallback to specification when buildSpecification is missing' => [ + [ + 'specification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', ], - 'handle missing both buildSpecification and specification' => [ - [ - 'name' => 'test-site', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], - [ - 'name' => 'test-site', - 'specification' => null, - ] + [ + 'specification' => 's-1vcpu-512mb', + ] + ]; + yield 'handle missing both buildSpecification and specification' => [ + [ + 'name' => 'test-site', + 'runtimeSpecification' => 's-1vcpu-256mb', ], - 'handle no spec fields at all' => [ - [ - 'name' => 'test-site', - 'framework' => 'react', - ], - [ - 'name' => 'test-site', - 'specification' => null, - 'framework' => 'react', - ] + [ + 'name' => 'test-site', + 'specification' => null, + ] + ]; + yield 'handle no spec fields at all' => [ + [ + 'name' => 'test-site', + 'framework' => 'react', ], + [ + 'name' => 'test-site', + 'specification' => null, + 'framework' => 'react', + ] ]; } @@ -240,70 +236,68 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function siteListProvider(): array + public static function siteListProvider(): \Iterator { - return [ - 'convert list of sites' => [ - [ - 'total' => 2, - 'sites' => [ - [ - 'name' => 'site-1', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], - [ - 'name' => 'site-2', - 'buildSpecification' => 's-2vcpu-1gb', - 'runtimeSpecification' => 's-1vcpu-512mb', - ], + yield 'convert list of sites' => [ + [ + 'total' => 2, + 'sites' => [ + [ + 'name' => 'site-1', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', + ], + [ + 'name' => 'site-2', + 'buildSpecification' => 's-2vcpu-1gb', + 'runtimeSpecification' => 's-1vcpu-512mb', ], ], - [ - 'total' => 2, - 'sites' => [ - [ - 'name' => 'site-1', - 'specification' => 's-1vcpu-512mb', - ], - [ - 'name' => 'site-2', - 'specification' => 's-2vcpu-1gb', - ], + ], + [ + 'total' => 2, + 'sites' => [ + [ + 'name' => 'site-1', + 'specification' => 's-1vcpu-512mb', ], - ] - ], - 'handle empty site list' => [ - [ - 'total' => 0, - 'sites' => [], - ], - [ - 'total' => 0, - 'sites' => [], - ] - ], - 'handle single site in list' => [ - [ - 'total' => 1, - 'sites' => [ - [ - 'name' => 'my-site', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], + [ + 'name' => 'site-2', + 'specification' => 's-2vcpu-1gb', ], ], - [ - 'total' => 1, - 'sites' => [ - [ - 'name' => 'my-site', - 'specification' => 's-1vcpu-512mb', - ], - ], - ] + ] + ]; + yield 'handle empty site list' => [ + [ + 'total' => 0, + 'sites' => [], ], + [ + 'total' => 0, + 'sites' => [], + ] + ]; + yield 'handle single site in list' => [ + [ + 'total' => 1, + 'sites' => [ + [ + 'name' => 'my-site', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', + ], + ], + ], + [ + 'total' => 1, + 'sites' => [ + [ + 'name' => 'my-site', + 'specification' => 's-1vcpu-512mb', + ], + ], + ] ]; } @@ -317,111 +311,109 @@ class V21Test extends TestCase $this->assertEquals($expected, $result); } - public static function documentProvider(): array + public static function documentProvider(): \Iterator { - return [ - 'cast $sequence to int' => [ - [ - '$id' => 'doc1', - '$sequence' => '123', - 'name' => 'test', - ], - [ - '$id' => 'doc1', - '$sequence' => 123, - 'name' => 'test', - ] + yield 'cast $sequence to int' => [ + [ + '$id' => 'doc1', + '$sequence' => '123', + 'name' => 'test', ], - 'non-numeric $sequence becomes 0' => [ - [ - '$id' => 'doc1', - '$sequence' => 'abc', - ], - [ - '$id' => 'doc1', - '$sequence' => 0, - ] + [ + '$id' => 'doc1', + '$sequence' => 123, + 'name' => 'test', + ] + ]; + yield 'non-numeric $sequence becomes 0' => [ + [ + '$id' => 'doc1', + '$sequence' => 'abc', ], - 'nested relationship document' => [ - [ - '$id' => 'doc1', - '$sequence' => '1', - 'author' => [ + [ + '$id' => 'doc1', + '$sequence' => 0, + ] + ]; + yield 'nested relationship document' => [ + [ + '$id' => 'doc1', + '$sequence' => '1', + 'author' => [ + '$id' => 'doc2', + '$sequence' => '2', + 'name' => 'John', + ], + ], + [ + '$id' => 'doc1', + '$sequence' => 1, + 'author' => [ + '$id' => 'doc2', + '$sequence' => 2, + 'name' => 'John', + ], + ] + ]; + yield 'nested array of relationship documents' => [ + [ + '$id' => 'doc1', + '$sequence' => '1', + 'comments' => [ + [ '$id' => 'doc2', '$sequence' => '2', - 'name' => 'John', + 'text' => 'hello', + ], + [ + '$id' => 'doc3', + '$sequence' => '3', + 'text' => 'world', ], ], - [ - '$id' => 'doc1', - '$sequence' => 1, - 'author' => [ + ], + [ + '$id' => 'doc1', + '$sequence' => 1, + 'comments' => [ + [ '$id' => 'doc2', '$sequence' => 2, - 'name' => 'John', + 'text' => 'hello', ], - ] - ], - 'nested array of relationship documents' => [ - [ - '$id' => 'doc1', - '$sequence' => '1', - 'comments' => [ - [ - '$id' => 'doc2', - '$sequence' => '2', - 'text' => 'hello', - ], - [ - '$id' => 'doc3', - '$sequence' => '3', - 'text' => 'world', - ], + [ + '$id' => 'doc3', + '$sequence' => 3, + 'text' => 'world', ], ], - [ - '$id' => 'doc1', - '$sequence' => 1, - 'comments' => [ - [ - '$id' => 'doc2', - '$sequence' => 2, - 'text' => 'hello', - ], - [ - '$id' => 'doc3', - '$sequence' => 3, - 'text' => 'world', - ], - ], - ] - ], - 'deeply nested relationships' => [ - [ - '$id' => 'doc1', - '$sequence' => '1', - 'author' => [ - '$id' => 'doc2', - '$sequence' => '2', - 'profile' => [ - '$id' => 'doc3', - '$sequence' => '3', - ], + ] + ]; + yield 'deeply nested relationships' => [ + [ + '$id' => 'doc1', + '$sequence' => '1', + 'author' => [ + '$id' => 'doc2', + '$sequence' => '2', + 'profile' => [ + '$id' => 'doc3', + '$sequence' => '3', ], ], - [ - '$id' => 'doc1', - '$sequence' => 1, - 'author' => [ - '$id' => 'doc2', - '$sequence' => 2, - 'profile' => [ - '$id' => 'doc3', - '$sequence' => 3, - ], - ], - ] ], + [ + '$id' => 'doc1', + '$sequence' => 1, + 'author' => [ + '$id' => 'doc2', + '$sequence' => 2, + 'profile' => [ + '$id' => 'doc3', + '$sequence' => 3, + ], + ], + ] ]; } @@ -441,51 +433,49 @@ class V21Test extends TestCase $this->assertSame($expected, $result); } - public static function documentListProvider(): array + public static function documentListProvider(): \Iterator { - return [ - 'cast $sequence in document list' => [ - [ - 'total' => 2, - 'documents' => [ - [ - '$id' => 'doc1', - '$sequence' => '10', - 'name' => 'first', - ], - [ - '$id' => 'doc2', - '$sequence' => '20', - 'name' => 'second', - ], + yield 'cast $sequence in document list' => [ + [ + 'total' => 2, + 'documents' => [ + [ + '$id' => 'doc1', + '$sequence' => '10', + 'name' => 'first', + ], + [ + '$id' => 'doc2', + '$sequence' => '20', + 'name' => 'second', ], ], - [ - 'total' => 2, - 'documents' => [ - [ - '$id' => 'doc1', - '$sequence' => 10, - 'name' => 'first', - ], - [ - '$id' => 'doc2', - '$sequence' => 20, - 'name' => 'second', - ], + ], + [ + 'total' => 2, + 'documents' => [ + [ + '$id' => 'doc1', + '$sequence' => 10, + 'name' => 'first', + ], + [ + '$id' => 'doc2', + '$sequence' => 20, + 'name' => 'second', ], - ] - ], - 'handle empty document list' => [ - [ - 'total' => 0, - 'documents' => [], ], - [ - 'total' => 0, - 'documents' => [], - ] + ] + ]; + yield 'handle empty document list' => [ + [ + 'total' => 0, + 'documents' => [], ], + [ + 'total' => 0, + 'documents' => [], + ] ]; } @@ -510,40 +500,38 @@ class V21Test extends TestCase $this->assertSame($expected, $result); } - public static function defaultPassthroughProvider(): array + public static function defaultPassthroughProvider(): \Iterator { - return [ - 'unmatched model passes through unchanged' => [ - Response::MODEL_DOCUMENT, - [ - 'name' => 'test-doc', - '$id' => 'doc123', - 'data' => 'some-value', - ], - [ - 'name' => 'test-doc', - '$id' => 'doc123', - 'data' => 'some-value', - ] + yield 'unmatched model passes through unchanged' => [ + Response::MODEL_DOCUMENT, + [ + 'name' => 'test-doc', + '$id' => 'doc123', + 'data' => 'some-value', ], - 'empty content passes through unchanged' => [ - Response::MODEL_DOCUMENT, - [], - [] - ], - 'deployment model passes through unchanged' => [ - Response::MODEL_DEPLOYMENT, - [ - 'id' => 'deployment123', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - ], - [ - 'id' => 'deployment123', - 'buildSpecification' => 's-1vcpu-512mb', - 'runtimeSpecification' => 's-1vcpu-256mb', - ] + [ + 'name' => 'test-doc', + '$id' => 'doc123', + 'data' => 'some-value', + ] + ]; + yield 'empty content passes through unchanged' => [ + Response::MODEL_DOCUMENT, + [], + [] + ]; + yield 'deployment model passes through unchanged' => [ + Response::MODEL_DEPLOYMENT, + [ + 'id' => 'deployment123', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', ], + [ + 'id' => 'deployment123', + 'buildSpecification' => 's-1vcpu-512mb', + 'runtimeSpecification' => 's-1vcpu-256mb', + ] ]; } diff --git a/tests/unit/Utopia/ResponseTest.php b/tests/unit/Utopia/ResponseTest.php index 74c68303f4..80c59ee2f8 100644 --- a/tests/unit/Utopia/ResponseTest.php +++ b/tests/unit/Utopia/ResponseTest.php @@ -1,5 +1,7 @@ generateComment(); $secondTip = $this->extractTip($second); - $this->assertEquals($firstTip, $secondTip); + $this->assertSame($firstTip, $secondTip); } public function testTipIsRestoredFromParsedComment(): void @@ -94,7 +96,7 @@ class CommentTest extends TestCase $newTip = $this->extractTip($new); $this->assertNotNull($newTip); - $this->assertNotEquals('Old tip that should be ignored', $newTip); + $this->assertNotSame('Old tip that should be ignored', $newTip); $this->assertContains($newTip, $this->getTips()); } @@ -132,7 +134,7 @@ class CommentTest extends TestCase $second = $comment->generateComment(); $secondTip = $this->extractTip($second); - $this->assertEquals($firstTip, $secondTip); + $this->assertSame($firstTip, $secondTip); } private function extractTip(string $comment): ?string