2019-12-27 06:25:59 +13:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Tests;
|
|
|
|
|
|
|
|
use Exception;
|
2020-03-25 06:56:32 +13:00
|
|
|
use Appwrite\Storage\Storage;
|
2020-06-12 07:36:10 +12:00
|
|
|
use Appwrite\Storage\Device\Local;
|
2019-12-27 06:25:59 +13:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
2020-07-03 04:11:07 +12:00
|
|
|
Storage::setDevice('disk-a', new Local(__DIR__ . '/../../resources/disk-a'));
|
|
|
|
Storage::setDevice('disk-b', new Local(__DIR__ . '/../../resources/disk-b'));
|
2019-12-27 06:25:59 +13:00
|
|
|
|
|
|
|
class StorageTest extends TestCase
|
|
|
|
{
|
2020-10-01 10:54:16 +13:00
|
|
|
public function setUp(): void
|
2019-12-27 06:25:59 +13:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-10-01 10:54:16 +13:00
|
|
|
public function tearDown(): void
|
2019-12-27 06:25:59 +13:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetters()
|
|
|
|
{
|
2020-06-12 07:36:10 +12:00
|
|
|
$this->assertEquals(get_class(Storage::getDevice('disk-a')), 'Appwrite\Storage\Device\Local');
|
|
|
|
$this->assertEquals(get_class(Storage::getDevice('disk-b')), 'Appwrite\Storage\Device\Local');
|
2019-12-27 06:25:59 +13:00
|
|
|
|
|
|
|
try {
|
|
|
|
get_class(Storage::getDevice('disk-c'));
|
|
|
|
$this->fail("Expected exception not thrown");
|
2020-10-28 08:48:38 +13:00
|
|
|
} catch (Exception $e) {
|
2019-12-27 06:25:59 +13:00
|
|
|
$this->assertEquals('The device "disk-c" is not listed', $e->getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testExists()
|
|
|
|
{
|
|
|
|
$this->assertEquals(Storage::exists('disk-a'), true);
|
|
|
|
$this->assertEquals(Storage::exists('disk-b'), true);
|
|
|
|
$this->assertEquals(Storage::exists('disk-c'), false);
|
|
|
|
}
|
2020-10-01 10:54:16 +13:00
|
|
|
}
|