Commit Graph

43 Commits

Author SHA1 Message Date
Chirag Aggarwal 9d7df34590 fix: clean up php 8.5 runtime deprecations 2026-04-29 14:47:05 +05:30
Chirag Aggarwal d2230f8fe7 chore: bump PHPStan to level 4 and fix all new errors
Raises `phpstan.neon` level from 3 to 4 and fixes the 549 new errors
that level 4 surfaces across 157 files. Fixes are root-cause — no
`@phpstan-ignore`, no `@var` casts, no baseline entries, no widened
types. A handful of latent bugs were fixed along the way:

- `app/controllers/general.php`: path-traversal guard was negating
  `\substr(...)` before the strict comparison (`!\substr(...) === $base`
  was always `false === $base`). Rewritten as `\substr(...) !== $base`.
- `src/Appwrite/Platform/Modules/Databases/Http/Databases/Logs/XList.php`
  and `.../TablesDB/Logs/XList.php`: were importing the raw Matomo
  `DeviceDetector` (whose `getDevice()` returns `?int`) but treating the
  result as an array with `deviceName/deviceBrand/deviceModel` keys.
  Swapped to `Appwrite\Detector\Detector`, matching the wrapper already
  used a few lines below for `$os`/`$client`.
- `src/Appwrite/Platform/Modules/Functions/Workers/Builds.php`: a match
  key was checking `$resourceKey === 'functions'` when `$resourceKey`
  is `'functionId'|'siteId'` — always false. Switched to the intended
  `$resource->getCollection() === 'functions'` check.
- `src/Appwrite/OpenSSL/OpenSSL.php`: `encrypt()` return type tightened
  to `string|false` to match `openssl_encrypt`; this lets callers'
  `=== false` error handling remain meaningful.
- `app/controllers/api/messaging.php`: removed a dead
  `array_key_exists('from', [])` branch in the Msg91 provider (empty
  array literal; branch was unreachable).

Large cleanup categories across the 549 fixes:
- Removed redundant `?? default` on array offsets and expressions that
  PHPStan now knows are non-nullable.
- Removed unreachable statements (mostly `return;` after `throw` or
  `markTestSkipped()`).
- Removed redundant `is_array`/`is_string`/`is_bool`/`instanceof` checks
  on already-narrowed types.
- Added `default =>` arms (or throwing arms) to non-exhaustive matches
  on `string`/`mixed` input.
- Removed dead `$document === false` branches where method return types
  were tightened to non-nullable `Document`.
- Removed unused properties (`$version` on Etsy/Zoom OAuth2, `$paths` on
  Installer State, `$source` on MigrationsWorker, `$account2` on two
  GraphQL auth tests), unused traits (`ApiVectorsDB`, `DatabaseFixture`),
  and an unused `cleanupStaleExecutions` task method.
- Replaced `assertTrue(true)` and redundant `assertIsArray`/`assertIsString`/
  `assertNotNull` assertions with `addToAssertionCount(1)` or
  `assertNotEmpty` where the runtime type was already known.
2026-04-19 17:31:20 +05:30
loks0n e2d7dd837d fix: use cURL cookie engine instead of parse_str for RFC 6265 compliance
parse_str() URL-decodes cookie values, causing the test client to behave
differently from real clients (Dart, Swift) which store values verbatim
per RFC 6265. This masked a production bug where base64 session values
containing %3D%3D would fail to decode on real devices.

Replaces the manual Set-Cookie header parsing with cURL's built-in cookie
engine (CURLOPT_COOKIEFILE='') and reads cookies via CURLINFO_COOKIELIST,
which stores and returns values verbatim without any decoding.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 15:07:46 +01:00
Jake Barnby 64a368ba3d Merge remote-tracking branch 'origin/feat-db-tests' into feat-mongodb
# Conflicts:
#	.github/workflows/tests.yml
#	src/Appwrite/Utopia/Response.php
#	src/Appwrite/Utopia/Response/Model/AttributeList.php
#	tests/e2e/Client.php
#	tests/e2e/Scopes/ProjectCustom.php
#	tests/e2e/Services/Databases/DatabasesBase.php
#	tests/e2e/Services/Databases/Legacy/DatabasesCustomClientTest.php
#	tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php
#	tests/e2e/Services/Databases/Legacy/DatabasesStringTypesTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesBase.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesCustomClientTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php
#	tests/e2e/Services/Databases/TablesDB/DatabasesStringTypesTest.php
#	tests/e2e/Services/Databases/Transactions/TransactionsBase.php
#	tests/e2e/Services/GraphQL/Legacy/DatabaseServerTest.php
#	tests/e2e/Services/GraphQL/TablesDB/DatabaseServerTest.php
#	tests/e2e/Services/Messaging/MessagingBase.php
#	tests/e2e/Services/Sites/SitesBase.php
#	tests/e2e/Services/Sites/SitesCustomServerTest.php
2026-02-18 03:27:23 +13:00
Jake Barnby b7ce686d73 Merge branch '1.8.x' into feat-mongodb 2026-02-13 07:18:26 +00:00
Jake Barnby 52606f352c fix: handle 401 in assertEventually and increase curl timeout to 30s
- setupDeployment's assertEventually callbacks now handle 401 responses
  gracefully instead of crashing with "Undefined array key"
