1
0
Fork 0
mirror of synced 2024-06-26 18:20:43 +12:00

test for create file with bucket support

This commit is contained in:
Damodar Lohani 2021-06-18 14:23:36 +05:45
parent 29cb5e9fef
commit 2f5dea62dc
3 changed files with 29 additions and 7 deletions

View file

@ -0,0 +1,22 @@
<?php
namespace Tests\E2E\Scopes;
trait SideConsole
{
public function getHeaders():array
{
return [
'origin' => 'http://localhost',
'cookie' => 'a_session_'.$this->getProject()['$id'].'=' . $this->getRoot()['session'],
];
}
/**
* @return string
*/
public function getSide()
{
return 'console';
}
}

View file

@ -17,16 +17,17 @@ trait StorageBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
], $this->getHeaders()), [
'name' => 'Test Bucket',
'read' => ['role:all'],
'write' => ['role:all'],
]);
var_dump($bucket);
$this->assertEquals(201, $bucket['headers']['status-code']);
$this->assertNotEmpty($bucket['body']['$id']);
$bucketId = $bucket['body']['$id'];
$file = $this->client->call(Client::METHOD_POST, '/storage/' . $bucketId .'/files', array_merge([
$file = $this->client->call(Client::METHOD_POST, '/storage/buckets/' . $bucketId .'/files', array_merge([
'content-type' => 'multipart/form-data',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
@ -34,8 +35,7 @@ trait StorageBase
'read' => ['role:all'],
'write' => ['role:all'],
]);
$this->assertEquals($file['headers']['status-code'], 201);
$this->assertEquals(201, $file['headers']['status-code']);
$this->assertNotEmpty($file['body']['$id']);
$this->assertIsInt($file['body']['dateCreated']);
$this->assertEquals('logo.png', $file['body']['name']);

View file

@ -4,11 +4,11 @@ namespace Tests\E2E\Services\Storage;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectConsole;
use Tests\E2E\Scopes\SideClient;
use Tests\E2E\Scopes\SideConsole;
class StorageConsoleClientTest extends Scope
{
use StorageBase;
use ProjectConsole;
use SideClient;
use SideConsole;
}