diff --git a/composer.json b/composer.json index 4814411e0f..e0c3caf63c 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,8 @@ ], "scripts": { "test": "vendor/bin/phpunit", - "lint": "vendor/bin/pint --test", - "format": "vendor/bin/pint", + "lint": "vendor/bin/pint --test --config pint.json", + "format": "vendor/bin/pint --config pint.json", "bench": "vendor/bin/phpbench run --report=benchmark", "check": "./vendor/bin/phpstan analyse -c phpstan.neon" }, diff --git a/phpstan.neon b/phpstan.neon index b18f3d6d58..153b3be21c 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -5,4 +5,5 @@ parameters: scanDirectories: - vendor/swoole/ide-helper excludePaths: - - tests/resources \ No newline at end of file + - tests/resources + - app/sdks \ No newline at end of file diff --git a/tests/e2e/Services/Databases/Legacy/DatabasesBase.php b/tests/e2e/Services/Databases/Legacy/DatabasesBase.php index 554b47f4a5..6aab125478 100644 --- a/tests/e2e/Services/Databases/Legacy/DatabasesBase.php +++ b/tests/e2e/Services/Databases/Legacy/DatabasesBase.php @@ -1437,8 +1437,8 @@ trait DatabasesBase } /** - * @depends testCreateAttributes - */ + * @depends testCreateAttributes + */ public function testGetIndexByKeyWithLengths(array $data): void { $databaseId = $data['databaseId']; @@ -1508,8 +1508,8 @@ trait DatabasesBase $this->assertEquals(400, $create['headers']['status-code']); } /** - * @depends testCreateIndexes - */ + * @depends testCreateIndexes + */ public function testListIndexes(array $data): void { $databaseId = $data['databaseId']; @@ -1979,39 +1979,33 @@ trait DatabasesBase ]); $this->assertEquals(2, $documents['body']['total']); - if ($this->getSide() === 'client') { - // Skipped on server side: Creating a document with no permissions results in an empty permissions array, whereas on client side it assigns permissions to the current user + // test without passing permissions + $document = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'title' => 'Thor: Ragnarok', + 'releaseYear' => 2000 + ] + ]); - // test without passing permissions - $document = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'], - ], $this->getHeaders()), [ - 'data' => [ - 'title' => 'Thor: Ragnarok', - 'releaseYear' => 2000 - ] - ]); + $this->assertEquals(200, $document['headers']['status-code']); + $this->assertEquals('Thor: Ragnarok', $document['body']['title']); - $this->assertEquals(200, $document['headers']['status-code']); - $this->assertEquals('Thor: Ragnarok', $document['body']['title']); - $this->assertCount(3, $document['body']['$permissions']); - $permissionsCreated = $document['body']['$permissions']; - // checking the default created permission - $defaultPermission = [ - Permission::read(Role::user($this->getUser()['$id'])), - Permission::update(Role::user($this->getUser()['$id'])), - Permission::delete(Role::user($this->getUser()['$id'])) - ]; - // ignoring the order of the permission and checking the permissions - $this->assertEqualsCanonicalizing($defaultPermission, $permissionsCreated); + $document = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ])); - $document = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ - 'content-type' => 'application/json', - 'x-appwrite-project' => $this->getProject()['$id'] - ], $this->getHeaders())); + $this->assertEquals(200, $document['headers']['status-code']); - $this->assertEquals(200, $document['headers']['status-code']); + $deleteResponse = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['moviesId'] . '/documents/' . $documentId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + 'x-appwrite-key' => $this->getProject()['apiKey'] + ])); $this->assertEquals(204, $deleteResponse['headers']['status-code']);