diff --git a/tests/e2e/ProjectStorageTest.php b/tests/e2e/ProjectStorageTest.php new file mode 100644 index 000000000..d9b7c7148 --- /dev/null +++ b/tests/e2e/ProjectStorageTest.php @@ -0,0 +1,40 @@ +initProject(['files.read', 'files.write']); + } + + /** + * @depends testRegisterSuccess + */ + public function testFileCreateSuccess(array $data): array + { + $file = $this->client->call(Client::METHOD_POST, '/storage/files', [ + 'content-type' => 'multipart/form-data', + 'x-appwrite-project' => $data['projectUid'], + 'x-appwrite-key' => $data['projectAPIKeySecret'], + ], [ + 'files' => new CURLFile(realpath(__DIR__ . '/../resources/logo.png'), 'image/png', 'logo.png'), + 'read' => ['*'], + 'write' => ['*'], + 'folderId' => 'xyz', + ]); + + $this->assertNotEmpty($file['body'][0]['$uid']); + $this->assertEquals('files', $file['body'][0]['$collection']); + $this->assertIsInt($file['body'][0]['dateCreated']); + $this->assertEquals('logo.png', $file['body'][0]['name']); + $this->assertEquals('image/png', $file['body'][0]['mimeType']); + $this->assertEquals(47218, $file['body'][0]['sizeOriginal']); + + return $data; + } +} diff --git a/tests/resources/logo.png b/tests/resources/logo.png new file mode 100644 index 000000000..4f5f4b057 Binary files /dev/null and b/tests/resources/logo.png differ