Files
appwrite/tests/e2e/Services/Projects/Schedules/SchedulesBase.php
Jake Barnby 6582ec8e67 fix: register TYPE_ID in GraphQL Mapper and fix Schedules tests for ParaTest
- Add 'id' => Type::string() to GraphQL Mapper Registry defaults to handle
  Model::TYPE_ID used by Document and Row models ($sequence field)
- Refactor SchedulesConsoleClientTest to use static-cached setup helpers
  instead of @depends annotations, which don't work in ParaTest --functional mode

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-18 21:59:33 +13:00

69 lines
2.2 KiB
PHP

<?php
namespace Tests\E2E\Services\Projects\Schedules;
use Tests\E2E\Client;
use Utopia\Database\Helpers\ID;
use Utopia\System\System;
trait SchedulesBase
{
protected static array $cachedScheduleProjectData = [];
protected function setupScheduleProjectData(): array
{
if (!empty(self::$cachedScheduleProjectData)) {
return self::$cachedScheduleProjectData;
}
$team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'teamId' => ID::unique(),
'name' => 'Schedule Test Team',
]);
$this->assertEquals(201, $team['headers']['status-code']);
$project = $this->client->call(Client::METHOD_POST, '/projects', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'projectId' => ID::unique(),
'name' => 'Schedule Test Project',
'teamId' => $team['body']['$id'],
'region' => System::getEnv('_APP_REGION', 'default'),
]);
$this->assertEquals(201, $project['headers']['status-code']);
$projectId = $project['body']['$id'];
$key = $this->client->call(Client::METHOD_POST, '/projects/'.$projectId.'/keys', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'keyId' => ID::unique(),
'name' => 'Schedule Test Key',
'scopes' => [
'functions.read',
'functions.write',
'execution.read',
'execution.write',
'messages.read',
'messages.write',
],
]);
$this->assertEquals(201, $key['headers']['status-code']);
self::$cachedScheduleProjectData = [
'projectId' => $projectId,
'apiKey' => $key['body']['secret'],
];
return self::$cachedScheduleProjectData;
}
}