Commit Graph

27 Commits

Author SHA1 Message Date
Matej Bačo d27b578888 Fix more tests 2026-05-06 10:34:37 +02:00
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
Chirag Aggarwal 18ed6a9c59 Fix more PHPStan static access issues 2026-03-31 22:04:37 +05:30
Jake Barnby bada1a7c05 Timing updates 2026-02-24 14:00:07 +13:00
Jake Barnby b976454416 fix: add early failure detection and increase polling timeouts
Throw Critical exception when attribute/index/deployment status is
'failed' to fail tests immediately instead of waiting 15-20 minutes.
Increase default schema polling timeouts from 15 to 20 minutes for
CI stability under parallel load.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-20 19:51:59 +13:00
Jake Barnby 54505c0600 fix: increase polling timeouts for CI stability
Spatial attribute creation under parallel MariaDB load and function
deployment builds under MongoDB can exceed previous limits. Increased
SchemaPolling timeout from 8 to 10 minutes and GraphQL function build
timeout from 2 to 4 minutes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 04:21:49 +13:00
Jake Barnby 64d6efd098 fix: Add missing attribute types to Collection/AttributeList models and fix parallel test issues
- Add MODEL_ATTRIBUTE_VARCHAR/TEXT/MEDIUMTEXT/LONGTEXT to Collection and
  AttributeList models, fixing TypeError in Response::hasModel() that
  caused 4974 server crashes when serializing collections with new
  string attribute types
- Initialize $ruleType to null in Response::output() to prevent
  undefined variable when no model condition matches
- Isolate testUniqueIndexDuplicate with its own collection to prevent
  duplicate title interference from parallel tests in the same process
- Add retry mechanism to phone session creation for OTP token issues
- Increase GraphQL function build timeout from 30s to 120s
- Increase Sites deployment activation timeout from 100s to 200s
- Relax GraphQL bulk update row count assertion for parallel safety

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 17:53:21 +13:00
Jake Barnby e976617869 perf: Remove @depends from Databases permissions and partial GraphQL tests
- Added setupDatabase() helper with caching to all permission test files
- Removed @depends from LegacyPermissionsMemberTest, LegacyPermissionsTeamTest
- Removed @depends from TablesDBPermissionsMemberTest, TablesDBPermissionsTeamTest
- Partial GraphQL test updates from agents

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-06 11:56:58 +13:00
Jake Barnby 4adc4f65ad Add missing PHPUnit #[Depends] to GraphQL Functions tests
Fixed missing #[Depends] attributes:
- FunctionsClientTest: 4 methods (testCreateDeployment, testCreateExecution,
  testGetExecutions, testGetExecution)
- FunctionsServerTest: 11 methods (all test methods with parameters)
- Legacy/DatabaseServerTest: Fixed testCreateIndex dependency
  (was depending on void-returning testUpdateURLAttribute)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 18:28:38 +13:00
Jake Barnby 714b8d7ea6 Migrate to PHPUnit 11 2026-01-15 16:14:53 +13:00
Jake Barnby 6d2832831c Remove weird static/const mix 2025-08-19 23:03:18 +12:00
Matej Bačo 5ace34790d Migrate many tests to JS 2025-07-09 16:58:55 +02:00
Matej Bačo 1bdbb8fce1 Fix failing tests 2025-04-01 16:50:11 +02:00
Matej Bačo 2f3c43d0db Fix failing tests 2025-03-05 13:00:06 +01:00
Matej Bačo 16934af49f Fix flaky test 2025-02-25 13:14:33 +01:00
Fabian Gruber 213e16050b fix(test): use assertEventually instead of while(true) 2025-02-05 13:40:13 +01:00
loks0n cb0416be7b chore: fmt 2024-09-19 21:08:04 +01:00
Matej Bačo c3a80dcebc Fix GraphQL function test 2023-10-26 16:50:35 +02:00
Jake Barnby 0a1ab4ae60 Add back codes env var 2023-08-28 22:24:52 -04:00
Jake Barnby ef25c176ed Fix retry build test 2023-08-28 21:11:57 -04:00
Jake Barnby a1b10ef7a8 Fix graphql tests 2023-08-20 13:40:44 -04:00
Jake Barnby 1e4a3cd020 Fix graphql test 2023-08-20 13:20:37 -04:00
Jake Barnby 2404352f3c Fix more graphql tests 2023-08-19 01:59:36 -04:00
fogelito 48e2bf1c3e Helpers GraphQL 2023-01-16 11:25:40 +02:00
Jake Barnby fd52cdc45f Revert prefix to _ 2022-12-08 16:08:57 +13:00
Jake Barnby f9a32f6011 Fix reserved attribute selections 2022-10-21 13:53:54 +13:00
Jake Barnby 5bd420a823 Remove redundant test class prefixes 2022-09-22 20:29:42 +12:00