From b7fe52ad54fe55d14442ff57e67c1f4bb1045a44 Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 15 Oct 2020 00:11:12 +0300 Subject: [PATCH 1/2] Updated tests --- tests/e2e/Client.php | 2 +- tests/e2e/Services/Account/AccountBase.php | 68 ++++++------ .../e2e/Services/Functions/FunctionsBase.php | 2 +- .../Functions/FunctionsCustomServerTest.php | 6 +- .../Projects/ProjectsConsoleClientTest.php | 102 +++++++++--------- tests/e2e/Services/Teams/TeamsBase.php | 2 +- tests/e2e/Services/Teams/TeamsBaseClient.php | 18 ++-- tests/e2e/Services/Teams/TeamsBaseServer.php | 6 +- 8 files changed, 103 insertions(+), 103 deletions(-) diff --git a/tests/e2e/Client.php b/tests/e2e/Client.php index 5a84716b52..e9a47c7350 100644 --- a/tests/e2e/Client.php +++ b/tests/e2e/Client.php @@ -211,7 +211,7 @@ class Client } $responseBody = curl_exec($ch); - $responseType = (isset($responseHeaders['content-type'])) ? $responseHeaders['content-type'] : ''; + $responseType = $responseHeaders['content-type'] ?? ''; $responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); switch (substr($responseType, 0, strpos($responseType, ';'))) { diff --git a/tests/e2e/Services/Account/AccountBase.php b/tests/e2e/Services/Account/AccountBase.php index 4e95148a65..d070ed3e7f 100644 --- a/tests/e2e/Services/Account/AccountBase.php +++ b/tests/e2e/Services/Account/AccountBase.php @@ -65,8 +65,8 @@ trait AccountBase public function testCreateAccountSession($data):array { sleep(10); - $email = (isset($data['email'])) ? $data['email'] : ''; - $password = (isset($data['password'])) ? $data['password'] : ''; + $email = $data['email'] ?? ''; + $password = $data['password'] ?? ''; /** * Test for SUCCESS @@ -132,9 +132,9 @@ trait AccountBase */ public function testGetAccount($data):array { - $email = (isset($data['email'])) ? $data['email'] : ''; - $name = (isset($data['name'])) ? $data['name'] : ''; - $session = (isset($data['session'])) ? $data['session'] : ''; + $email = $data['email'] ?? ''; + $name = $data['name'] ?? ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -183,7 +183,7 @@ trait AccountBase */ public function testGetAccountPrefs($data):array { - $session = (isset($data['session'])) ? $data['session'] : ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -219,8 +219,8 @@ trait AccountBase */ public function testGetAccountSessions($data):array { - $session = (isset($data['session'])) ? $data['session'] : ''; - $sessionId = (isset($data['sessionId'])) ? $data['sessionId'] : ''; + $session = $data['session'] ?? ''; + $sessionId = $data['sessionId'] ?? ''; /** * Test for SUCCESS @@ -281,7 +281,7 @@ trait AccountBase public function testGetAccountLogs($data):array { sleep(10); - $session = (isset($data['session'])) ? $data['session'] : ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -369,8 +369,8 @@ trait AccountBase */ public function testUpdateAccountName($data):array { - $email = (isset($data['email'])) ? $data['email'] : ''; - $session = (isset($data['session'])) ? $data['session'] : ''; + $email = $data['email'] ?? ''; + $session = $data['session'] ?? ''; $newName = 'New Name'; /** @@ -436,9 +436,9 @@ trait AccountBase */ public function testUpdateAccountPassword($data):array { - $email = (isset($data['email'])) ? $data['email'] : ''; - $password = (isset($data['password'])) ? $data['password'] : ''; - $session = (isset($data['session'])) ? $data['session'] : ''; + $email = $data['email'] ?? ''; + $password = $data['password'] ?? ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -505,7 +505,7 @@ trait AccountBase public function testUpdateAccountEmail($data):array { $newEmail = uniqid().'new@localhost.test'; - $session = (isset($data['session'])) ? $data['session'] : ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -561,7 +561,7 @@ trait AccountBase public function testUpdateAccountPrefs($data):array { $newEmail = uniqid().'new@localhost.test'; - $session = (isset($data['session'])) ? $data['session'] : ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -638,9 +638,9 @@ trait AccountBase */ public function testCreateAccountVerification($data):array { - $email = (isset($data['email'])) ? $data['email'] : ''; - $name = (isset($data['name'])) ? $data['name'] : ''; - $session = (isset($data['session'])) ? $data['session'] : ''; + $email = $data['email'] ?? ''; + $name = $data['name'] ?? ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -703,9 +703,9 @@ trait AccountBase */ public function testUpdateAccountVerification($data):array { - $id = (isset($data['id'])) ? $data['id'] : ''; - $session = (isset($data['session'])) ? $data['session'] : ''; - $verification = (isset($data['verification'])) ? $data['verification'] : ''; + $id = $data['id'] ?? ''; + $session = $data['session'] ?? ''; + $verification = $data['verification'] ?? ''; /** * Test for SUCCESS @@ -757,9 +757,9 @@ trait AccountBase */ public function testDeleteAccountSession($data):array { - $email = (isset($data['email'])) ? $data['email'] : ''; - $password = (isset($data['password'])) ? $data['password'] : ''; - $session = (isset($data['session'])) ? $data['session'] : ''; + $email = $data['email'] ?? ''; + $password = $data['password'] ?? ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -825,8 +825,8 @@ trait AccountBase */ public function testDeleteAccountSessionCurrent($data):array { - $email = (isset($data['email'])) ? $data['email'] : ''; - $password = (isset($data['password'])) ? $data['password'] : ''; + $email = $data['email'] ?? ''; + $password = $data['password'] ?? ''; /** * Test for SUCCESS @@ -882,7 +882,7 @@ trait AccountBase */ public function testDeleteAccountSessions($data):array { - $session = (isset($data['session'])) ? $data['session'] : ''; + $session = $data['session'] ?? ''; /** * Test for SUCCESS @@ -910,8 +910,8 @@ trait AccountBase /** * Create new fallback session */ - $email = (isset($data['email'])) ? $data['email'] : ''; - $password = (isset($data['password'])) ? $data['password'] : ''; + $email = $data['email'] ?? ''; + $password = $data['password'] ?? ''; $response = $this->client->call(Client::METHOD_POST, '/account/sessions', array_merge([ 'origin' => 'http://localhost', @@ -932,8 +932,8 @@ trait AccountBase */ public function testCreateAccountRecovery($data):array { - $email = (isset($data['email'])) ? $data['email'] : ''; - $name = (isset($data['name'])) ? $data['name'] : ''; + $email = $data['email'] ?? ''; + $name = $data['name'] ?? ''; /** * Test for SUCCESS @@ -1006,8 +1006,8 @@ trait AccountBase */ public function testUpdateAccountRecovery($data):array { - $id = (isset($data['id'])) ? $data['id'] : ''; - $recovery = (isset($data['recovery'])) ? $data['recovery'] : ''; + $id = $data['id'] ?? ''; + $recovery = $data['recovery'] ?? ''; $newPassowrd = 'test-recovery'; /** diff --git a/tests/e2e/Services/Functions/FunctionsBase.php b/tests/e2e/Services/Functions/FunctionsBase.php index 80ee47c72a..a167b3763a 100644 --- a/tests/e2e/Services/Functions/FunctionsBase.php +++ b/tests/e2e/Services/Functions/FunctionsBase.php @@ -13,7 +13,7 @@ trait FunctionsBase // */ // public function testGetTeam($data):array // { - // $id = (isset($data['teamUid'])) ? $data['teamUid'] : ''; + // $id = $data['teamUid'] ?? ''; // /** // * Test for SUCCESS diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 7f0441a88d..9aac863039 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -38,7 +38,7 @@ class FunctionsConsoleServerTest extends Scope 'timeout' => 10, ]); - $functionId = (isset($response1['body']['$id'])) ? $response1['body']['$id'] : ''; + $functionId = $response1['body']['$id'] ?? ''; $this->assertEquals(201, $response1['headers']['status-code']); $this->assertNotEmpty($response1['body']['$id']); @@ -186,7 +186,7 @@ class FunctionsConsoleServerTest extends Scope 'code' => new CURLFile(realpath(__DIR__ . '/../../../resources/functions/php-fx.tar.gz'), 'application/x-gzip', 'php-fx.tar.gz'), ]); - $tagId = (isset($tag['body']['$id'])) ? $tag['body']['$id'] : ''; + $tagId = $tag['body']['$id'] ?? ''; $this->assertEquals(201, $tag['headers']['status-code']); $this->assertNotEmpty($tag['body']['$id']); @@ -296,7 +296,7 @@ class FunctionsConsoleServerTest extends Scope 'async' => 1, ]); - $executionId = (isset($execution['body']['$id'])) ? $execution['body']['$id'] : ''; + $executionId = $execution['body']['$id'] ?? ''; $this->assertEquals(201, $execution['headers']['status-code']); $this->assertNotEmpty($execution['body']['$id']); diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 7e4e6c1e41..ac3ff87240 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -79,7 +79,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testListProject($data):array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; /** * Test for SUCCESS @@ -106,7 +106,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testGetProject($data):array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; /** * Test for SUCCESS @@ -147,7 +147,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testGetProjectUsage($data):array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; /** * Test for SUCCESS @@ -206,7 +206,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testUpdateProject($data):array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; /** * Test for SUCCESS @@ -249,7 +249,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testUpdateProjectOAuth($data):array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $providers = require('app/config/providers.php'); /** @@ -307,7 +307,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testCreateProjectWebhook($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/webhooks', array_merge([ 'content-type' => 'application/json', @@ -358,7 +358,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testListProjectWebhook($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/webhooks', array_merge([ 'content-type' => 'application/json', @@ -380,8 +380,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testGetProjectWebhook($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $webhookId = (isset($data['webhookId'])) ? $data['webhookId'] : ''; + $id = $data['projectId'] ?? ''; + $webhookId = $data['webhookId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/webhooks/'.$webhookId, array_merge([ 'content-type' => 'application/json', @@ -416,8 +416,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testUpdateProjectWebhook($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $webhookId = (isset($data['webhookId'])) ? $data['webhookId'] : ''; + $id = $data['projectId'] ?? ''; + $webhookId = $data['webhookId'] ?? ''; $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/webhooks/'.$webhookId, array_merge([ 'content-type' => 'application/json', @@ -503,8 +503,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testDeleteProjectWebhook($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $webhookId = (isset($data['webhookId'])) ? $data['webhookId'] : ''; + $id = $data['projectId'] ?? ''; + $webhookId = $data['webhookId'] ?? ''; $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/webhooks/'.$webhookId, array_merge([ 'content-type' => 'application/json', @@ -541,7 +541,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testCreateProjectKey($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/keys', array_merge([ 'content-type' => 'application/json', @@ -581,7 +581,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testListProjectKey($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys', array_merge([ 'content-type' => 'application/json', @@ -603,8 +603,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testGetProjectKey($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $keyId = (isset($data['keyId'])) ? $data['keyId'] : ''; + $id = $data['projectId'] ?? ''; + $keyId = $data['keyId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/keys/'.$keyId, array_merge([ 'content-type' => 'application/json', @@ -638,8 +638,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testUpdateProjectKey($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $keyId = (isset($data['keyId'])) ? $data['keyId'] : ''; + $id = $data['projectId'] ?? ''; + $keyId = $data['keyId'] ?? ''; $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/keys/'.$keyId, array_merge([ 'content-type' => 'application/json', @@ -693,8 +693,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testDeleteProjectKey($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $keyId = (isset($data['keyId'])) ? $data['keyId'] : ''; + $id = $data['projectId'] ?? ''; + $keyId = $data['keyId'] ?? ''; $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/keys/'.$keyId, array_merge([ 'content-type' => 'application/json', @@ -731,7 +731,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testCreateProjectTask($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/tasks', array_merge([ 'content-type' => 'application/json', @@ -859,7 +859,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testListProjectTask($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/tasks', array_merge([ 'content-type' => 'application/json', @@ -881,8 +881,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testGetProjectTask($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $taskId = (isset($data['taskId'])) ? $data['taskId'] : ''; + $id = $data['projectId'] ?? ''; + $taskId = $data['taskId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/tasks/'.$taskId, array_merge([ 'content-type' => 'application/json', @@ -921,8 +921,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testUpdateProjectTask($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $taskId = (isset($data['taskId'])) ? $data['taskId'] : ''; + $id = $data['projectId'] ?? ''; + $taskId = $data['taskId'] ?? ''; $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/tasks/'.$taskId, array_merge([ 'content-type' => 'application/json', @@ -1087,8 +1087,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testDeleteProjectTask($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $taskId = (isset($data['taskId'])) ? $data['taskId'] : ''; + $id = $data['projectId'] ?? ''; + $taskId = $data['taskId'] ?? ''; $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/tasks/'.$taskId, array_merge([ 'content-type' => 'application/json', @@ -1125,7 +1125,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testCreateProjectPlatform($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/platforms', array_merge([ 'content-type' => 'application/json', @@ -1227,7 +1227,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testListProjectPlatform($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms', array_merge([ 'content-type' => 'application/json', @@ -1249,9 +1249,9 @@ class ProjectsConsoleClientTest extends Scope */ public function testGetProjectPlatform($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; - $platformWebId = (isset($data['platformWebId'])) ? $data['platformWebId'] : ''; + $platformWebId = $data['platformWebId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([ 'content-type' => 'application/json', @@ -1267,7 +1267,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('', $response['body']['store']); $this->assertEquals('localhost', $response['body']['hostname']); - $platformFultteriOSId = (isset($data['platformFultteriOSId'])) ? $data['platformFultteriOSId'] : ''; + $platformFultteriOSId = $data['platformFultteriOSId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformFultteriOSId, array_merge([ 'content-type' => 'application/json', @@ -1283,7 +1283,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('', $response['body']['store']); $this->assertEquals('', $response['body']['hostname']); - $platformFultterAndroidId = (isset($data['platformFultterAndroidId'])) ? $data['platformFultterAndroidId'] : ''; + $platformFultterAndroidId = $data['platformFultterAndroidId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/platforms/'.$platformFultterAndroidId, array_merge([ 'content-type' => 'application/json', @@ -1317,9 +1317,9 @@ class ProjectsConsoleClientTest extends Scope */ public function testUpdateProjectPlatform($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; - $platformWebId = (isset($data['platformWebId'])) ? $data['platformWebId'] : ''; + $platformWebId = $data['platformWebId'] ?? ''; $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([ 'content-type' => 'application/json', @@ -1340,7 +1340,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('', $response['body']['store']); $this->assertEquals('localhost-new', $response['body']['hostname']); - $platformFultteriOSId = (isset($data['platformFultteriOSId'])) ? $data['platformFultteriOSId'] : ''; + $platformFultteriOSId = $data['platformFultteriOSId'] ?? ''; $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformFultteriOSId, array_merge([ 'content-type' => 'application/json', @@ -1361,7 +1361,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals('', $response['body']['store']); $this->assertEquals('', $response['body']['hostname']); - $platformFultterAndroidId = (isset($data['platformFultterAndroidId'])) ? $data['platformFultterAndroidId'] : ''; + $platformFultterAndroidId = $data['platformFultterAndroidId'] ?? ''; $response = $this->client->call(Client::METHOD_PUT, '/projects/'.$id.'/platforms/'.$platformFultterAndroidId, array_merge([ 'content-type' => 'application/json', @@ -1394,9 +1394,9 @@ class ProjectsConsoleClientTest extends Scope */ public function testDeleteProjectPlatform($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; - $platformWebId = (isset($data['platformWebId'])) ? $data['platformWebId'] : ''; + $platformWebId = $data['platformWebId'] ?? ''; $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformWebId, array_merge([ 'content-type' => 'application/json', @@ -1413,7 +1413,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $platformFultteriOSId = (isset($data['platformFultteriOSId'])) ? $data['platformFultteriOSId'] : ''; + $platformFultteriOSId = $data['platformFultteriOSId'] ?? ''; $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformFultteriOSId, array_merge([ 'content-type' => 'application/json', @@ -1430,7 +1430,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(404, $response['headers']['status-code']); - $platformFultterAndroidId = (isset($data['platformFultterAndroidId'])) ? $data['platformFultterAndroidId'] : ''; + $platformFultterAndroidId = $data['platformFultterAndroidId'] ?? ''; $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/platforms/'.$platformFultterAndroidId, array_merge([ 'content-type' => 'application/json', @@ -1467,7 +1467,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testCreateProjectDomain($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_POST, '/projects/'.$id.'/domains', array_merge([ 'content-type' => 'application/json', @@ -1506,7 +1506,7 @@ class ProjectsConsoleClientTest extends Scope */ public function testListProjectDomain($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; + $id = $data['projectId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/domains', array_merge([ 'content-type' => 'application/json', @@ -1528,8 +1528,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testGetProjectDomain($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $domainId = (isset($data['domainId'])) ? $data['domainId'] : ''; + $id = $data['projectId'] ?? ''; + $domainId = $data['domainId'] ?? ''; $response = $this->client->call(Client::METHOD_GET, '/projects/'.$id.'/domains/'.$domainId, array_merge([ 'content-type' => 'application/json', @@ -1563,8 +1563,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testUpdateProjectDomain($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $domainId = (isset($data['domainId'])) ? $data['domainId'] : ''; + $id = $data['projectId'] ?? ''; + $domainId = $data['domainId'] ?? ''; $response = $this->client->call(Client::METHOD_PATCH, '/projects/'.$id.'/domains/'.$domainId.'/verification', array_merge([ 'content-type' => 'application/json', @@ -1585,8 +1585,8 @@ class ProjectsConsoleClientTest extends Scope */ public function testDeleteProjectDomain($data): array { - $id = (isset($data['projectId'])) ? $data['projectId'] : ''; - $domainId = (isset($data['domainId'])) ? $data['domainId'] : ''; + $id = $data['projectId'] ?? ''; + $domainId = $data['domainId'] ?? ''; $response = $this->client->call(Client::METHOD_DELETE, '/projects/'.$id.'/domains/'.$domainId, array_merge([ 'content-type' => 'application/json', diff --git a/tests/e2e/Services/Teams/TeamsBase.php b/tests/e2e/Services/Teams/TeamsBase.php index 73bdfe7199..a8ac2ac433 100644 --- a/tests/e2e/Services/Teams/TeamsBase.php +++ b/tests/e2e/Services/Teams/TeamsBase.php @@ -75,7 +75,7 @@ trait TeamsBase */ public function testGetTeam($data):array { - $id = (isset($data['teamUid'])) ? $data['teamUid'] : ''; + $id = $data['teamUid'] ?? ''; /** * Test for SUCCESS diff --git a/tests/e2e/Services/Teams/TeamsBaseClient.php b/tests/e2e/Services/Teams/TeamsBaseClient.php index ceb0d86e5c..25bbcbdd58 100644 --- a/tests/e2e/Services/Teams/TeamsBaseClient.php +++ b/tests/e2e/Services/Teams/TeamsBaseClient.php @@ -11,7 +11,7 @@ trait TeamsBaseClient */ public function testGetTeamMemberships($data):array { - $teamUid = (isset($data['teamUid'])) ? $data['teamUid'] : ''; + $teamUid = $data['teamUid'] ?? ''; /** * Test for SUCCESS @@ -40,8 +40,8 @@ trait TeamsBaseClient */ public function testCreateTeamMembership($data):array { - $teamUid = (isset($data['teamUid'])) ? $data['teamUid'] : ''; - $teamName = (isset($data['teamName'])) ? $data['teamName'] : ''; + $teamUid = $data['teamUid'] ?? ''; + $teamName = $data['teamName'] ?? ''; $email = uniqid().'friend@localhost.test'; /** @@ -127,10 +127,10 @@ trait TeamsBaseClient */ public function testUpdateTeamMembership($data):array { - $teamUid = (isset($data['teamUid'])) ? $data['teamUid'] : ''; - $secret = (isset($data['secret'])) ? $data['secret'] : ''; - $inviteUid = (isset($data['inviteUid'])) ? $data['inviteUid'] : ''; - $userUid = (isset($data['userUid'])) ? $data['userUid'] : ''; + $teamUid = $data['teamUid'] ?? ''; + $secret = $data['secret'] ?? ''; + $inviteUid = $data['inviteUid'] ?? ''; + $userUid = $data['userUid'] ?? ''; /** * Test for SUCCESS @@ -207,8 +207,8 @@ trait TeamsBaseClient */ public function testDeleteTeamMembership($data):array { - $teamUid = (isset($data['teamUid'])) ? $data['teamUid'] : ''; - $inviteUid = (isset($data['inviteUid'])) ? $data['inviteUid'] : ''; + $teamUid = $data['teamUid'] ?? ''; + $inviteUid = $data['inviteUid'] ?? ''; /** * Test for SUCCESS diff --git a/tests/e2e/Services/Teams/TeamsBaseServer.php b/tests/e2e/Services/Teams/TeamsBaseServer.php index 1547a4e289..9869ce5906 100644 --- a/tests/e2e/Services/Teams/TeamsBaseServer.php +++ b/tests/e2e/Services/Teams/TeamsBaseServer.php @@ -11,7 +11,7 @@ trait TeamsBaseServer */ public function testGetTeamMemberships($data):array { - $id = (isset($data['teamUid'])) ? $data['teamUid'] : ''; + $id = $data['teamUid'] ?? ''; /** * Test for SUCCESS @@ -37,8 +37,8 @@ trait TeamsBaseServer */ public function testCreateTeamMembership($data):array { - $teamUid = (isset($data['teamUid'])) ? $data['teamUid'] : ''; - $teamName = (isset($data['teamName'])) ? $data['teamName'] : ''; + $teamUid = $data['teamUid'] ?? ''; + $teamName = $data['teamName'] ?? ''; $email = uniqid().'friend@localhost.test'; /** From 95cafb9f1b2791a9ebe5f72160a172f69eb247be Mon Sep 17 00:00:00 2001 From: Eldad Fux Date: Thu, 15 Oct 2020 00:34:57 +0300 Subject: [PATCH 2/2] Updated controllers and workers --- app/controllers/api/avatars.php | 6 +- app/controllers/api/database.php | 4 +- app/controllers/api/health.php | 16 +- app/tasks/migrate.php | 2 +- app/views/console/database/collection.phtml | 8 +- app/views/console/database/document.phtml | 36 ++-- app/views/console/database/form.phtml | 12 +- .../console/database/rules/documentId.phtml | 6 +- .../console/database/search/documents.phtml | 10 +- app/views/console/users/index.phtml | 6 +- app/workers/certificates.php | 4 +- app/workers/tasks.php | 6 +- app/workers/webhooks.php | 12 +- composer.lock | 162 +++++++++--------- 14 files changed, 145 insertions(+), 145 deletions(-) diff --git a/app/controllers/api/avatars.php b/app/controllers/api/avatars.php index 0930806983..8349cce246 100644 --- a/app/controllers/api/avatars.php +++ b/app/controllers/api/avatars.php @@ -283,8 +283,8 @@ App::get('/v1/avatars/favicon') case 'jpeg': $size = \explode('x', \strtolower($sizes)); - $sizeWidth = (isset($size[0])) ? (int) $size[0] : 0; - $sizeHeight = (isset($size[1])) ? (int) $size[1] : 0; + $sizeWidth = (int) $size[0] ?? 0; + $sizeHeight = (int) $size[1] ?? 0; if (($sizeWidth * $sizeHeight) >= $space) { $space = $sizeWidth * $sizeHeight; @@ -423,7 +423,7 @@ App::get('/v1/avatars/initials') $code = 0; foreach ($words as $key => $w) { - $initials .= (isset($w[0])) ? $w[0] : ''; + $initials .= $w[0] ?? ''; $code += (isset($w[0])) ? \ord($w[0]) : 0; if ($key == 1) { diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 70fdfac4f8..bd19935754 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -418,8 +418,8 @@ App::post('/v1/database/collections/:collectionId/documents') * Set default collection values */ foreach ($collection->getAttribute('rules') as $key => $rule) { - $key = (isset($rule['key'])) ? $rule['key'] : ''; - $default = (isset($rule['default'])) ? $rule['default'] : null; + $key = $rule['key'] ?? ''; + $default = $rule['default'] ?? null; if (!isset($data[$key])) { $data[$key] = $default; diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index b8955a1989..5ef4f2b9c8 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -278,14 +278,14 @@ App::get('/v1/health/stats') // Currently only used internally 'partitionFree' => Storage::human($device->getPartitionFreeSpace()), ], 'cache' => [ - 'uptime' => (isset($cacheStats['uptime_in_seconds'])) ? $cacheStats['uptime_in_seconds'] : 0, - 'clients' => (isset($cacheStats['connected_clients'])) ? $cacheStats['connected_clients'] : 0, - 'hits' => (isset($cacheStats['keyspace_hits'])) ? $cacheStats['keyspace_hits'] : 0, - 'misses' => (isset($cacheStats['keyspace_misses'])) ? $cacheStats['keyspace_misses'] : 0, - 'memory_used' => (isset($cacheStats['used_memory'])) ? $cacheStats['used_memory'] : 0, - 'memory_used_human' => (isset($cacheStats['used_memory_human'])) ? $cacheStats['used_memory_human'] : 0, - 'memory_used_peak' => (isset($cacheStats['used_memory_peak'])) ? $cacheStats['used_memory_peak'] : 0, - 'memory_used_peak_human' => (isset($cacheStats['used_memory_peak_human'])) ? $cacheStats['used_memory_peak_human'] : 0, + 'uptime' => $cacheStats['uptime_in_seconds'] ?? 0, + 'clients' => $cacheStats['connected_clients'] ?? 0, + 'hits' => $cacheStats['keyspace_hits'] ?? 0, + 'misses' => $cacheStats['keyspace_misses'] ?? 0, + 'memory_used' => $cacheStats['used_memory'] ?? 0, + 'memory_used_human' => $cacheStats['used_memory_human'] ?? 0, + 'memory_used_peak' => $cacheStats['used_memory_peak'] ?? 0, + 'memory_used_peak_human' => $cacheStats['used_memory_peak_human'] ?? 0, ], ]); }, ['response', 'register']); diff --git a/app/tasks/migrate.php b/app/tasks/migrate.php index efa06e1fed..8f7fc9c7e1 100644 --- a/app/tasks/migrate.php +++ b/app/tasks/migrate.php @@ -59,7 +59,7 @@ $callbacks = [ $offset = $offset + $limit; } - $schema = (isset($_SERVER['_APP_DB_SCHEMA'])) ? $_SERVER['_APP_DB_SCHEMA'] : ''; + $schema = $_SERVER['_APP_DB_SCHEMA'] ?? ''; try { $statement = $db->prepare(" diff --git a/app/views/console/database/collection.phtml b/app/views/console/database/collection.phtml index ea864120e2..fc9f99351c 100644 --- a/app/views/console/database/collection.phtml +++ b/app/views/console/database/collection.phtml @@ -104,10 +104,10 @@ $maxCells = 10; if($i > $maxCells) { break; } - $label = (isset($rule['label'])) ? $rule['label'] : ''; - $key = (isset($rule['key'])) ? $rule['key'] : ''; - $type = (isset($rule['type'])) ? $rule['type'] : ''; - $array = (isset($rule['array'])) ? $rule['array'] : ''; + $label = $rule['label'] ?? ''; + $key = $rule['key'] ?? ''; + $type = $rule['type'] ?? ''; + $array = $rule['array'] ?? ''; ?> diff --git a/app/views/console/database/document.phtml b/app/views/console/database/document.phtml index e8f760f686..5ac9e841ea 100644 --- a/app/views/console/database/document.phtml +++ b/app/views/console/database/document.phtml @@ -17,10 +17,10 @@ $collections = []; render(); ?> getId()) { @@ -48,11 +48,11 @@ $collections = []; @@ -126,11 +126,11 @@ $collections = [];