- Increase Client curl timeout from 15s to 30s for slow CI runners
  (testDeleteScheduledExecution and testGetScreenshotWithPermissions
  were hitting the 15s limit)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 10:37:07 +13:00
fogelito 4ef8222294 Check strings 2026-02-12 12:18:03 +02:00
Jake Barnby 1a22c281f5 Parallelise 2026-01-10 21:25:06 +13:00
Jake Barnby fb8270733e Allow running tests with specific response format 2025-09-01 22:09:30 +12:00
Chirag Aggarwal 0e636f67be update client 2025-08-12 16:24:01 +05:30
Chirag Aggarwal f8afbbbf3c feat: allow HEAD requests and add test for it 2025-08-12 16:14:15 +05:30
Matej Bačo 06020e2b62 Add preview auth tests, finish todos, improve quality 2025-03-08 12:57:55 +01:00
loks0n e43887c53b feat: remove verbose 2024-11-08 13:06:09 +01:00
loks0n ee4b54857f fix: tests 2024-11-08 13:01:18 +01:00
loks0n 83cbddb926 fix: test 2024-11-07 20:31:12 +01:00
Khushboo Verma 3190384d24 Add multipart support 2024-08-05 18:38:41 +05:30
Matej Bačo f87e2bc879 Binary support & tests for Router 2024-07-01 10:35:06 +02:00
Christy Jacob 72a2a043cd fix: linter 2023-12-09 00:28:10 +01:00
Christy Jacob 731e7b86a7 fix: failing tests 2023-12-09 00:17:13 +01:00
Jake Barnby bab804b8e1 Fix tests
(cherry picked from commit 0661f1f889)
2023-05-30 18:29:20 +12:00
Jake Barnby bf284f4fde Add content-type tests 2022-07-13 15:50:25 +12:00
Everly Precia Suresh 8d0581e401 fix linting issues in client.php 2022-06-02 12:49:01 +00:00
Everly Precia Suresh 19300ccdd7 format files in app, src, tests 2022-05-23 14:54:50 +00:00
Matej Bačo 36a985d7ea Update tests/e2e/Client.php
Co-authored-by: Eldad A. Fux <eldad.fux@gmail.com>
2022-02-11 12:32:16 +01:00
Matej Baco 3293d15eff Cleanup 2022-01-31 16:07:07 +01:00
Matej Baco 4161a65e0b Path validator + tests 2022-01-31 16:04:30 +01:00
Damodar Lohani 7a18639c5c test for user prefs 2021-12-30 13:54:23 +05:45
Torsten Dittmann c8036ffc32 reduce timeouts 2021-10-22 18:19:02 +02:00
Torsten Dittmann cac9875b97 tests: clean up travis file 2021-04-28 12:20:32 +02:00
Torsten Dittmann 0ddefb97eb tests: adjust curl 2021-04-28 09:14:41 +02:00
Torsten Dittmann ef7c4549af tests: adjust curl 2021-04-28 08:54:09 +02:00
Torsten Dittmann 107bbf57fb tests: debug travis 2021-04-28 08:10:40 +02:00
Eldad Fux e009f9c60b Updated tests folder 2020-10-27 21:48:38 +02:00
Eldad Fux 3f3914bf2d Better error log for e2e tests 2020-10-27 10:47:28 +02:00
Eldad Fux b7fe52ad54 Updated tests 2020-10-15 00:11:12 +03:00
Eldad Fux 178d45cabf New OAuth e2e test 2020-01-13 17:15:52 +02:00
Eldad Fux a2f9e7ef99 Updated tests 2020-01-11 23:53:57 +02:00
Eldad Fux f5f074eb86 Tests - work in progress 2020-01-11 15:58:02 +02:00
peter279k 2c2bf9ad2f Test enhancement 2019-11-04 03:05:26 +08:00
Christy Jacob 4158c3ea21 refactor: code refactoring using php-cs-fixer 2019-09-30 11:43:40 +05:30
eldadfux 669fac6d3d Added more tests 2019-09-15 21:56:04 +03:00
eldadfux c559379f8e Remove console restrictions 2019-09-15 19:50:57 +03:00
eldadfux 2dbed62d4f Added e2e tests 2019-09-14 07:37:37 +03:00