test for create file with bucket support
This commit is contained in:
parent
29cb5e9fef
commit
2f5dea62dc
22
tests/e2e/Scopes/SideConsole.php
Normal file
22
tests/e2e/Scopes/SideConsole.php
Normal 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';
|
||||
}
|
||||
}
|
|
@ -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']);
|
||||
|
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue