1
0
Fork 0
mirror of synced 2024-08-27 08:02:22 +12:00
appwrite/tests/unit/Storage/StorageTest.php

43 lines
1.2 KiB
PHP
Raw Normal View History

2019-12-27 06:25:59 +13:00
<?php
namespace Appwrite\Tests;
use Exception;
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");
} catch(Exception $e) {
$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
}