diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 07f5785e5e..ca7ccb18e3 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -19,14 +19,14 @@ use Utopia\System\System; class ProjectsConsoleClientTest extends Scope { - use Async; - use ProjectConsole; use ProjectsBase; + use ProjectConsole; use SideClient; + use Async; #[Group('smtpAndTemplates')] #[Group('projectsCRUD')] - public function test_create_project(): void + public function testCreateProject(): void { /** * Test for SUCCESS @@ -46,12 +46,12 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/projects', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-response-format' => '1.9.4', + 'x-appwrite-response-format' => '1.9.4' ], $this->getHeaders()), [ 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -96,7 +96,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => '', 'teamId' => $team['body']['$id'], - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -108,13 +108,13 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'projectId' => ID::unique(), 'name' => 'Project Test', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(401, $response['headers']['status-code']); } - public function test_delete_project_with_multi_db(): void + public function testDeleteProjectWithMultiDB(): void { // Create a team and project $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ @@ -136,7 +136,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'MultiDB Project', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -156,7 +156,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $database['headers']['status-code']); $databaseId = $database['body']['$id']; - $collection = $this->client->call(Client::METHOD_POST, '/databases/'.$databaseId.'/collections', $projectAdminHeaders, [ + $collection = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $projectAdminHeaders, [ 'collectionId' => ID::unique(), 'name' => 'Legacy Collection', 'documentSecurity' => true, @@ -174,7 +174,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $documentsDb['headers']['status-code']); $documentsDbId = $documentsDb['body']['$id']; - $documentsCollection = $this->client->call(Client::METHOD_POST, '/documentsdb/'.$documentsDbId.'/collections', $projectAdminHeaders, [ + $documentsCollection = $this->client->call(Client::METHOD_POST, '/documentsdb/' . $documentsDbId . '/collections', $projectAdminHeaders, [ 'collectionId' => ID::unique(), 'name' => 'Documents Collection', 'documentSecurity' => true, @@ -192,7 +192,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $vectorDb['headers']['status-code']); $vectorDbId = $vectorDb['body']['$id']; - $vectorCollection = $this->client->call(Client::METHOD_POST, '/vectorsdb/'.$vectorDbId.'/collections', $projectAdminHeaders, [ + $vectorCollection = $this->client->call(Client::METHOD_POST, '/vectorsdb/' . $vectorDbId . '/collections', $projectAdminHeaders, [ 'collectionId' => ID::unique(), 'name' => 'Vector Collection', 'dimension' => 3, @@ -204,7 +204,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $vectorCollection['headers']['status-code']); // Delete project - $delete = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId, array_merge([ + $delete = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); @@ -212,7 +212,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $delete['headers']['status-code']); // Ensure project is gone - $getProject = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId, array_merge([ + $getProject = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -221,7 +221,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $getProject['headers']['status-code']); } - public function test_create_duplicate_project(): void + public function testCreateDuplicateProject(): void { // Create a team $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ @@ -245,7 +245,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => $projectId, 'name' => 'Original Project', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -261,7 +261,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => $projectId, 'name' => 'Project Duplicate', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(409, $response['headers']['status-code']); @@ -270,7 +270,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('projectsCRUD')] - public function test_transfer_project_team() + public function testTransferProjectTeam() { /** * Test for SUCCESS @@ -324,7 +324,7 @@ class ProjectsConsoleClientTest extends Scope $projectId = $response['body']['$id']; - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId.'/team', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/team', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -339,7 +339,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('projectsCRUD')] - public function test_list_project(): void + public function testListProject(): void { $data = $this->setupProjectData(); $id = $data['projectId']; @@ -347,6 +347,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS */ + $response = $this->client->call(Client::METHOD_GET, '/projects', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -365,7 +366,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', ], $this->getHeaders(), [ - 'search' => $id, + 'search' => $id ])); $this->assertEquals(200, $response['headers']['status-code']); @@ -377,7 +378,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', ], $this->getHeaders(), [ - 'search' => 'Project Test', + 'search' => 'Project Test' ])); $this->assertEquals($response['headers']['status-code'], 200); @@ -407,7 +408,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test 2', 'teamId' => $team['body']['$id'], - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -529,7 +530,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('projectsCRUD')] - public function test_list_projects_query_select(): void + public function testListProjectsQuerySelect(): void { $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ 'content-type' => 'application/json', @@ -550,7 +551,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Query Select Test Project', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -592,7 +593,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, '/projects', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'x-appwrite-response-format' => '1.9.4', + 'x-appwrite-response-format' => '1.9.4' ], $this->getHeaders()), [ 'queries' => [ Query::select(['$id', 'name', 'teamId', 'description', '$createdAt', '$updatedAt'])->toString(), @@ -788,7 +789,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Invalid `queries` param: Invalid query: Attribute not found in schema: invalidAttribute', $response['body']['message']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); @@ -796,7 +797,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); } - public function test_get_project(): void + public function testGetProject(): void { // Create a team $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ @@ -827,7 +828,7 @@ class ProjectsConsoleClientTest extends Scope 'legalState' => 'Custom state', 'legalCity' => 'Košice', 'legalAddress' => 'Main street 32', - 'legalTaxId' => 'TAXID_123456', + 'legalTaxId' => 'TAXID_123456' ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -874,7 +875,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ 'number' => '+421123456789', - 'otp' => '123456', + 'otp' => '123456' ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -884,12 +885,12 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'labels' => ['custom1', 'custom2'], + 'labels' => ['custom1', 'custom2'] ]); $this->assertEquals(200, $response['headers']['status-code']); // Create dev keys - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/dev-keys', array_merge([ 'content-type' => 'application/json', ], $this->getHeaders()), [ 'name' => 'Custom key 1', @@ -897,11 +898,11 @@ class ProjectsConsoleClientTest extends Scope ]); $this->assertEquals(201, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/dev-keys', array_merge([ 'content-type' => 'application/json', ], $this->getHeaders()), [ 'name' => 'Custom key 2', - 'expire' => '2099-05-07 11:23:30.713', + 'expire' => '2099-05-07 11:23:30.713' ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -911,7 +912,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ 'number' => '+420987654321', - 'otp' => '654321', + 'otp' => '654321' ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -921,7 +922,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'duration' => 135, + 'duration' => 135 ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -930,7 +931,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'total' => 54, + 'total' => 54 ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -939,7 +940,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'total' => 7, + 'total' => 7 ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -948,7 +949,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'total' => 9, + 'total' => 9 ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -957,7 +958,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'enabled' => true, + 'enabled' => true ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -966,7 +967,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'enabled' => true, + 'enabled' => true ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -975,7 +976,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'enabled' => true, + 'enabled' => true ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -997,7 +998,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'enabled' => true, + 'enabled' => true ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -1018,7 +1019,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $webhook['headers']['status-code']); // Create API key - $key = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $key = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -1029,7 +1030,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $key['headers']['status-code']); // Create platform - $platform = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $platform = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -1055,7 +1056,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -1262,7 +1263,7 @@ class ProjectsConsoleClientTest extends Scope 'authPhone', ]; foreach ($authsKeys as $authsKey) { - $this->assertTrue($response['body'][$authsKey], 'Auth method should be enabled: '.$authsKey); + $this->assertTrue($response['body'][$authsKey], 'Auth method should be enabled: ' . $authsKey); } $serviceKeys = [ @@ -1285,7 +1286,7 @@ class ProjectsConsoleClientTest extends Scope 'serviceStatusForMessaging', ]; foreach ($serviceKeys as $serviceKey) { - $this->assertTrue($response['body'][$serviceKey], 'Service should be enabled: '.$serviceKey); + $this->assertTrue($response['body'][$serviceKey], 'Service should be enabled: ' . $serviceKey); } $protocolKeys = [ @@ -1294,7 +1295,7 @@ class ProjectsConsoleClientTest extends Scope 'protocolStatusForWebsocket', ]; foreach ($protocolKeys as $protocolKey) { - $this->assertTrue($response['body'][$protocolKey], 'Protocol should be enabled: '.$protocolKey); + $this->assertTrue($response['body'][$protocolKey], 'Protocol should be enabled: ' . $protocolKey); } // Ensure booleans can be falsy @@ -1304,7 +1305,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'enabled' => false, + 'enabled' => false ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -1313,7 +1314,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'enabled' => false, + 'enabled' => false ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -1322,7 +1323,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'enabled' => false, + 'enabled' => false ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -1344,7 +1345,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'enabled' => false, + 'enabled' => false ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -1354,7 +1355,7 @@ class ProjectsConsoleClientTest extends Scope foreach ($authMethods as $authMethod) { $response = $this->client->call( Client::METHOD_PATCH, - '/project/auth-methods/'.$authMethod, + '/project/auth-methods/' . $authMethod, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, @@ -1371,7 +1372,7 @@ class ProjectsConsoleClientTest extends Scope foreach ($protocols as $protocol) { $response = $this->client->call( Client::METHOD_PATCH, - '/project/protocols/'.$protocol, + '/project/protocols/' . $protocol, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, @@ -1407,7 +1408,7 @@ class ProjectsConsoleClientTest extends Scope foreach ($services as $service) { $response = $this->client->call( Client::METHOD_PATCH, - '/project/services/'.$service, + '/project/services/' . $service, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, @@ -1440,7 +1441,7 @@ class ProjectsConsoleClientTest extends Scope ); $this->assertEquals(200, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -1474,7 +1475,7 @@ class ProjectsConsoleClientTest extends Scope 'authPhone', ]; foreach ($authsKeys as $authsKey) { - $this->assertFalse($response['body'][$authsKey], 'Auth method should be disabled: '.$authsKey); + $this->assertFalse($response['body'][$authsKey], 'Auth method should be disabled: ' . $authsKey); } $serviceKeys = [ @@ -1497,7 +1498,7 @@ class ProjectsConsoleClientTest extends Scope 'serviceStatusForMessaging', ]; foreach ($serviceKeys as $serviceKey) { - $this->assertFalse($response['body'][$serviceKey], 'Service should be disabled: '.$serviceKey); + $this->assertFalse($response['body'][$serviceKey], 'Service should be disabled: ' . $serviceKey); } $protocolKeys = [ @@ -1506,7 +1507,7 @@ class ProjectsConsoleClientTest extends Scope 'protocolStatusForWebsocket', ]; foreach ($protocolKeys as $protocolKey) { - $this->assertFalse($response['body'][$protocolKey], 'Protocol should be disabled: '.$protocolKey); + $this->assertFalse($response['body'][$protocolKey], 'Protocol should be disabled: ' . $protocolKey); } /** @@ -1530,14 +1531,14 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); } - public function test_get_project_usage(): void + public function testGetProjectUsage(): void { $this->markTestIncomplete( 'This test is failing right now due to functions collection.' ); } - public function test_update_project(): void + public function testUpdateProject(): void { // Create a team $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ @@ -1560,7 +1561,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -1569,7 +1570,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -1603,19 +1604,19 @@ class ProjectsConsoleClientTest extends Scope } #[Group('smtpAndTemplates')] - public function test_update_project_smtp(): void + public function testUpdateProjectSMTP(): void { $data = $this->setupProjectData(); $id = $data['projectId']; - $smtpHost = System::getEnv('_APP_SMTP_HOST', 'maildev'); - $smtpPort = intval(System::getEnv('_APP_SMTP_PORT', '1025')); + $smtpHost = System::getEnv('_APP_SMTP_HOST', "maildev"); + $smtpPort = intval(System::getEnv('_APP_SMTP_PORT', "1025")); $smtpUsername = System::getEnv('_APP_SMTP_USERNAME', 'user'); $smtpPassword = System::getEnv('_APP_SMTP_PASSWORD', 'password'); /** * Test for SUCCESS: Valid Credentials */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/smtp', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/smtp', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -1641,7 +1642,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('', $response['body']['smtpSecure']); // Check the project - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -1661,7 +1662,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE: Invalid Credentials */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/smtp', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/smtp', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -1681,10 +1682,10 @@ class ProjectsConsoleClientTest extends Scope } #[Group('smtpAndTemplates')] - public function test_create_project_smtp_tests(): void + public function testCreateProjectSMTPTests(): void { - $smtpHost = System::getEnv('_APP_SMTP_HOST', 'maildev'); - $smtpPort = intval(System::getEnv('_APP_SMTP_PORT', '1025')); + $smtpHost = System::getEnv('_APP_SMTP_HOST', "maildev"); + $smtpPort = intval(System::getEnv('_APP_SMTP_PORT', "1025")); $smtpUsername = System::getEnv('_APP_SMTP_USERNAME', 'user'); $smtpPassword = System::getEnv('_APP_SMTP_PASSWORD', 'password'); @@ -1709,13 +1710,13 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); $id = $response['body']['$id']; - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/smtp/tests', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/smtp/tests', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -1748,7 +1749,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertStringContainsStringIgnoringCase('251 Little Falls Drive', $email1['html']); $this->assertEquals('custommailer@appwrite.io', $email2['from'][0]['address']); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/smtp/tests', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/smtp/tests', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -1764,7 +1765,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/smtp/tests', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/smtp/tests', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -1782,13 +1783,13 @@ class ProjectsConsoleClientTest extends Scope } #[Group('smtpAndTemplates')] - public function test_update_templates(): void + public function testUpdateTemplates(): void { $data = $this->setupProjectData(); $id = $data['projectId']; /** Get Default Email Template */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/templates/email/verification/en-us', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/templates/email/verification/en-us', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -1804,10 +1805,10 @@ class ProjectsConsoleClientTest extends Scope $projectWithoutSmtp = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'Project Without SMTP', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectWithoutSmtp.'/templates/email/verification/en-us', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectWithoutSmtp . '/templates/email/verification/en-us', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -1825,7 +1826,7 @@ class ProjectsConsoleClientTest extends Scope $smtpPort = 1025; $smtpUsername = 'user'; $smtpPassword = 'password'; - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/smtp', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/smtp', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -1841,7 +1842,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); /** Update Email template */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/templates/email/verification/en-us', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/templates/email/verification/en-us', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -1861,7 +1862,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('Please verify your email {{url}}', $response['body']['message']); /** Get Updated Email Template */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/templates/email/verification/en-us', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/templates/email/verification/en-us', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -1877,7 +1878,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('smtpAndTemplates')] - public function test_session_alert_locale_fallback(): void + public function testSessionAlertLocaleFallback(): void { $smtpHost = 'maildev'; $smtpPort = 1025; @@ -1910,7 +1911,7 @@ class ProjectsConsoleClientTest extends Scope $projectId = $project['body']['$id']; /** Configure custom SMTP pointing to maildev */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId.'/smtp', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/smtp', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -1931,7 +1932,7 @@ class ProjectsConsoleClientTest extends Scope * default locale (en), which is the same slot used as the system-wide * fallback when a session's locale has no dedicated template. */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId.'/templates/email', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/templates/email', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -1950,7 +1951,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('fallback@appwrite.io', $response['body']['senderEmail']); /** Set custom sessionAlert template for Slovak locale */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId.'/templates/email', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/templates/email', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -1969,7 +1970,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('sk@appwrite.io', $response['body']['senderEmail']); /** Enable session alerts */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId.'/auth/session-alerts', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/auth/session-alerts', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -1979,7 +1980,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); /** Verify alerts are enabled */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -1988,7 +1989,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertTrue($response['body']['authSessionAlerts']); /** Create user (email + password) in the project */ - $userEmail = 'session-alert-'.uniqid().'@appwrite.io'; + $userEmail = 'session-alert-' . uniqid() . '@appwrite.io'; $password = 'password'; $response = $this->client->call(Client::METHOD_POST, '/account', [ 'origin' => 'http://localhost', @@ -2082,27 +2083,27 @@ class ProjectsConsoleClientTest extends Scope $this->assertStringContainsString('Slovak sign-in alert body', $lastEmail['html']); /** Cleanup — delete the project */ - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(204, $response['headers']['status-code']); /** Cleanup — delete the team */ - $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(204, $response['headers']['status-code']); } - public function test_update_project_auth_duration(): void + public function testUpdateProjectAuthDuration(): void { $data = $this->setupProjectData(); $id = $data['projectId']; // Check defaults - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => 'console', 'x-appwrite-response-format' => '1.9.4', @@ -2114,7 +2115,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/duration', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/duration', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2138,7 +2139,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $projectId, ], $this->getHeaders()), [ 'userId' => 'unique()', - 'email' => 'test'.rand(0, 9999).'@example.com', + 'email' => 'test' . rand(0, 9999) . '@example.com', 'password' => 'password', 'name' => 'Test User', ]); @@ -2182,7 +2183,7 @@ class ProjectsConsoleClientTest extends Scope }, timeoutMs: 15 * 1000); // Set session duration to 10min - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/duration', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/duration', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2203,7 +2204,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(401, $response['headers']['status-code']); // Return project back to normal - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/duration', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/duration', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2215,7 +2216,7 @@ class ProjectsConsoleClientTest extends Scope $projectId = $response['body']['$id']; // Check project is back to normal - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => 'console', 'x-appwrite-response-format' => '1.9.4', @@ -2225,7 +2226,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(TOKEN_EXPIRATION_LOGIN_LONG, $response['body']['authDuration']); // 1 Year } - public function test_update_project_invalidate_sessions(): void + public function testUpdateProjectInvalidateSessions(): void { // Create a team for the test project $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ @@ -2247,14 +2248,14 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Session Invalidation Test Project', 'teamId' => $team['body']['$id'], - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); $id = $response['body']['$id']; // Check defaults - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => 'console', 'x-appwrite-response-format' => '1.9.4', @@ -2263,7 +2264,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertTrue($response['body']['authInvalidateSessions']); - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/session-invalidation', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/session-invalidation', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2272,7 +2273,7 @@ class ProjectsConsoleClientTest extends Scope ]); $this->assertFalse($response['body']['authInvalidateSessions']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => 'console', 'x-appwrite-response-format' => '1.9.4', @@ -2281,7 +2282,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertFalse($response['body']['authInvalidateSessions']); - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/session-invalidation', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/session-invalidation', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2290,7 +2291,7 @@ class ProjectsConsoleClientTest extends Scope ]); $this->assertTrue($response['body']['authInvalidateSessions']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => 'console', 'x-appwrite-response-format' => '1.9.4', @@ -2300,7 +2301,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertTrue($response['body']['authInvalidateSessions']); } - public function test_update_project_o_auth(): void + public function testUpdateProjectOAuth(): void { // Create a team $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ @@ -2323,33 +2324,33 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); $id = $response['body']['$id']; - $providers = require __DIR__.'/../../../../app/config/oAuthProviders.php'; + $providers = require(__DIR__ . '/../../../../app/config/oAuthProviders.php'); /** * Test for SUCCESS */ foreach ($providers as $key => $provider) { - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/oauth2', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/oauth2', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', ], $this->getHeaders()), [ 'provider' => $key, - 'appId' => 'AppId-'.ucfirst($key), - 'secret' => 'Secret-'.ucfirst($key), + 'appId' => 'AppId-' . ucfirst($key), + 'secret' => 'Secret-' . ucfirst($key), ]); $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); } - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -2363,7 +2364,7 @@ class ProjectsConsoleClientTest extends Scope $asserted = false; foreach ($response['body']['oAuthProviders'] as $responseProvider) { if ($responseProvider['key'] === $key) { - $this->assertEquals('AppId-'.ucfirst($key), $responseProvider['appId']); + $this->assertEquals('AppId-' . ucfirst($key), $responseProvider['appId']); $this->assertEmpty($responseProvider['secret']); $this->assertFalse($responseProvider['enabled']); $asserted = true; @@ -2377,13 +2378,13 @@ class ProjectsConsoleClientTest extends Scope // Enable providers $i = 0; foreach ($providers as $key => $provider) { - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/oauth2', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/oauth2', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', ], $this->getHeaders()), [ 'provider' => $key, - 'enabled' => $i === 0 ? false : true, // On first provider, test enabled=false + 'enabled' => $i === 0 ? false : true // On first provider, test enabled=false ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -2392,7 +2393,7 @@ class ProjectsConsoleClientTest extends Scope $i++; } - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -2422,7 +2423,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/oauth2', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/oauth2', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -2435,7 +2436,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); } - public function test_update_project_auth_status(): void + public function testUpdateProjectAuthStatus(): void { // Create a team $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ @@ -2458,14 +2459,14 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); $id = $response['body']['$id']; - $auth = require __DIR__.'/../../../../app/config/auth.php'; - $originalEmail = uniqid().'user@localhost.test'; + $auth = require(__DIR__ . '/../../../../app/config/auth.php'); + $originalEmail = uniqid() . 'user@localhost.test'; $originalPassword = 'password'; $originalName = 'User Name'; @@ -2489,13 +2490,13 @@ class ProjectsConsoleClientTest extends Scope 'password' => $originalPassword, ]); - $session = $response['cookies']['a_session_'.$id]; + $session = $response['cookies']['a_session_' . $id]; /** * Test for SUCCESS */ foreach ($auth as $index => $method) { - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/'.$index, array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/' . $index, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2506,7 +2507,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -2514,10 +2515,10 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals(false, $response['body']['auth'.ucfirst($method['key'])]); + $this->assertEquals(false, $response['body']['auth' . ucfirst($method['key'])]); } - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $password = 'password'; $name = 'User Name'; @@ -2540,25 +2541,25 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'cookie' => 'a_session_'.$id.'='.$session, + 'cookie' => 'a_session_' . $id . '=' . $session, ]), [ 'teamId' => ID::unique(), - 'name' => 'Arsenal', + 'name' => 'Arsenal' ]); $this->assertEquals(201, $response['headers']['status-code']); $teamUid = $response['body']['$id']; - $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamUid.'/memberships', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamUid . '/memberships', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'cookie' => 'a_session_'.$id.'='.$session, + 'cookie' => 'a_session_' . $id . '=' . $session, ]), [ 'email' => $email, 'name' => 'Friend User', 'roles' => ['admin', 'editor'], - 'url' => 'http://localhost:5000/join-us#title', + 'url' => 'http://localhost:5000/join-us#title' ]); $this->assertEquals($response['headers']['status-code'], 501); @@ -2566,7 +2567,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/account/jwt', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'cookie' => 'a_session_'.$id.'='.$session, + 'cookie' => 'a_session_' . $id . '=' . $session, ])); $this->assertEquals($response['headers']['status-code'], 501); @@ -2593,7 +2594,7 @@ class ProjectsConsoleClientTest extends Scope // Cleanup foreach ($auth as $index => $method) { - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/'.$index, array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/' . $index, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2603,7 +2604,7 @@ class ProjectsConsoleClientTest extends Scope } } - public function test_update_project_auth_limit(): void + public function testUpdateProjectAuthLimit(): void { $data = $this->setupProjectData(); $id = $data['projectId']; @@ -2611,7 +2612,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/limit', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/limit', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2622,7 +2623,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $password = 'password'; $name = 'User Name'; @@ -2654,10 +2655,10 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $team['headers']['status-code']); $teamId = $team['body']['$id']; - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; // Creating A User Using Team membership - $response = $this->client->call(Client::METHOD_POST, '/teams/'.$teamId.'/memberships', array_merge($this->getHeaders(), [ + $response = $this->client->call(Client::METHOD_POST, '/teams/' . $teamId . '/memberships', array_merge($this->getHeaders(), [ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $id, @@ -2670,7 +2671,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $response = $this->client->call(Client::METHOD_POST, '/account', array_merge([ 'origin' => 'http://localhost', @@ -2686,10 +2687,11 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(Exception::USER_COUNT_EXCEEDED, $response['body']['type']); $this->assertEquals(400, $response['headers']['status-code']); + /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/limit', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/limit', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2700,7 +2702,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $response = $this->client->call(Client::METHOD_POST, '/account', array_merge([ 'origin' => 'http://localhost', @@ -2716,18 +2718,18 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals($response['headers']['status-code'], 201); } - public function test_update_project_auth_sessions_limit(): void + public function testUpdateProjectAuthSessionsLimit(): void { $id = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testUpdateProjectAuthSessionsLimit', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/max-sessions', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/max-sessions', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2739,7 +2741,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertNotEmpty($response['body']['$id']); $this->assertEquals(1, $response['body']['authSessionsLimit']); - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $password = 'password'; $name = 'User Name'; @@ -2777,7 +2779,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); $latestSessionId = $response['body']['$id']; - $sessionCookie = 'a_session_'.$id.'='.($response['cookies']['a_session_'.$id] ?? ''); + $sessionCookie = 'a_session_' . $id . '=' . ($response['cookies']['a_session_' . $id] ?? ''); // Small delay for shutdown hook to complete \usleep(500_000); @@ -2799,7 +2801,7 @@ class ProjectsConsoleClientTest extends Scope /** * Reset Limit */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/max-sessions', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/max-sessions', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2810,7 +2812,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); } - public function test_update_project_auth_password_history(): void + public function testUpdateProjectAuthPasswordHistory(): void { $data = $this->setupProjectWithAuthLimit(); $id = $data['projectId']; @@ -2818,7 +2820,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for Success */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/password-history', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/password-history', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2829,7 +2831,8 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(1, $response['body']['authPasswordHistory']); - $email = uniqid().'user@localhost.test'; + + $email = uniqid() . 'user@localhost.test'; $password = 'password'; $name = 'User Name'; @@ -2861,13 +2864,13 @@ class ProjectsConsoleClientTest extends Scope 'password' => $password, ]); $this->assertEquals(201, $session['headers']['status-code']); - $session = $session['cookies']['a_session_'.$id]; + $session = $session['cookies']['a_session_' . $id]; $response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'cookie' => 'a_session_'.$id.'='.$session, + 'cookie' => 'a_session_' . $id . '=' . $session, ]), [ 'oldPassword' => $password, 'password' => $password, @@ -2881,16 +2884,17 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, ]); - $response = $this->client->call(Client::METHOD_PATCH, '/users/'.$userId.'/password', $headers, [ + $response = $this->client->call(Client::METHOD_PATCH, '/users/' . $userId . '/password', $headers, [ 'password' => $password, ]); $this->assertEquals(400, $response['headers']['status-code']); + /** * Reset */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/password-history', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/password-history', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -2902,7 +2906,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(0, $response['body']['authPasswordHistory']); } - public function test_update_project_auth_password_strength(): void + public function testUpdateProjectAuthPasswordStrength(): void { $data = $this->setupProjectData(); $id = $data['projectId']; @@ -2947,7 +2951,7 @@ class ProjectsConsoleClientTest extends Scope $weakPassword = 'password123!'; $validPassword = 'Password123!'; - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $response = $this->client->call(Client::METHOD_POST, '/account', array_merge([ 'origin' => 'http://localhost', @@ -2955,7 +2959,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, ]), [ 'userId' => ID::unique(), - 'email' => uniqid().'weak-account@localhost.test', + 'email' => uniqid() . 'weak-account@localhost.test', 'password' => $weakPassword, 'name' => 'Weak Account', ]); @@ -2968,7 +2972,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-mode' => 'admin', ]), [ 'userId' => ID::unique(), - 'email' => uniqid().'weak-user@localhost.test', + 'email' => uniqid() . 'weak-user@localhost.test', 'password' => $weakPassword, 'name' => 'Weak User', ]); @@ -2999,13 +3003,13 @@ class ProjectsConsoleClientTest extends Scope ]); $this->assertEquals(201, $session['headers']['status-code']); - $session = $session['cookies']['a_session_'.$id]; + $session = $session['cookies']['a_session_' . $id]; $response = $this->client->call(Client::METHOD_PATCH, '/account/password', array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'cookie' => 'a_session_'.$id.'='.$session, + 'cookie' => 'a_session_' . $id . '=' . $session, ]), [ 'oldPassword' => $validPassword, 'password' => $weakPassword, @@ -3047,7 +3051,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, ]); - $response = $this->client->call(Client::METHOD_PATCH, '/users/'.$userId.'/password', $headers, [ + $response = $this->client->call(Client::METHOD_PATCH, '/users/' . $userId . '/password', $headers, [ 'password' => $weakPassword, ]); @@ -3075,7 +3079,7 @@ class ProjectsConsoleClientTest extends Scope #[Group('smtpAndTemplates')] #[Group('projectsCRUD')] - public function test_update_mock_numbers(): void + public function testUpdateMockNumbers(): void { $data = $this->setupProjectData(); $id = $data['projectId']; @@ -3085,7 +3089,7 @@ class ProjectsConsoleClientTest extends Scope */ /** Trying to pass an empty body to the endpoint */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -3095,21 +3099,21 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('Param "numbers" is not optional.', $response['body']['message']); /** Trying to pass body with incorrect structure */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', ], $this->getHeaders()), [ 'numbers' => [ 'phone' => '+1655513432', - 'otp' => '123456', - ], + 'otp' => '123456' + ] ]); $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Invalid `numbers` param: Value must a valid array no longer than 10 items and Invalid payload structure. Please check the "phone" and "otp" fields', $response['body']['message']); /** Trying to pass an OTP longer than 6 characters*/ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -3117,15 +3121,15 @@ class ProjectsConsoleClientTest extends Scope 'numbers' => [ [ 'phone' => '+1655513432', - 'otp' => '12345678', - ], - ], + 'otp' => '12345678' + ] + ] ]); $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Invalid `numbers` param: Value must a valid array no longer than 10 items and Invalid OTP. Please make sure the OTP is a 6 digit number', $response['body']['message']); /** Trying to pass an OTP shorter than 6 characters*/ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -3133,15 +3137,15 @@ class ProjectsConsoleClientTest extends Scope 'numbers' => [ [ 'phone' => '+1655513432', - 'otp' => '123', - ], - ], + 'otp' => '123' + ] + ] ]); $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Invalid `numbers` param: Value must a valid array no longer than 10 items and Invalid OTP. Please make sure the OTP is a 6 digit number', $response['body']['message']); /** Trying to pass an OTP with non numeric characters */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -3149,15 +3153,15 @@ class ProjectsConsoleClientTest extends Scope 'numbers' => [ [ 'phone' => '+1655513432', - 'otp' => '123re2', - ], - ], + 'otp' => '123re2' + ] + ] ]); $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Invalid `numbers` param: Value must a valid array no longer than 10 items and Invalid OTP. Please make sure the OTP is a 6 digit number', $response['body']['message']); /** Trying to pass an invalid phone number */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -3165,15 +3169,15 @@ class ProjectsConsoleClientTest extends Scope 'numbers' => [ [ 'phone' => '1655234', - 'otp' => '123456', - ], - ], + 'otp' => '123456' + ] + ] ]); $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Invalid `numbers` param: Value must a valid array no longer than 10 items and Phone number must start with a \'+\' can have a maximum of fifteen digits.', $response['body']['message']); /** Trying to pass a number longer than 15 digits */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -3181,15 +3185,15 @@ class ProjectsConsoleClientTest extends Scope 'numbers' => [ [ 'phone' => '+1234567890987654', - 'otp' => '123456', - ], - ], + 'otp' => '123456' + ] + ] ]); $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Invalid `numbers` param: Value must a valid array no longer than 10 items and Phone number must start with a \'+\' can have a maximum of fifteen digits.', $response['body']['message']); /** Trying to pass duplicate numbers */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -3197,13 +3201,13 @@ class ProjectsConsoleClientTest extends Scope 'numbers' => [ [ 'phone' => '+1655513432', - 'otp' => '123456', + 'otp' => '123456' ], [ 'phone' => '+1655513432', - 'otp' => '123456', - ], - ], + 'otp' => '123456' + ] + ] ]); $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Duplicate phone numbers are not allowed.', $response['body']['message']); @@ -3212,17 +3216,17 @@ class ProjectsConsoleClientTest extends Scope for ($i = 0; $i < 11; $i++) { $numbers[] = [ 'phone' => '+1655513432', - 'otp' => '123456', + 'otp' => '123456' ]; } /** Trying to pass more than 10 values */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', ], $this->getHeaders()), [ - 'numbers' => $numbers, + 'numbers' => $numbers ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -3231,16 +3235,16 @@ class ProjectsConsoleClientTest extends Scope /** * Test for success */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', ], $this->getHeaders()), [ - 'numbers' => [], + 'numbers' => [] ]); $this->assertEquals(200, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/mock-numbers', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/mock-numbers', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -3248,9 +3252,9 @@ class ProjectsConsoleClientTest extends Scope 'numbers' => [ [ 'phone' => '+1655513432', - 'otp' => '123456', - ], - ], + 'otp' => '123456' + ] + ] ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -3287,7 +3291,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); } - public function test_update_project_auth_password_dictionary(): void + public function testUpdateProjectAuthPasswordDictionary(): void { $data = $this->setupProjectWithAuthLimit(); $id = $data['projectId']; @@ -3308,7 +3312,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, ]), [ 'userId' => ID::unique(), - 'email' => uniqid().'user@localhost.test', + 'email' => uniqid() . 'user@localhost.test', 'password' => $password, 'name' => $name, ]); @@ -3324,7 +3328,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-mode' => 'admin', ]), [ 'userId' => ID::unique(), - 'email' => uniqid().'user@localhost.test', + 'email' => uniqid() . 'user@localhost.test', 'password' => 'password', 'name' => 'Cristiano Ronaldo', ]); @@ -3333,7 +3337,7 @@ class ProjectsConsoleClientTest extends Scope /** * Enable Disctionary */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/password-dictionary', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/password-dictionary', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -3353,7 +3357,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, ]), [ 'userId' => ID::unique(), - 'email' => uniqid().'user@localhost.test', + 'email' => uniqid() . 'user@localhost.test', 'password' => $password, 'name' => $name, ]); @@ -3369,7 +3373,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-mode' => 'admin', ]), [ 'userId' => ID::unique(), - 'email' => uniqid().'user@localhost.test', + 'email' => uniqid() . 'user@localhost.test', 'password' => 'password', 'name' => 'Cristiano Ronaldo', ]); @@ -3381,16 +3385,17 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, ]); - $response = $this->client->call(Client::METHOD_PATCH, '/users/'.$userId.'/password', $headers, [ + $response = $this->client->call(Client::METHOD_PATCH, '/users/' . $userId . '/password', $headers, [ 'password' => $password, ]); $this->assertEquals(400, $response['headers']['status-code']); + /** * Reset */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/password-history', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/password-history', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -3404,7 +3409,7 @@ class ProjectsConsoleClientTest extends Scope /** * Reset */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/password-dictionary', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/password-dictionary', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -3416,7 +3421,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(false, $response['body']['authPasswordDictionary']); } - public function test_update_disallow_personal_data(): void + public function testUpdateDisallowPersonalData(): void { $data = $this->setupProjectData(); $id = $data['projectId']; @@ -3424,7 +3429,7 @@ class ProjectsConsoleClientTest extends Scope /** * Enable Disallowing of Personal Data */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/personal-data', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/personal-data', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -3438,7 +3443,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for failure */ - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $password = 'password'; $name = 'username'; $userId = ID::unique(); @@ -3451,7 +3456,7 @@ class ProjectsConsoleClientTest extends Scope 'email' => $email, 'password' => $email, 'name' => $name, - 'userId' => $userId, + 'userId' => $userId ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -3466,7 +3471,7 @@ class ProjectsConsoleClientTest extends Scope 'email' => $email, 'password' => $name, 'name' => $name, - 'userId' => $userId, + 'userId' => $userId ]); $phone = '+123456789'; @@ -3479,7 +3484,7 @@ class ProjectsConsoleClientTest extends Scope 'password' => $phone, 'name' => $name, 'userId' => $userId, - 'phone' => $phone, + 'phone' => $phone ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -3487,7 +3492,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(Exception::USER_PASSWORD_PERSONAL_DATA, $response['body']['type']); /** Test for success */ - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $password = 'password'; $name = 'username'; $userId = ID::unique(); @@ -3499,7 +3504,7 @@ class ProjectsConsoleClientTest extends Scope 'email' => $email, 'password' => $password, 'name' => $name, - 'userId' => $userId, + 'userId' => $userId ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -3510,14 +3515,14 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-mode' => 'admin', ]), [ // Empty password - 'email' => uniqid().'user@localhost.test', + 'email' => uniqid() . 'user@localhost.test', 'name' => 'User', 'userId' => ID::unique(), ]); $this->assertEquals(201, $response['headers']['status-code']); - $email = uniqid().'user@localhost.test'; + $email = uniqid() . 'user@localhost.test'; $userId = ID::unique(); $response = $this->client->call(Client::METHOD_POST, '/users', array_merge($this->getHeaders(), [ 'content-type' => 'application/json', @@ -3528,15 +3533,16 @@ class ProjectsConsoleClientTest extends Scope 'password' => $password, 'name' => $name, 'userId' => $userId, - 'phone' => $phone, + 'phone' => $phone ]); $this->assertEquals(201, $response['headers']['status-code']); + /** * Reset */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/auth/personal-data', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/auth/personal-data', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.1', @@ -3548,12 +3554,12 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(false, $response['body']['authPersonalDataCheck']); } - public function test_update_project_api_status(): void + public function testUpdateProjectApiStatus(): void { $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'teamId' => ID::unique(), 'name' => 'Project Test', @@ -3566,12 +3572,12 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -3585,11 +3591,11 @@ class ProjectsConsoleClientTest extends Scope */ foreach ($protocols as $key) { - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/api', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/api', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'api' => $key, 'status' => false, @@ -3598,16 +3604,16 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals(false, $response['body']['protocolStatusFor'.ucfirst($key)]); + $this->assertEquals(false, $response['body']['protocolStatusFor' . ucfirst($key)]); } /** @@ -3615,11 +3621,11 @@ class ProjectsConsoleClientTest extends Scope */ foreach ($protocols as $key) { - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/api', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/api', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'api' => $key, 'status' => true, @@ -3628,25 +3634,25 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals(true, $response['body']['protocolStatusFor'.ucfirst($key)]); + $this->assertEquals(true, $response['body']['protocolStatusFor' . ucfirst($key)]); } } - public function test_update_project_api_status_realtime_backwards_compat(): void + public function testUpdateProjectApiStatusRealtimeBackwardsCompat(): void { $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'teamId' => ID::unique(), 'name' => 'Project Test', @@ -3658,12 +3664,12 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -3673,11 +3679,11 @@ class ProjectsConsoleClientTest extends Scope /** * Test that "realtime" gets renamed to "websocket" via request filter */ - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/api', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/api', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'api' => 'realtime', 'status' => false, @@ -3685,22 +3691,22 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(false, $response['body']['protocolStatusForWebsocket']); // Re-enable via old "realtime" name - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/api', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/api', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'api' => 'realtime', 'status' => true, @@ -3708,23 +3714,23 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(true, $response['body']['protocolStatusForWebsocket']); } - public function test_update_project_service_status_admin(): array + public function testUpdateProjectServiceStatusAdmin(): array { $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'teamId' => ID::unique(), 'name' => 'Project Test', @@ -3736,35 +3742,35 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'projectId' => ID::unique(), 'name' => 'Project Test', 'teamId' => $team['body']['$id'], - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); $this->assertNotEmpty($project['body']['$id']); $id = $project['body']['$id']; - $services = require __DIR__.'/../../../../app/config/services.php'; + $services = require(__DIR__ . '/../../../../app/config/services.php'); /** * Test for Disabled */ foreach ($services as $service) { - if (! $service['optional']) { + if (!$service['optional']) { continue; } $key = $service['key'] ?? ''; - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/service', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/service', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'service' => $key, 'status' => false, @@ -3773,40 +3779,41 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals(false, $response['body']['serviceStatusFor'.ucfirst($key)]); + $this->assertEquals(false, $response['body']['serviceStatusFor' . ucfirst($key)]); } /** * Admin request must succeed */ + $response = $this->client->call(Client::METHOD_GET, '/functions', array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', // 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-project' => $id, - 'cookie' => 'a_session_console='.$this->getRoot()['session'], - 'x-appwrite-mode' => 'admin', + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], + 'x-appwrite-mode' => 'admin' ])); $this->assertEquals(200, $response['headers']['status-code']); foreach ($services as $service) { - if (! $service['optional']) { + if (!$service['optional']) { continue; } $key = $service['key'] ?? ''; - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/service/', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/service/', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', @@ -3819,28 +3826,28 @@ class ProjectsConsoleClientTest extends Scope return ['projectId' => $id]; } - public function test_update_project_service_status(): void + public function testUpdateProjectServiceStatus(): void { $data = $this->setupProjectWithServicesDisabled(); $id = $data['projectId']; - $services = require __DIR__.'/../../../../app/config/services.php'; + $services = require(__DIR__ . '/../../../../app/config/services.php'); /** * Test for Disabled */ foreach ($services as $service) { - if (! $service['optional']) { + if (!$service['optional']) { continue; } $key = $service['key'] ?? ''; - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/service', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/service', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'service' => $key, 'status' => false, @@ -3849,16 +3856,16 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals(false, $response['body']['serviceStatusFor'.ucfirst($key)]); + $this->assertEquals(false, $response['body']['serviceStatusFor' . ucfirst($key)]); } /** @@ -3877,7 +3884,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $id, ]), [ 'teamId' => ID::unique(), - 'name' => 'Arsenal', + 'name' => 'Arsenal' ]); $this->assertEquals(403, $response['headers']['status-code']); @@ -3885,7 +3892,7 @@ class ProjectsConsoleClientTest extends Scope // Cleanup foreach ($services as $service) { - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/service/', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/service/', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', @@ -3896,28 +3903,28 @@ class ProjectsConsoleClientTest extends Scope } } - public function test_update_project_service_status_server(): void + public function testUpdateProjectServiceStatusServer(): void { $data = $this->setupProjectWithServicesDisabled(); $id = $data['projectId']; - $services = require __DIR__.'/../../../../app/config/services.php'; + $services = require(__DIR__ . '/../../../../app/config/services.php'); /** * Test for Disabled */ foreach ($services as $service) { - if (! $service['optional']) { + if (!$service['optional']) { continue; } $key = $service['key'] ?? ''; - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/service', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/service', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'service' => $key, 'status' => false, @@ -3926,23 +3933,23 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ])); $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']['$id']); - $this->assertEquals(false, $response['body']['serviceStatusFor'.ucfirst($key)]); + $this->assertEquals(false, $response['body']['serviceStatusFor' . ucfirst($key)]); } // Create API Key - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), [ 'keyId' => ID::unique(), 'name' => 'Key Test', @@ -3961,7 +3968,7 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $id, 'x-appwrite-key' => $keySecret, - 'x-sdk-name' => 'python', + 'x-sdk-name' => 'python' ])); $this->assertEquals(200, $response['headers']['status-code']); @@ -3970,19 +3977,19 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $id, 'x-appwrite-key' => $keySecret, - 'x-sdk-name' => 'php', + 'x-sdk-name' => 'php' ]), [ 'teamId' => ID::unique(), - 'name' => 'Arsenal', + 'name' => 'Arsenal' ]); $this->assertEquals(201, $response['headers']['status-code']); /** Check that the API key has been updated */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), []); $this->assertEquals(200, $response['headers']['status-code']); @@ -3995,16 +4002,16 @@ class ProjectsConsoleClientTest extends Scope // Cleanup - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_console='.$this->getRoot()['session'], + 'cookie' => 'a_session_console=' . $this->getRoot()['session'], ]), []); $this->assertEquals(204, $response['headers']['status-code']); foreach ($services as $service) { - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/service/', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $id . '/service/', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.0', @@ -4015,7 +4022,7 @@ class ProjectsConsoleClientTest extends Scope } } - public function test_create_project_webhook(): void + public function testCreateProjectWebhook(): void { $data = $this->setupProjectData(); $id = $data['projectId']; @@ -4023,7 +4030,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/webhooks', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), [ 'webhookId' => 'unique()', 'name' => 'Webhook Test', @@ -4050,7 +4057,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/webhooks', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), [ 'webhookId' => 'unique()', 'name' => 'Webhook Test', @@ -4066,7 +4073,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/webhooks', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), [ 'webhookId' => 'unique()', 'name' => 'Webhook Test', @@ -4077,7 +4084,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); } - public function test_list_project_webhook(): void + public function testListProjectWebhook(): void { $data = $this->setupProjectWithWebhook(); $id = $data['projectId']; @@ -4085,7 +4092,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, '/webhooks', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), []); $this->assertEquals(200, $response['headers']['status-code']); @@ -4097,16 +4104,16 @@ class ProjectsConsoleClientTest extends Scope */ } - public function test_get_project_webhook(): void + public function testGetProjectWebhook(): void { $data = $this->setupProjectWithWebhook(); $id = $data['projectId']; $webhookId = $data['webhookId']; - $response = $this->client->call(Client::METHOD_GET, '/webhooks/'.$webhookId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/webhooks/' . $webhookId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), []); $this->assertEquals(200, $response['headers']['status-code']); @@ -4125,22 +4132,22 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, '/webhooks/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), []); $this->assertEquals(404, $response['headers']['status-code']); } - public function test_update_project_webhook(): void + public function testUpdateProjectWebhook(): void { $data = $this->setupProjectWithWebhook(); $id = $data['projectId']; $webhookId = $data['webhookId']; - $response = $this->client->call(Client::METHOD_PUT, '/webhooks/'.$webhookId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/webhooks/' . $webhookId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), [ 'name' => 'Webhook Test Update', 'events' => ['users.*.delete', 'users.*.sessions.*.delete', 'buckets.*.files.*.create'], @@ -4162,10 +4169,10 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('', $response['body']['authUsername']); $this->assertEquals('', $response['body']['authPassword']); - $response = $this->client->call(Client::METHOD_GET, '/webhooks/'.$webhookId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/webhooks/' . $webhookId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), []); $this->assertEquals(200, $response['headers']['status-code']); @@ -4185,10 +4192,10 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_PUT, '/webhooks/'.$webhookId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/webhooks/' . $webhookId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), [ 'name' => 'Webhook Test Update', 'events' => ['users.*.delete', 'users.*.sessions.*.delete', 'buckets.*.files.*.unknown'], @@ -4198,10 +4205,10 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_PUT, '/webhooks/'.$webhookId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/webhooks/' . $webhookId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), [ 'name' => 'Webhook Test Update', 'events' => ['users.*.delete', 'users.*.sessions.*.delete', 'buckets.*.files.*.create'], @@ -4211,10 +4218,10 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_PUT, '/webhooks/'.$webhookId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/webhooks/' . $webhookId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), [ 'name' => 'Webhook Test Update', 'events' => ['users.*.delete', 'users.*.sessions.*.delete', 'buckets.*.files.*.create'], @@ -4224,17 +4231,17 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); } - public function test_update_project_webhook_signature(): void + public function testUpdateProjectWebhookSignature(): void { $data = $this->setupProjectWithWebhook(); $id = $data['projectId']; $webhookId = $data['webhookId']; $signatureKey = $data['signatureKey']; - $response = $this->client->call(Client::METHOD_PATCH, '/webhooks/'.$webhookId.'/secret', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/webhooks/' . $webhookId . '/secret', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders())); $this->assertEquals(200, $response['headers']['status-code']); @@ -4242,7 +4249,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertNotEquals($signatureKey, $response['body']['secret']); } - public function test_delete_project_webhook(): void + public function testDeleteProjectWebhook(): void { // Create a fresh project with webhook for deletion test $projectData = $this->setupProjectData(); @@ -4252,7 +4259,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/webhooks', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), [ 'webhookId' => 'unique()', 'name' => 'Webhook To Delete', @@ -4266,19 +4273,19 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); $webhookId = $response['body']['$id']; - $response = $this->client->call(Client::METHOD_DELETE, '/webhooks/'.$webhookId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/webhooks/' . $webhookId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), []); $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/webhooks/'.$webhookId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/webhooks/' . $webhookId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), []); $this->assertEquals(404, $response['headers']['status-code']); @@ -4289,7 +4296,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_DELETE, '/webhooks/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), []); $this->assertEquals(404, $response['headers']['status-code']); @@ -4297,12 +4304,12 @@ class ProjectsConsoleClientTest extends Scope // Keys - public function test_create_project_key(): void + public function testCreateProjectKey(): void { $data = $this->setupProjectData(); $id = $data['projectId']; - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4325,7 +4332,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS without key ID */ - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -4340,8 +4347,8 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS with custom ID */ - $customKeyId = \uniqid().'custom-id'; - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $customKeyId = \uniqid() . 'custom-id'; + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4356,7 +4363,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE with custom ID */ - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4370,7 +4377,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS with magic string ID */ - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4385,13 +4392,13 @@ class ProjectsConsoleClientTest extends Scope $data = array_merge($data, [ 'keyId' => $response['body']['$id'], - 'secret' => $response['body']['secret'], + 'secret' => $response['body']['secret'] ]); /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4403,14 +4410,15 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); } - public function test_list_project_key(): void + + public function testListProjectKey(): void { $data = $this->setupProjectWithKey(); $id = $data['projectId']; /** Create a second key with an expiry for query testing */ $expireDate = DateTime::addSeconds(new \DateTime(), 3600); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -4424,7 +4432,7 @@ class ProjectsConsoleClientTest extends Scope $key2Id = $response['body']['$id']; /** List all keys (no queries) — count depends on how many test methods ran before this in the same worker */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -4435,13 +4443,13 @@ class ProjectsConsoleClientTest extends Scope $this->assertCount($totalKeys, $response['body']['keys']); /** List keys with limit */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ Query::limit(1)->toString(), - ], + ] ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -4449,13 +4457,13 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals($totalKeys, $response['body']['total']); /** List keys with offset */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ Query::offset(1)->toString(), - ], + ] ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -4463,13 +4471,13 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals($totalKeys, $response['body']['total']); /** List keys with cursor after */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ Query::cursorAfter(new Document(['$id' => $data['keyId']]))->toString(), - ], + ] ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -4477,26 +4485,26 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals($totalKeys, $response['body']['total']); /** List keys filtering by expire (lessThan now — should match none) */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ Query::lessThan('expire', (new \DateTime())->format('Y-m-d H:i:s'))->toString(), - ], + ] ]); $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(0, $response['body']['total']); /** List keys filtering by expire (greaterThan now — should match the key with expiry) */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ Query::greaterThan('expire', (new \DateTime())->format('Y-m-d H:i:s'))->toString(), - ], + ] ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -4508,37 +4516,38 @@ class ProjectsConsoleClientTest extends Scope */ /** Test invalid query attribute */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ Query::equal('secret', ['test'])->toString(), - ], + ] ]); $this->assertEquals(400, $response['headers']['status-code']); /** Test invalid cursor */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ Query::cursorAfter(new Document(['$id' => 'invalid']))->toString(), - ], + ] ]); $this->assertEquals(400, $response['headers']['status-code']); } - public function test_get_project_key(): void + + public function testGetProjectKey(): void { $data = $this->setupProjectWithKey(); $id = $data['projectId']; $keyId = $data['keyId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -4559,7 +4568,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys/error', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -4567,7 +4576,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); } - public function test_validate_project_key(): void + public function testValidateProjectKey(): void { $data = $this->setupProjectData(); $projectId = $data['projectId']; @@ -4578,7 +4587,7 @@ class ProjectsConsoleClientTest extends Scope */ // Expiring key - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$projectId.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $projectId . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4591,7 +4600,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/users', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-key' => $response['body']['secret'], + 'x-appwrite-key' => $response['body']['secret'] ], [ 'userId' => ID::unique(), ]); @@ -4599,7 +4608,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); // No expiry - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$projectId.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $projectId . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4612,7 +4621,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, '/health', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-key' => $response['body']['secret'], + 'x-appwrite-key' => $response['body']['secret'] ], []); $this->assertEquals(200, $response['headers']['status-code']); @@ -4622,7 +4631,7 @@ class ProjectsConsoleClientTest extends Scope */ // Expired key - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$projectId.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $projectId . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4635,7 +4644,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, '/health', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-key' => $response['body']['secret'], + 'x-appwrite-key' => $response['body']['secret'] ]); $this->assertEquals(401, $response['headers']['status-code']); @@ -4658,13 +4667,13 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, "/storage/buckets/{$bucketId}/files", [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-key' => 'invalid-key', + 'x-appwrite-key' => 'invalid-key' ]); $this->assertEquals(401, $response['headers']['status-code']); // Invalid scopes - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$projectId.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $projectId . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4677,7 +4686,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, '/users', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-key' => $response['body']['secret'], + 'x-appwrite-key' => $response['body']['secret'] ]); $this->assertEquals(401, $response['headers']['status-code']); @@ -4691,14 +4700,14 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Project Test 2', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $response['headers']['status-code']); $project2Id = $response['body']['$id']; - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$project2Id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $project2Id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4711,19 +4720,20 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, '/health', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-key' => $response['body']['secret'], + 'x-appwrite-key' => $response['body']['secret'] ]); $this->assertEquals(401, $response['headers']['status-code']); } - public function test_update_project_key(): void + + public function testUpdateProjectKey(): void { $data = $this->setupProjectWithKey(); $id = $data['projectId']; $keyId = $data['keyId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4746,7 +4756,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertArrayHasKey('accessedAt', $response['body']); $this->assertEmpty($response['body']['accessedAt']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -4768,7 +4778,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -4779,13 +4789,13 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); } - public function test_delete_project_key(): void + public function testDeleteProjectKey(): void { // Create a fresh key for deletion testing (cannot use cached key) $projectData = $this->setupProjectData(); $id = $projectData['projectId']; - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -4797,7 +4807,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); $keyId = $response['body']['$id']; - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -4805,7 +4815,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -4815,7 +4825,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/keys/error', array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/keys/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -4823,7 +4833,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); } - public function test_create_project_key_outdated(): void + public function testCreateProjectKeyOutdated(): void { $data = $this->setupProjectData(); $id = $data['projectId']; @@ -4832,13 +4842,13 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'projectId' => $id, + 'projectId' => $id ]); $this->assertEquals(201, $response['headers']['status-code']); $this->assertContains('users.read', $response['body']['scopes']); $this->assertNotEmpty($response['body']['secret']); - $this->assertStringStartsNotWith(API_KEY_STANDARD.'_', $response['body']['secret']); + $this->assertStringStartsNotWith(API_KEY_STANDARD . '_', $response['body']['secret']); $keyId = $response['body']['$id']; $secret = $response['body']['secret']; @@ -4846,12 +4856,12 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_GET, '/users', [ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-key' => $secret, + 'x-appwrite-key' => $secret ], []); $this->assertEquals(200, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/keys/'.$keyId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/keys/' . $keyId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -4862,13 +4872,13 @@ class ProjectsConsoleClientTest extends Scope // JWT Keys - public function test_jwt_key(): void + public function testJWTKey(): void { $data = $this->setupProjectData(); $id = $data['projectId']; // Create JWT key - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/jwts', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/jwts', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.2', @@ -4917,12 +4927,12 @@ class ProjectsConsoleClientTest extends Scope // Platforms - public function test_create_project_platform(): void + public function testCreateProjectPlatform(): void { $data = $this->setupProjectData(); $id = $data['projectId']; - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -4942,7 +4952,7 @@ class ProjectsConsoleClientTest extends Scope $data = array_merge($data, ['platformWebId' => $response['body']['$id']]); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -4962,7 +4972,7 @@ class ProjectsConsoleClientTest extends Scope $data = array_merge($data, ['platformFultteriOSId' => $response['body']['$id']]); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -4982,7 +4992,7 @@ class ProjectsConsoleClientTest extends Scope $data = array_merge($data, ['platformFultterAndroidId' => $response['body']['$id']]); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5002,7 +5012,7 @@ class ProjectsConsoleClientTest extends Scope $data = array_merge($data, ['platformFultterWebId' => $response['body']['$id']]); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5022,7 +5032,7 @@ class ProjectsConsoleClientTest extends Scope $data = array_merge($data, ['platformAppleIosId' => $response['body']['$id']]); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5042,7 +5052,7 @@ class ProjectsConsoleClientTest extends Scope $data = array_merge($data, ['platformAppleMacOsId' => $response['body']['$id']]); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5062,7 +5072,7 @@ class ProjectsConsoleClientTest extends Scope $data = array_merge($data, ['platformAppleWatchOsId' => $response['body']['$id']]); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5085,7 +5095,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5098,13 +5108,13 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); } - public function test_list_project_platform(): void + public function testListProjectPlatform(): void { $data = $this->setupProjectWithPlatform(); $id = $data['projectId']; $this->assertEventually(function () use ($id) { - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5121,14 +5131,14 @@ class ProjectsConsoleClientTest extends Scope */ } - public function test_get_project_platform(): void + public function testGetProjectPlatform(): void { $data = $this->setupProjectWithPlatform(); $id = $data['projectId']; $platformWebId = $data['platformWebId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformWebId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5145,7 +5155,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultteriOSId = $data['platformFultteriOSId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformFultteriOSId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformFultteriOSId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5162,7 +5172,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultterAndroidId = $data['platformFultterAndroidId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformFultterAndroidId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformFultterAndroidId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5179,7 +5189,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultterWebId = $data['platformFultterWebId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformFultterWebId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformFultterWebId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5196,7 +5206,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleIosId = $data['platformAppleIosId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformAppleIosId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformAppleIosId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5213,7 +5223,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleMacOsId = $data['platformAppleMacOsId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformAppleMacOsId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformAppleMacOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5230,7 +5240,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleWatchOsId = $data['platformAppleWatchOsId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformAppleWatchOsId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformAppleWatchOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5247,7 +5257,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleTvOsId = $data['platformAppleTvOsId']; - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformAppleTvOsId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformAppleTvOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5265,7 +5275,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/error', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5274,14 +5284,14 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); } - public function test_update_project_platform(): void + public function testUpdateProjectPlatform(): void { $data = $this->setupProjectWithPlatform(); $id = $data['projectId']; $platformWebId = $data['platformWebId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/' . $platformWebId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5301,7 +5311,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultteriOSId = $data['platformFultteriOSId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformFultteriOSId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/' . $platformFultteriOSId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5321,7 +5331,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultterAndroidId = $data['platformFultterAndroidId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformFultterAndroidId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/' . $platformFultterAndroidId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5341,7 +5351,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultterWebId = $data['platformFultterWebId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformFultterWebId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/' . $platformFultterWebId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5361,7 +5371,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleIosId = $data['platformAppleIosId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformAppleIosId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/' . $platformAppleIosId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5381,7 +5391,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleMacOsId = $data['platformAppleMacOsId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformAppleMacOsId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/' . $platformAppleMacOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5401,7 +5411,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleWatchOsId = $data['platformAppleWatchOsId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformAppleWatchOsId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/' . $platformAppleWatchOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5421,7 +5431,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleTvOsId = $data['platformAppleTvOsId']; - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformAppleTvOsId, array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/' . $platformAppleTvOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5442,7 +5452,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/error', array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $id . '/platforms/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5454,14 +5464,14 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); } - public function test_delete_project_platform(): void + public function testDeleteProjectPlatform(): void { // Create a fresh project with platforms for deletion testing (cannot use cached platforms) $projectData = $this->setupProjectData(); $id = $projectData['projectId']; // Create web platform - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5474,7 +5484,7 @@ class ProjectsConsoleClientTest extends Scope $platformWebId = $response['body']['$id']; // Create flutter-ios platform - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5487,7 +5497,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultteriOSId = $response['body']['$id']; // Create flutter-android platform - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5500,7 +5510,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultterAndroidId = $response['body']['$id']; // Create flutter-web platform - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5513,7 +5523,7 @@ class ProjectsConsoleClientTest extends Scope $platformFultterWebId = $response['body']['$id']; // Create apple-ios platform - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5526,7 +5536,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleIosId = $response['body']['$id']; // Create apple-macos platform - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5539,7 +5549,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleMacOsId = $response['body']['$id']; // Create apple-watchos platform - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5552,7 +5562,7 @@ class ProjectsConsoleClientTest extends Scope $platformAppleWatchOsId = $response['body']['$id']; // Create apple-tvos platform - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/platforms', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5564,7 +5574,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); $platformAppleTvOsId = $response['body']['$id']; - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/platforms/' . $platformWebId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5573,7 +5583,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformWebId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5581,7 +5591,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformFultteriOSId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/platforms/' . $platformFultteriOSId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5590,7 +5600,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformFultteriOSId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformFultteriOSId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5598,7 +5608,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformFultterAndroidId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/platforms/' . $platformFultterAndroidId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5607,7 +5617,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformFultterAndroidId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformFultterAndroidId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5615,7 +5625,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformFultterWebId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/platforms/' . $platformFultterWebId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5624,7 +5634,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformFultterWebId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformFultterWebId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5632,7 +5642,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformAppleIosId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/platforms/' . $platformAppleIosId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5641,7 +5651,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformAppleIosId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformAppleIosId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5649,7 +5659,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformAppleMacOsId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/platforms/' . $platformAppleMacOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5658,7 +5668,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformAppleMacOsId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformAppleMacOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5666,7 +5676,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformAppleWatchOsId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/platforms/' . $platformAppleWatchOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5675,7 +5685,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformAppleWatchOsId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformAppleWatchOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5683,7 +5693,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformAppleTvOsId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $id . '/platforms/' . $platformAppleTvOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5692,7 +5702,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); $this->assertEmpty($response['body']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformAppleTvOsId, array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $id . '/platforms/' . $platformAppleTvOsId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.8.0', @@ -5706,13 +5716,13 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_DELETE, '/webhooks/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $id, - 'x-appwrite-mode' => 'admin', + 'x-appwrite-mode' => 'admin' ], $this->getHeaders()), []); $this->assertEquals(404, $response['headers']['status-code']); } - public function test_delete_project(): array + public function testDeleteProject(): array { $data = []; @@ -5739,7 +5749,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -5750,14 +5760,14 @@ class ProjectsConsoleClientTest extends Scope $projectId = $project['body']['$id']; // Ensure I can get both team and project - $team = $this->client->call(Client::METHOD_GET, '/teams/'.$teamId, array_merge([ + $team = $this->client->call(Client::METHOD_GET, '/teams/' . $teamId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(200, $team['headers']['status-code']); - $project = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId, array_merge([ + $project = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -5766,7 +5776,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $project['headers']['status-code']); // Delete Project - $project = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId, array_merge([ + $project = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); @@ -5774,14 +5784,14 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $project['headers']['status-code']); // Ensure I can get team but not a project - $team = $this->client->call(Client::METHOD_GET, '/teams/'.$teamId, array_merge([ + $team = $this->client->call(Client::METHOD_GET, '/teams/' . $teamId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(200, $team['headers']['status-code']); - $project = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId, array_merge([ + $project = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', @@ -5792,7 +5802,7 @@ class ProjectsConsoleClientTest extends Scope return $data; } - public function test_delete_shared_project(): void + public function testDeleteSharedProject(): void { $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ 'content-type' => 'application/json', @@ -5813,7 +5823,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project 1', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $project2 = $this->client->call(Client::METHOD_POST, '/projects', array_merge([ @@ -5824,14 +5834,14 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Amazing Project 2', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $project1Id = $project1['body']['$id']; $project2Id = $project2['body']['$id']; // Create user in each project - $key1 = $this->client->call(Client::METHOD_POST, '/projects/'.$project1Id.'/keys', array_merge([ + $key1 = $this->client->call(Client::METHOD_POST, '/projects/' . $project1Id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -5852,7 +5862,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $user1['headers']['status-code']); - $key2 = $this->client->call(Client::METHOD_POST, '/projects/'.$project2Id.'/keys', array_merge([ + $key2 = $this->client->call(Client::METHOD_POST, '/projects/' . $project2Id . '/keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -5874,7 +5884,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $user2['headers']['status-code']); // Delete project 1 - $project1 = $this->client->call(Client::METHOD_DELETE, '/projects/'.$project1Id, array_merge([ + $project1 = $this->client->call(Client::METHOD_DELETE, '/projects/' . $project1Id, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); @@ -5883,7 +5893,7 @@ class ProjectsConsoleClientTest extends Scope // Ensure project 2 user is still there $this->assertEventually(function () use ($user2, $project2Id, $key2) { - $response = $this->client->call(Client::METHOD_GET, '/users/'.$user2['body']['$id'], [ + $response = $this->client->call(Client::METHOD_GET, '/users/' . $user2['body']['$id'], [ 'content-type' => 'application/json', 'x-appwrite-project' => $project2Id, 'x-appwrite-key' => $key2['body']['secret'], @@ -5899,13 +5909,13 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-key' => $key2['body']['secret'], ], [ 'userId' => ID::unique(), - 'email' => 'test3@appwrite.io', + 'email' => 'test3@appwrite.io' ]); $this->assertEquals(201, $user3['headers']['status-code']); } - public function test_create_project_variable(): void + public function testCreateProjectVariable(): void { $data = $this->setupProjectData(); @@ -5920,7 +5930,7 @@ class ProjectsConsoleClientTest extends Scope 'variableId' => 'unique()', 'key' => 'APP_TEST_CREATE', 'value' => 'TESTINGVALUE', - 'secret' => false, + 'secret' => false ]); $this->assertEquals(201, $variable['headers']['status-code']); @@ -5937,7 +5947,7 @@ class ProjectsConsoleClientTest extends Scope 'variableId' => 'unique()', 'key' => 'APP_TEST_CREATE_1', 'value' => 'TESTINGVALUE_1', - 'secret' => true, + 'secret' => true ]); $this->assertEquals(201, $variable['headers']['status-code']); @@ -5955,7 +5965,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'variableId' => 'unique()', 'key' => 'APP_TEST_CREATE', - 'value' => 'ANOTHERTESTINGVALUE', + 'value' => 'ANOTHERTESTINGVALUE' ]); $this->assertEquals(409, $variable['headers']['status-code']); @@ -5967,8 +5977,8 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ 'variableId' => 'unique()', - 'key' => str_repeat('A', 256), - 'value' => 'TESTINGVALUE', + 'key' => str_repeat("A", 256), + 'value' => 'TESTINGVALUE' ]); $this->assertEquals(400, $variable['headers']['status-code']); @@ -5981,19 +5991,20 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'variableId' => 'unique()', 'key' => 'LONGKEY', - 'value' => str_repeat('#', 8193), + 'value' => str_repeat("#", 8193), ]); $this->assertEquals(400, $variable['headers']['status-code']); } - public function test_list_variables(): void + public function testListVariables(): void { $data = $this->setupProjectWithVariable(); /** * Test for SUCCESS */ + $response = $this->client->call(Client::METHOD_GET, '/project/variables', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], @@ -6005,37 +6016,38 @@ class ProjectsConsoleClientTest extends Scope $this->assertGreaterThanOrEqual(2, $response['body']['total']); } - public function test_get_variable(): void + public function testGetVariable(): void { $data = $this->setupProjectWithVariable(); /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_GET, '/project/variables/'.$data['variableId'], array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/project/variables/' . $data['variableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders())); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('APP_TEST', $response['body']['key']); - $this->assertEquals('TESTINGVALUE', $response['body']['value']); + $this->assertEquals("APP_TEST", $response['body']['key']); + $this->assertEquals("TESTINGVALUE", $response['body']['value']); - $response = $this->client->call(Client::METHOD_GET, '/project/variables/'.$data['secretVariableId'], array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/project/variables/' . $data['secretVariableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders())); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('APP_TEST_1', $response['body']['key']); + $this->assertEquals("APP_TEST_1", $response['body']['key']); $this->assertEmpty($response['body']['value']); $this->assertTrue($response['body']['secret']); /** * Test for FAILURE */ + $response = $this->client->call(Client::METHOD_GET, '/project/variables/NON_EXISTING_VARIABLE', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], @@ -6045,59 +6057,60 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); } - public function test_update_variable(): void + public function testUpdateVariable(): void { $data = $this->setupProjectWithVariable(); /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_PUT, '/project/variables/'.$data['variableId'], array_merge([ + + $response = $this->client->call(Client::METHOD_PUT, '/project/variables/' . $data['variableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ 'key' => 'APP_TEST_UPDATE', - 'value' => 'TESTINGVALUEUPDATED', + 'value' => 'TESTINGVALUEUPDATED' ]); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('APP_TEST_UPDATE', $response['body']['key']); - $this->assertEquals('TESTINGVALUEUPDATED', $response['body']['value']); + $this->assertEquals("APP_TEST_UPDATE", $response['body']['key']); + $this->assertEquals("TESTINGVALUEUPDATED", $response['body']['value']); - $variable = $this->client->call(Client::METHOD_GET, '/project/variables/'.$data['variableId'], array_merge([ + $variable = $this->client->call(Client::METHOD_GET, '/project/variables/' . $data['variableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders())); $this->assertEquals(200, $variable['headers']['status-code']); - $this->assertEquals('APP_TEST_UPDATE', $variable['body']['key']); - $this->assertEquals('TESTINGVALUEUPDATED', $variable['body']['value']); + $this->assertEquals("APP_TEST_UPDATE", $variable['body']['key']); + $this->assertEquals("TESTINGVALUEUPDATED", $variable['body']['value']); - $response = $this->client->call(Client::METHOD_PUT, '/project/variables/'.$data['secretVariableId'], array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/project/variables/' . $data['secretVariableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ 'key' => 'APP_TEST_UPDATE_1', - 'value' => 'TESTINGVALUEUPDATED_1', + 'value' => 'TESTINGVALUEUPDATED_1' ]); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals('APP_TEST_UPDATE_1', $response['body']['key']); + $this->assertEquals("APP_TEST_UPDATE_1", $response['body']['key']); $this->assertEmpty($response['body']['value']); - $variable = $this->client->call(Client::METHOD_GET, '/project/variables/'.$data['secretVariableId'], array_merge([ + $variable = $this->client->call(Client::METHOD_GET, '/project/variables/' . $data['secretVariableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders())); $this->assertEquals(200, $variable['headers']['status-code']); - $this->assertEquals('APP_TEST_UPDATE_1', $variable['body']['key']); + $this->assertEquals("APP_TEST_UPDATE_1", $variable['body']['key']); $this->assertEmpty($variable['body']['value']); - $response = $this->client->call(Client::METHOD_PUT, '/project/variables/'.$data['secretVariableId'], array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/project/variables/' . $data['secretVariableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', @@ -6119,15 +6132,15 @@ class ProjectsConsoleClientTest extends Scope $this->assertGreaterThanOrEqual(2, count($response['body']['variables'])); // Verify our updated variables exist (may not be at specific positions) $variableKeys = array_column($response['body']['variables'], 'key'); - $this->assertContains('APP_TEST_UPDATE', $variableKeys); - $this->assertContains('APP_TEST_UPDATE_1', $variableKeys); + $this->assertContains("APP_TEST_UPDATE", $variableKeys); + $this->assertContains("APP_TEST_UPDATE_1", $variableKeys); - $response = $this->client->call(Client::METHOD_PUT, '/project/variables/'.$data['variableId'], array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/project/variables/' . $data['variableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'value' => 'TESTINGVALUEUPDATED_2', + 'value' => 'TESTINGVALUEUPDATED_2' ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -6137,7 +6150,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_PUT, '/project/variables/'.$data['variableId'], array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/project/variables/' . $data['variableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', @@ -6145,26 +6158,26 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(400, $response['headers']['status-code']); - $longKey = str_repeat('A', 256); - $response = $this->client->call(Client::METHOD_PUT, '/project/variables/'.$data['variableId'], array_merge([ + $longKey = str_repeat("A", 256); + $response = $this->client->call(Client::METHOD_PUT, '/project/variables/' . $data['variableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ 'key' => $longKey, - 'value' => 'TESTINGVALUEUPDATED', + 'value' => 'TESTINGVALUEUPDATED' ]); $this->assertEquals(400, $response['headers']['status-code']); - $longValue = str_repeat('#', 8193); - $response = $this->client->call(Client::METHOD_PUT, '/project/variables/'.$data['variableId'], array_merge([ + $longValue = str_repeat("#", 8193); + $response = $this->client->call(Client::METHOD_PUT, '/project/variables/' . $data['variableId'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $data['projectId'], 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ 'key' => 'APP_TEST_UPDATE', - 'value' => $longValue, + 'value' => $longValue ]); $this->assertEquals(400, $response['headers']['status-code']); @@ -6175,13 +6188,13 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ 'key' => 'APP_TEST_UPDATE', - 'value' => 'TESTINGVALUEUPDATED', + 'value' => 'TESTINGVALUEUPDATED' ]); $this->assertEquals(404, $response['headers']['status-code']); } - public function test_delete_variable(): void + public function testDeleteVariable(): void { // Create a fresh project with variables for deletion testing $projectData = $this->setupProjectData(); @@ -6195,7 +6208,7 @@ class ProjectsConsoleClientTest extends Scope 'variableId' => 'unique()', 'key' => 'APP_TEST_DELETE', 'value' => 'TESTINGVALUE', - 'secret' => false, + 'secret' => false ]); $this->assertEquals(201, $variable['headers']['status-code']); @@ -6210,7 +6223,7 @@ class ProjectsConsoleClientTest extends Scope 'variableId' => 'unique()', 'key' => 'APP_TEST_DELETE_1', 'value' => 'TESTINGVALUE_1', - 'secret' => true, + 'secret' => true ]); $this->assertEquals(201, $variable['headers']['status-code']); @@ -6219,7 +6232,8 @@ class ProjectsConsoleClientTest extends Scope /** * Test for SUCCESS */ - $response = $this->client->call(Client::METHOD_DELETE, '/project/variables/'.$variableId, array_merge([ + + $response = $this->client->call(Client::METHOD_DELETE, '/project/variables/' . $variableId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $projectData['projectId'], 'x-appwrite-mode' => 'admin', @@ -6227,7 +6241,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(204, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/project/variables/'.$secretVariableId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/project/variables/' . $secretVariableId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $projectData['projectId'], 'x-appwrite-mode' => 'admin', @@ -6251,6 +6265,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ + $response = $this->client->call(Client::METHOD_DELETE, '/project/variables/NON_EXISTING_VARIABLE', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $projectData['projectId'], @@ -6263,8 +6278,9 @@ class ProjectsConsoleClientTest extends Scope /** * Devkeys Tests starts here ------------------------------------------------ */ + #[Group('abuseEnabled')] - public function test_create_project_dev_key(): void + public function testCreateProjectDevKey(): void { /** * Test for SUCCESS @@ -6272,15 +6288,15 @@ class ProjectsConsoleClientTest extends Scope $id = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testCreateProjectDevKey', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'name' => 'Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -6291,12 +6307,12 @@ class ProjectsConsoleClientTest extends Scope $this->assertEmpty($response['body']['accessedAt']); /** Create a second dev key */ - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); $this->assertEquals(201, $response['headers']['status-code']); @@ -6311,18 +6327,19 @@ class ProjectsConsoleClientTest extends Scope */ /** TEST expiry date is required */ - $res = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/dev-keys', array_merge([ + $res = $this->client->call(Client::METHOD_POST, '/projects/' . $id . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'name' => 'Key Test', + 'name' => 'Key Test' ]); $this->assertEquals(400, $res['headers']['status-code']); } + #[Group('abuseEnabled')] - public function test_list_project_dev_key(): void + public function testListProjectDevKey(): void { /** * Test for SUCCESS @@ -6330,25 +6347,25 @@ class ProjectsConsoleClientTest extends Scope $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testListProjectDevKey', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); /** Create devKey 1 */ $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); /** Create devKey 2 */ $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); /** List all dev keys */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -6357,20 +6374,20 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(2, $response['body']['total']); /** List dev keys with limit */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ - Query::limit(1)->toString(), - ], + Query::limit(1)->toString() + ] ]); $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(1, $response['body']['total']); /** List dev keys with search */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); @@ -6381,11 +6398,11 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('Dev Key Test', $response['body']['devKeys'][1]['name']); /** List dev keys with querying `expire` */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'queries' => [Query::lessThan('expire', (new \DateTime())->format('Y-m-d H:i:s'))->toString()], + 'queries' => [Query::lessThan('expire', (new \DateTime())->format('Y-m-d H:i:s'))->toString()] ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -6396,21 +6413,22 @@ class ProjectsConsoleClientTest extends Scope */ /** Test for search with invalid query */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ 'queries' => [ - Query::search('name', 'Invalid')->toString(), - ], + Query::search('name', 'Invalid')->toString() + ] ]); $this->assertEquals(400, $response['headers']['status-code']); $this->assertEquals('Invalid `queries` param: Invalid query: Attribute not found in schema: name', $response['body']['message']); } + #[Group('abuseEnabled')] - public function test_get_project_dev_key(): void + public function testGetProjectDevKey(): void { /** * Test for SUCCESS @@ -6418,16 +6436,16 @@ class ProjectsConsoleClientTest extends Scope $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testGetProjectDevKey', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $devKey = $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys/'.$devKey['$id'], array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys/' . $devKey['$id'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -6443,7 +6461,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys/error', array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -6452,7 +6470,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('abuseEnabled')] - public function test_get_dev_key_with_sdks(): void + public function testGetDevKeyWithSdks(): void { /** * Test for SUCCESS @@ -6460,13 +6478,13 @@ class ProjectsConsoleClientTest extends Scope $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testGetDevKeyWithSdks', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $devKey = $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); /** Use dev key with python sdk */ @@ -6474,10 +6492,10 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'x-appwrite-dev-key' => $devKey['secret'], - 'x-sdk-name' => 'python', + 'x-sdk-name' => 'python' ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(401, $res['headers']['status-code']); @@ -6486,15 +6504,15 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'x-appwrite-dev-key' => $devKey['secret'], - 'x-sdk-name' => 'php', + 'x-sdk-name' => 'php' ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(401, $res['headers']['status-code']); /** Get the dev key */ - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys/'.$devKey['$id'], array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys/' . $devKey['$id'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -6507,7 +6525,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('abuseEnabled')] - public function test_no_host_validation_with_dev_key(): void + public function testNoHostValidationWithDevKey(): void { /** * Test for SUCCESS @@ -6515,20 +6533,20 @@ class ProjectsConsoleClientTest extends Scope $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testNoHostValidationWithDevKey', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $devKey = $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); $provider = 'mock'; $appId = '1'; $secret = '123456'; - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId.'/oauth2', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/oauth2', array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -6541,23 +6559,23 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); /** Test oauth2 and get invalid `success` URL */ - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider, [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, ], [ 'success' => 'https://example.com', - 'failure' => 'https://example.com', + 'failure' => 'https://example.com' ]); $this->assertEquals(400, $response['headers']['status-code']); /** Test oauth2 with devKey and now flow works with untrusted URL too */ - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider, [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-dev-key' => $devKey['secret'], + 'x-appwrite-dev-key' => $devKey['secret'] ], [ 'success' => 'https://example.com', - 'failure' => 'https://example.com', + 'failure' => 'https://example.com' ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); @@ -6565,6 +6583,7 @@ class ProjectsConsoleClientTest extends Scope $location = $response['headers']['location']; + $locationClient = new Client(); $locationClient->setEndpoint(''); $locationClient->addHeader('x-appwrite-dev-key', $devKey['secret']); @@ -6590,27 +6609,27 @@ class ProjectsConsoleClientTest extends Scope $this->assertSame('https://example.com/#', $response['headers']['location']); /** Ensure any hostname is allowed */ - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider, [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'x-appwrite-dev-key' => $devKey['secret'], 'origin' => '', - 'referer' => 'https://domain-without-rule.com', + 'referer' => 'https://domain-without-rule.com' ], [ 'success' => 'https://domain-without-rule.com', - 'failure' => 'https://domain-without-rule.com', + 'failure' => 'https://domain-without-rule.com' ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider, [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'x-appwrite-dev-key' => $devKey['secret'], 'referer' => '', - 'origin' => 'https://domain-without-rule.com', + 'origin' => 'https://domain-without-rule.com' ], [ 'success' => 'https://domain-without-rule.com', - 'failure' => 'https://domain-without-rule.com', + 'failure' => 'https://domain-without-rule.com' ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); @@ -6629,7 +6648,7 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/account/sessions/magic-url', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-dev-key' => $devKey['secret'], + 'x-appwrite-dev-key' => $devKey['secret'] ], [ 'userId' => ID::unique(), 'email' => 'user@appwrite.io', @@ -6638,13 +6657,13 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(201, $response['headers']['status-code']); } - public function test_rule_o_auth_redirect(): void + public function testRuleOAuthRedirect(): void { // Prepare project $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testRuleOAuthRedirect', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $provider = 'mock'; @@ -6652,7 +6671,7 @@ class ProjectsConsoleClientTest extends Scope $secret = '123456'; // Prepare OAuth provider - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId.'/oauth2', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/oauth2', array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -6665,31 +6684,31 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); // Prepare rule. In reality this is site rule, but for testing, API rule is enough, and faster to prepare - $domain = \uniqid().'-with-rule.custom.localhost'; + $domain = \uniqid() . '-with-rule.custom.localhost'; $rule = $this->client->call(Client::METHOD_POST, '/proxy/rules/api', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'domain' => $domain, + 'domain' => $domain ]); $this->assertEquals(201, $rule['headers']['status-code']); // Ensure unknown domain cannot be redirect URL - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider, [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'referer' => 'https://'.$domain, + 'referer' => 'https://' . $domain, 'origin' => '', ], [ 'success' => 'https://domain-without-rule.com', - 'failure' => 'https://domain-without-rule.com', + 'failure' => 'https://domain-without-rule.com' ], followRedirects: false); $this->assertEquals(400, $response['headers']['status-code']); // Also ensure final step blocks unknown redirect URL - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider.'/redirect', [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider . '/redirect', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'origin' => '', @@ -6698,7 +6717,7 @@ class ProjectsConsoleClientTest extends Scope 'code' => 'any-code', 'state' => \json_encode([ 'success' => 'https://domain-without-rule.com', - 'failure' => 'https://domain-without-rule.com', + 'failure' => 'https://domain-without-rule.com' ]), 'error' => '', 'error_description' => '', @@ -6707,19 +6726,19 @@ class ProjectsConsoleClientTest extends Scope $this->assertStringContainsString('project_invalid_success_url', $response['body']); // Ensure rule's domain can be redirect URL - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider, [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider, [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'referer' => 'https://'.$domain, + 'referer' => 'https://' . $domain, 'origin' => '', ], [ - 'success' => 'https://'.$domain, - 'failure' => 'https://'.$domain, + 'success' => 'https://' . $domain, + 'failure' => 'https://' . $domain ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); // Also ensure final step allows redirect URL - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider.'/redirect', [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider . '/redirect', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'origin' => '', @@ -6727,20 +6746,20 @@ class ProjectsConsoleClientTest extends Scope ], [ 'code' => 'any-code', 'state' => \json_encode([ - 'success' => 'https://'.$domain, - 'failure' => 'https://'.$domain, + 'success' => 'https://' . $domain, + 'failure' => 'https://' . $domain ]), 'error' => '', 'error_deescription' => '', ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $this->assertStringContainsString('https://'.$domain, $response['headers']['location']); + $this->assertStringContainsString('https://' . $domain, $response['headers']['location']); // Ensure unknown domain cannot be redirect URL $response = $this->client->call(Client::METHOD_POST, '/account/sessions/magic-url', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'referer' => 'https://'.$domain, + 'referer' => 'https://' . $domain, 'origin' => '', ], [ 'userId' => ID::unique(), @@ -6753,23 +6772,23 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/account/sessions/magic-url', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'referer' => 'https://'.$domain, + 'referer' => 'https://' . $domain, 'origin' => '', ], [ 'userId' => ID::unique(), 'email' => 'user@appwrite.io', - 'url' => 'https://'.$domain, + 'url' => 'https://' . $domain, ]); $this->assertEquals(201, $response['headers']['status-code']); } - public function test_o_auth_redirect_with_custom_scheme_state(): void + public function testOAuthRedirectWithCustomSchemeState(): void { // Prepare project $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testOAuthRedirectWithCustomSchemeState', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $provider = 'mock'; @@ -6777,7 +6796,7 @@ class ProjectsConsoleClientTest extends Scope $secret = '123456'; // Prepare OAuth provider - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId.'/oauth2', array_merge([ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId . '/oauth2', array_merge([ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -6789,13 +6808,13 @@ class ProjectsConsoleClientTest extends Scope ]); $this->assertEquals(200, $response['headers']['status-code']); - $scheme = 'appwrite-callback-'.$projectId; + $scheme = 'appwrite-callback-' . $projectId; $state = \json_encode([ - 'success' => $scheme.':///', - 'failure' => $scheme.':///', + 'success' => $scheme . ':///', + 'failure' => $scheme . ':///' ]); - $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/'.$provider.'/redirect', [ + $response = $this->client->call(Client::METHOD_GET, '/account/sessions/oauth2/' . $provider . '/redirect', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'origin' => '', @@ -6808,12 +6827,12 @@ class ProjectsConsoleClientTest extends Scope ], followRedirects: false); $this->assertEquals(301, $response['headers']['status-code']); - $this->assertStringStartsWith($scheme.'://', $response['headers']['location']); + $this->assertStringStartsWith($scheme . '://', $response['headers']['location']); $this->assertStringContainsString('error=', $response['headers']['location']); } #[Group('abuseEnabled')] - public function test_cors_with_dev_key(): void + public function testCorsWithDevKey(): void { /** * Test for SUCCESS @@ -6821,13 +6840,13 @@ class ProjectsConsoleClientTest extends Scope $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testCorsWithDevKey', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $devKey = $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); $origin = 'http://example.com'; @@ -6841,7 +6860,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $projectId, ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(403, $response['headers']['status-code']); @@ -6849,6 +6868,7 @@ class ProjectsConsoleClientTest extends Scope // you should not return a fallback origin for a disallowed host $this->assertNull($response['headers']['access-control-allow-origin'] ?? null); + /** * Test CORS with Dev Key (should bypass origin check) */ @@ -6856,17 +6876,17 @@ class ProjectsConsoleClientTest extends Scope 'origin' => $origin, 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-dev-key' => $devKey['secret'], + 'x-appwrite-dev-key' => $devKey['secret'] ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(401, $response['headers']['status-code']); $this->assertEquals($origin, $response['headers']['access-control-allow-origin'] ?? null); } - public function test_console_cors_with_trusted_project(): void + public function testConsoleCorsWithTrustedProject(): void { $trustedProjectIds = ['trusted-project', 'another-trusted-project']; // Set in env variable @@ -6878,17 +6898,17 @@ class ProjectsConsoleClientTest extends Scope $this->setupProject([ 'projectId' => $projectId, 'name' => 'Trusted project', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); // Add domain to trusted project; API for simplicity, in real work this will be site - $domain = \uniqid().'.custom.localhost'; + $domain = \uniqid() . '.custom.localhost'; $rule = $this->client->call(Client::METHOD_POST, '/proxy/rules/api', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'x-appwrite-mode' => 'admin', ], $this->getHeaders()), [ - 'domain' => $domain, + 'domain' => $domain ]); $this->assertEquals(201, $rule['headers']['status-code']); @@ -6902,7 +6922,7 @@ class ProjectsConsoleClientTest extends Scope [ 'content-type' => 'application/json', 'x-appwrite-project' => 'console', - 'origin' => 'http://'.$domain, + 'origin' => 'http://' . $domain ] ) ); @@ -6910,7 +6930,7 @@ class ProjectsConsoleClientTest extends Scope if (\in_array($projectId, $trustedProjectIds)) { // Trusted projects can $this->assertEquals(200, $currencies['headers']['status-code']); - $this->assertSame('http://'.$domain, $currencies['headers']['access-control-allow-origin']); + $this->assertSame('http://' . $domain, $currencies['headers']['access-control-allow-origin']); } else { // Untrusted projects cannot $this->assertEquals(403, $currencies['headers']['status-code']); @@ -6918,7 +6938,7 @@ class ProjectsConsoleClientTest extends Scope } } finally { // Cleanup - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -6929,7 +6949,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('abuseEnabled')] - public function test_no_rate_limit_with_dev_key(): void + public function testNoRateLimitWithDevKey(): void { /** * Test for SUCCESS @@ -6937,13 +6957,13 @@ class ProjectsConsoleClientTest extends Scope $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testNoRateLimitWithDevKey', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $devKey = $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); /** @@ -6955,7 +6975,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $projectId, ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(401, $response['headers']['status-code']); @@ -6965,7 +6985,7 @@ class ProjectsConsoleClientTest extends Scope 'x-appwrite-project' => $projectId, ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(429, $response['headers']['status-code']); @@ -6973,17 +6993,17 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-dev-key' => $devKey['secret'], + 'x-appwrite-dev-key' => $devKey['secret'] ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(401, $response['headers']['status-code']); /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_POST, '/projects/'.$projectId.'/dev-keys', array_merge([ + $response = $this->client->call(Client::METHOD_POST, '/projects/' . $projectId . '/dev-keys', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -6994,10 +7014,10 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-dev-key' => $response['body']['secret'], + 'x-appwrite-dev-key' => $response['body']['secret'] ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(429, $response['headers']['status-code']); @@ -7007,16 +7027,16 @@ class ProjectsConsoleClientTest extends Scope $devKey = $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test Expire 5 seconds', - 'expire' => DateTime::addSeconds(new \DateTime(), 5), + 'expire' => DateTime::addSeconds(new \DateTime(), 5) ]); $response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-dev-key' => $devKey['secret'], + 'x-appwrite-dev-key' => $devKey['secret'] ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(401, $response['headers']['status-code']); @@ -7024,31 +7044,31 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-dev-key' => $devKey['secret'], + 'x-appwrite-dev-key' => $devKey['secret'] ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(429, $response['headers']['status-code']); }, 15_000, 500); } #[Group('abuseEnabled')] - public function test_update_project_dev_key(): void + public function testUpdateProjectDevKey(): void { $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testUpdateProjectDevKey', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $devKey = $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); - $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$projectId.'/dev-keys/'.$devKey['$id'], array_merge([ + $response = $this->client->call(Client::METHOD_PUT, '/projects/' . $projectId . '/dev-keys/' . $devKey['$id'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ @@ -7063,7 +7083,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertArrayHasKey('accessedAt', $response['body']); $this->assertEmpty($response['body']['accessedAt']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys/'.$devKey['$id'], array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys/' . $devKey['$id'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -7077,21 +7097,21 @@ class ProjectsConsoleClientTest extends Scope } #[Group('abuseEnabled')] - public function test_delete_project_dev_key(): void + public function testDeleteProjectDevKey(): void { $projectId = $this->setupProject([ 'projectId' => ID::unique(), 'name' => 'testDeleteProjectDevKey', - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $devKey = $this->setupDevKey([ 'projectId' => $projectId, 'name' => 'Dev Key Test', - 'expire' => DateTime::addSeconds(new \DateTime(), 36000), + 'expire' => DateTime::addSeconds(new \DateTime(), 36000) ]); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId.'/dev-keys/'.$devKey['$id'], array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId . '/dev-keys/' . $devKey['$id'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -7105,14 +7125,14 @@ class ProjectsConsoleClientTest extends Scope $response = $this->client->call(Client::METHOD_POST, '/account/sessions/email', [ 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, - 'x-appwrite-dev-key' => $devKey['secret'], + 'x-appwrite-dev-key' => $devKey['secret'] ], [ 'email' => 'user@appwrite.io', - 'password' => 'password', + 'password' => 'password' ]); $this->assertEquals(429, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_GET, '/projects/'.$projectId.'/dev-keys/'.$devKey['$id'], array_merge([ + $response = $this->client->call(Client::METHOD_GET, '/projects/' . $projectId . '/dev-keys/' . $devKey['$id'], array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -7122,7 +7142,7 @@ class ProjectsConsoleClientTest extends Scope /** * Test for FAILURE */ - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId.'/dev-keys/error', array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId . '/dev-keys/error', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), []); @@ -7133,7 +7153,8 @@ class ProjectsConsoleClientTest extends Scope /** * Devkeys Tests ends here ------------------------------------------------ */ - public function test_project_labels(): void + + public function testProjectLabels(): void { // Setup: Prepare team $team = $this->client->call(Client::METHOD_POST, '/teams', array_merge([ @@ -7156,7 +7177,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Test project - Labels 1', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -7165,11 +7186,11 @@ class ProjectsConsoleClientTest extends Scope $projectId = $project['body']['$id']; // Apply labels - $project = $this->client->call(Client::METHOD_PUT, '/projects/'.$projectId.'/labels', array_merge([ + $project = $this->client->call(Client::METHOD_PUT, '/projects/' . $projectId . '/labels', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'labels' => ['vip', 'imagine', 'blocked'], + 'labels' => ['vip', 'imagine', 'blocked'] ]); $this->assertEquals(200, $project['headers']['status-code']); @@ -7180,11 +7201,11 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('blocked', $project['body']['labels'][2]); // Update labels - $project = $this->client->call(Client::METHOD_PUT, '/projects/'.$projectId.'/labels', array_merge([ + $project = $this->client->call(Client::METHOD_PUT, '/projects/' . $projectId . '/labels', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'labels' => ['nonvip', 'imagine'], + 'labels' => ['nonvip', 'imagine'] ]); $this->assertEquals(200, $project['headers']['status-code']); $this->assertIsArray($project['body']['labels']); @@ -7200,7 +7221,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'queries' => [ Query::contains('labels', ['nonvip'])->toString(), - ], + ] ]); $this->assertEquals(200, $projects['headers']['status-code']); $this->assertEquals(1, $projects['body']['total']); @@ -7213,7 +7234,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'queries' => [ Query::contains('labels', ['vip'])->toString(), - ], + ] ]); $this->assertEquals(200, $projects['headers']['status-code']); $this->assertEquals(0, $projects['body']['total']); @@ -7225,7 +7246,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'queries' => [ Query::contains('labels', ['imagine'])->toString(), - ], + ] ]); $this->assertEquals(200, $projects['headers']['status-code']); $this->assertEquals(1, $projects['body']['total']); @@ -7238,7 +7259,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'queries' => [ Query::contains('labels', ['nonvip', 'imagine'])->toString(), - ], + ] ]); $this->assertEquals(200, $projects['headers']['status-code']); $this->assertEquals(1, $projects['body']['total']); @@ -7253,7 +7274,7 @@ class ProjectsConsoleClientTest extends Scope 'projectId' => ID::unique(), 'name' => 'Test project - Labels 2', 'teamId' => $teamId, - 'region' => System::getEnv('_APP_REGION', 'default'), + 'region' => System::getEnv('_APP_REGION', 'default') ]); $this->assertEquals(201, $project['headers']['status-code']); @@ -7261,11 +7282,11 @@ class ProjectsConsoleClientTest extends Scope $this->assertCount(0, $project['body']['labels']); $projectId2 = $project['body']['$id']; - $project = $this->client->call(Client::METHOD_PUT, '/projects/'.$projectId2.'/labels', array_merge([ + $project = $this->client->call(Client::METHOD_PUT, '/projects/' . $projectId2 . '/labels', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders()), [ - 'labels' => ['vip', 'imagine'], + 'labels' => ['vip', 'imagine'] ]); $this->assertEquals(200, $project['headers']['status-code']); $this->assertIsArray($project['body']['labels']); @@ -7281,7 +7302,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'queries' => [ Query::contains('labels', ['imagine'])->toString(), - ], + ] ]); $this->assertEquals(200, $projects['headers']['status-code']); $this->assertEquals(2, $projects['body']['total']); @@ -7296,7 +7317,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'queries' => [ Query::contains('labels', ['vip'])->toString(), - ], + ] ]); $this->assertEquals(200, $projects['headers']['status-code']); $this->assertEquals(1, $projects['body']['total']); @@ -7311,7 +7332,7 @@ class ProjectsConsoleClientTest extends Scope 'queries' => [ Query::contains('labels', ['vip'])->toString(), Query::contains('labels', ['imagine'])->toString(), - ], + ] ]); $this->assertEquals(200, $projects['headers']['status-code']); $this->assertEquals(1, $projects['body']['total']); @@ -7325,7 +7346,7 @@ class ProjectsConsoleClientTest extends Scope ], $this->getHeaders()), [ 'queries' => [ Query::contains('labels', ['vip', 'imagine'])->toString(), - ], + ] ]); $this->assertEquals(200, $projects['headers']['status-code']); $this->assertEquals(2, $projects['body']['total']); @@ -7333,21 +7354,21 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals($projectId2, $projects['body']['projects'][1]['$id']); // Cleanup - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(204, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId2, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId2, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); $this->assertEquals(204, $response['headers']['status-code']); - $response = $this->client->call(Client::METHOD_DELETE, '/teams/'.$teamId, array_merge([ + $response = $this->client->call(Client::METHOD_DELETE, '/teams/' . $teamId, array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], ], $this->getHeaders())); @@ -7356,7 +7377,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('ciIgnore')] - public function test_project_specific_permissions_for_list_projects(): void + public function testProjectSpecificPermissionsForListProjects(): void { $teamId = ID::unique(); $projectIdA = $this->setupProject([ @@ -7368,23 +7389,23 @@ class ProjectsConsoleClientTest extends Scope 'name' => 'Project Test B', ], $teamId, false); - $testUserEmail = 'test-'.ID::unique().'@localhost.test'; + $testUserEmail = 'test-' . ID::unique() . '@localhost.test'; $testUserName = 'Test User'; - ['membershipId' => $testUserMembershipId] = $this->setupUserMembership([ + [ 'membershipId' => $testUserMembershipId ] = $this->setupUserMembership([ 'teamId' => $teamId, 'email' => $testUserEmail, 'name' => $testUserName, - 'roles' => ['owner'], + 'roles' => ["owner"], ]); $testCases = [ [ - 'roles' => ['owner'], + 'roles' => ["owner"], 'successProjectIds' => [$projectIdA, $projectIdB], ], [ - 'roles' => ['developer'], + 'roles' => ["developer"], 'successProjectIds' => [$projectIdA, $projectIdB], ], [ @@ -7404,9 +7425,9 @@ class ProjectsConsoleClientTest extends Scope 'successProjectIds' => [$projectIdB], ], [ - 'roles' => ['developer', "project-$projectIdA-owner"], + 'roles' => ["developer", "project-$projectIdA-owner"], 'successProjectIds' => [$projectIdA, $projectIdB], - ], + ] ]; // Setup session @@ -7418,7 +7439,7 @@ class ProjectsConsoleClientTest extends Scope 'email' => $testUserEmail, 'password' => 'password', ]); - $token = $session['cookies']['a_session_'.$this->getProject()['$id']]; + $token = $session['cookies']['a_session_' . $this->getProject()['$id']]; foreach ($testCases as $testCase) { $this->updateMembershipRole($teamId, $testUserMembershipId, $testCase['roles']); @@ -7428,7 +7449,7 @@ class ProjectsConsoleClientTest extends Scope 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$token, + 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $token, ]); $this->assertEquals(200, $response['headers']['status-code']); @@ -7443,7 +7464,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('ciIgnore')] - public function test_project_specific_permissions_for_update_project(): void + public function testProjectSpecificPermissionsForUpdateProject(): void { $teamId = ID::unique(); $projectIdA = $this->setupProject([ @@ -7455,24 +7476,24 @@ class ProjectsConsoleClientTest extends Scope 'name' => 'Project Test B', ], $teamId, false); - $testUserEmail = 'test-'.ID::unique().'@localhost.test'; + $testUserEmail = 'test-' . ID::unique() . '@localhost.test'; $testUserName = 'Test User'; - ['membershipId' => $testUserMembershipId] = $this->setupUserMembership([ + [ 'membershipId' => $testUserMembershipId ] = $this->setupUserMembership([ 'teamId' => $teamId, 'email' => $testUserEmail, 'name' => $testUserName, - 'roles' => ['owner'], + 'roles' => ["owner"], ]); $testCases = [ [ - 'roles' => ['owner'], + 'roles' => ["owner"], 'successProjectIds' => [$projectIdA, $projectIdB], 'failureProjectIds' => [], ], [ - 'roles' => ['developer'], + 'roles' => ["developer"], 'successProjectIds' => [$projectIdA, $projectIdB], 'failureProjectIds' => [], ], @@ -7497,10 +7518,10 @@ class ProjectsConsoleClientTest extends Scope 'failureProjectIds' => [$projectIdA], ], [ - 'roles' => ['developer', "project-$projectIdA-owner"], + 'roles' => ["developer", "project-$projectIdA-owner"], 'successProjectIds' => [$projectIdA, $projectIdB], 'failureProjectIds' => [], - ], + ] ]; // Setup session @@ -7512,20 +7533,20 @@ class ProjectsConsoleClientTest extends Scope 'email' => $testUserEmail, 'password' => 'password', ]); - $token = $session['cookies']['a_session_'.$this->getProject()['$id']]; + $token = $session['cookies']['a_session_' . $this->getProject()['$id']]; foreach ($testCases as $testCase) { $this->updateMembershipRole($teamId, $testUserMembershipId, $testCase['roles']); foreach ($testCase['successProjectIds'] as $projectId) { - $newProjectName = 'Updated Project Name '.ID::unique(); + $newProjectName = 'Updated Project Name ' . ID::unique(); // Success: User should be able to update the project they have access to. - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId, [ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId, [ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$token, + 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $token, ], [ 'name' => $newProjectName, ]); @@ -7535,14 +7556,14 @@ class ProjectsConsoleClientTest extends Scope } foreach ($testCase['failureProjectIds'] as $projectId) { - $newProjectName = 'Updated Project Name '.ID::unique(); + $newProjectName = 'Updated Project Name ' . ID::unique(); // Failure: User should not be able to update the project they do not have access to. - $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$projectId, [ + $response = $this->client->call(Client::METHOD_PATCH, '/projects/' . $projectId, [ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-response-format' => '1.9.4', - 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$token, + 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $token, ], [ 'name' => $newProjectName, ]); @@ -7552,7 +7573,7 @@ class ProjectsConsoleClientTest extends Scope } #[Group('ciIgnore')] - public function test_project_specific_permissions_for_delete_project(): void + public function testProjectSpecificPermissionsForDeleteProject(): void { $teamId = ID::unique(); $projectIdA = $this->setupProject([ @@ -7576,24 +7597,24 @@ class ProjectsConsoleClientTest extends Scope 'name' => 'Project Test E', ], $teamId, false); - $testUserEmail = 'test-'.ID::unique().'@localhost.test'; + $testUserEmail = 'test-' . ID::unique() . '@localhost.test'; $testUserName = 'Test User'; - ['membershipId' => $testUserMembershipId] = $this->setupUserMembership([ + [ 'membershipId' => $testUserMembershipId ] = $this->setupUserMembership([ 'teamId' => $teamId, 'email' => $testUserEmail, 'name' => $testUserName, - 'roles' => ['owner'], + 'roles' => ["owner"], ]); $testCases = [ [ - 'roles' => ['owner'], + 'roles' => ["owner"], 'successProjectIds' => [$projectIdA], 'failureProjectIds' => [], ], [ - 'roles' => ['developer'], + 'roles' => ["developer"], 'successProjectIds' => [$projectIdB, $projectIdC], 'failureProjectIds' => [], ], @@ -7618,29 +7639,29 @@ class ProjectsConsoleClientTest extends Scope 'email' => $testUserEmail, 'password' => 'password', ]); - $token = $session['cookies']['a_session_'.$this->getProject()['$id']]; + $token = $session['cookies']['a_session_' . $this->getProject()['$id']]; foreach ($testCases as $testCase) { $this->updateMembershipRole($teamId, $testUserMembershipId, $testCase['roles']); foreach ($testCase['successProjectIds'] as $projectId) { // Success: User should be able to delete the project they have access to. - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId, [ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, [ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$token, + 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $token, ]); $this->assertEquals(204, $response['headers']['status-code']); } foreach ($testCase['failureProjectIds'] as $projectId) { // Failure: User should not be able to delete the project they do not have access to. - $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$projectId, [ + $response = $this->client->call(Client::METHOD_DELETE, '/projects/' . $projectId, [ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], - 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$token, + 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $token, ]); $this->assertTrue($response['headers']['status-code'] === 401 || $response['headers']['status-code'] === 404); } @@ -7651,7 +7672,7 @@ class ProjectsConsoleClientTest extends Scope * Test project specific permissions for project resources, in this case 'function variables'. */ #[Group('ciIgnore')] - public function test_project_specific_permissions_for_project_resources(): void + public function testProjectSpecificPermissionsForProjectResources(): void { $teamId = ID::unique(); $projectIdA = $this->setupProject([ @@ -7663,24 +7684,24 @@ class ProjectsConsoleClientTest extends Scope 'name' => 'Project Test B', ], $teamId, false); - $testUserEmail = 'test-'.ID::unique().'@localhost.test'; + $testUserEmail = 'test-' . ID::unique() . '@localhost.test'; $testUserName = 'Test User'; - ['membershipId' => $testUserMembershipId] = $this->setupUserMembership([ + [ 'membershipId' => $testUserMembershipId ] = $this->setupUserMembership([ 'teamId' => $teamId, 'email' => $testUserEmail, 'name' => $testUserName, - 'roles' => ['owner'], + 'roles' => ["owner"], ]); $testCases = [ [ - 'roles' => ['owner'], + 'roles' => ["owner"], 'successProjectIds' => [$projectIdA, $projectIdB], 'failureProjectIds' => [], ], [ - 'roles' => ['developer'], + 'roles' => ["developer"], 'successProjectIds' => [$projectIdA, $projectIdB], 'failureProjectIds' => [], ], @@ -7705,10 +7726,10 @@ class ProjectsConsoleClientTest extends Scope 'failureProjectIds' => [$projectIdA], ], [ - 'roles' => ['developer', "project-$projectIdA-owner"], + 'roles' => ["developer", "project-$projectIdA-owner"], 'successProjectIds' => [$projectIdA, $projectIdB], 'failureProjectIds' => [], - ], + ] ]; // Setup session @@ -7720,7 +7741,7 @@ class ProjectsConsoleClientTest extends Scope 'email' => $testUserEmail, 'password' => 'password', ]); - $token = $session['cookies']['a_session_'.$this->getProject()['$id']]; + $token = $session['cookies']['a_session_' . $this->getProject()['$id']]; // Setup functions $functionId = ID::unique(); @@ -7732,37 +7753,37 @@ class ProjectsConsoleClientTest extends Scope foreach ($testCase['successProjectIds'] as $projectId) { $variableId = ID::unique(); - $response = $this->client->call(Client::METHOD_POST, '/functions/'.$functionId.'/variables', [ + $response = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/variables', [ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'x-appwrite-mode' => 'admin', - 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$token, + 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $token, ], [ 'variableId' => $variableId, - 'key' => 'APP_TEST_'.$variableId, + 'key' => 'APP_TEST_' . $variableId, 'value' => 'TESTINGVALUE', - 'secret' => false, + 'secret' => false ]); $this->assertEquals(201, $response['headers']['status-code']); - $this->assertEquals('APP_TEST_'.$variableId, $response['body']['key']); + $this->assertEquals('APP_TEST_' . $variableId, $response['body']['key']); $this->assertEquals('TESTINGVALUE', $response['body']['value']); } foreach ($testCase['failureProjectIds'] as $projectId) { $variableId = ID::unique(); - $response = $this->client->call(Client::METHOD_POST, '/functions/'.$functionId.'/variables', [ + $response = $this->client->call(Client::METHOD_POST, '/functions/' . $functionId . '/variables', [ 'origin' => 'http://localhost', 'content-type' => 'application/json', 'x-appwrite-project' => $projectId, 'x-appwrite-mode' => 'admin', - 'cookie' => 'a_session_'.$this->getProject()['$id'].'='.$token, + 'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $token, ], [ 'variableId' => $variableId, - 'key' => 'APP_TEST_'.$variableId, + 'key' => 'APP_TEST_' . $variableId, 'value' => 'TESTINGVALUE', - 'secret' => false, + 'secret' => false ]); $this->assertTrue($response['headers']['status-code'] === 401 || $response['headers']['status-code'] === 404); @@ -7770,7 +7791,7 @@ class ProjectsConsoleClientTest extends Scope } } - public function test_password_recovery_url_params(): void + public function testPasswordRecoveryUrlParams(): void { // With search params $url = 'http://localhost/auth/signin?id=abcd1234&tenant=efgh5678&domain=example.com&referred=0'; @@ -7800,9 +7821,9 @@ class ProjectsConsoleClientTest extends Scope $this->assertStringContainsString($url, $email['html'] ?? ''); }); - $this->assertEquals('Password Reset for '.$this->getProject()['name'], $lastEmail['subject']); + $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); - $expectedUrl = $url.'&userId='.$userId.'&secret='; + $expectedUrl = $url . "&userId=" . $userId . "&secret="; $this->assertStringContainsString($expectedUrl, $lastEmail['html']); @@ -7832,9 +7853,9 @@ class ProjectsConsoleClientTest extends Scope $this->assertStringContainsString($url, $email['html'] ?? ''); }); - $this->assertEquals('Password Reset for '.$this->getProject()['name'], $lastEmail['subject']); + $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); - $expectedUrl = $url.'&userId='.$userId.'&secret='; + $expectedUrl = $url . "&userId=" . $userId . "&secret="; $this->assertStringContainsString($expectedUrl, $lastEmail['html']); @@ -7861,12 +7882,12 @@ 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, $email['html'] ?? ''); }); - $this->assertEquals('Password Reset for '.$this->getProject()['name'], $lastEmail['subject']); + $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); - $expectedUrl = $url.'?userId='.$userId.'&secret='; + $expectedUrl = $url . "?userId=" . $userId . "&secret="; $this->assertStringContainsString($expectedUrl, $lastEmail['html']); @@ -7893,12 +7914,12 @@ 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, $email['html'] ?? ''); }); - $this->assertEquals('Password Reset for '.$this->getProject()['name'], $lastEmail['subject']); + $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); - $expectedUrl = $url.'?userId='.$userId.'&secret='; + $expectedUrl = $url . "?userId=" . $userId . "&secret="; $this->assertStringContainsString($expectedUrl, $lastEmail['html']); @@ -7928,7 +7949,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertStringContainsString('INJECTED', $email['html'] ?? ''); }); - $this->assertEquals('Password Reset for '.$this->getProject()['name'], $lastEmail['subject']); + $this->assertEquals('Password Reset for ' . $this->getProject()['name'], $lastEmail['subject']); $this->assertStringContainsString('INJECTED', $lastEmail['html']); $this->assertStringContainsString('

', $lastEmail['html']); @@ -7936,7 +7957,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertStringContainsString('">', $lastEmail['html']); $this->assertStringContainsString('', $lastEmail['html']); - $expectedUrl = $url.'?userId='.$userId.'&secret='; + $expectedUrl = $url . "?userId=" . $userId . "&secret="; $this->assertStringContainsString($expectedUrl, $lastEmail['html']); }