1
0
Fork 0
mirror of synced 2024-06-29 03:30:34 +12:00

Added unit tests for storage devices

This commit is contained in:
Eldad Fux 2019-12-27 17:13:38 +02:00
parent 33a07bd858
commit c16267bc0c
4 changed files with 28 additions and 9 deletions

View file

@ -34,7 +34,7 @@ class Local extends Device
*/ */
public function getDescription() public function getDescription()
{ {
return 'Just the local storage that is in the physical or virtual machine'; return 'Adapter for Local storage that is in the physical or virtual machine or mounted to it.';
} }
/** /**

View file

@ -4,7 +4,6 @@ namespace Appwrite\Tests;
use Exception; use Exception;
use Storage\Compression\Algorithms\GZIP; use Storage\Compression\Algorithms\GZIP;
use Storage\Devices\Local;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class GZIPTest extends TestCase class GZIPTest extends TestCase

View file

@ -3,24 +3,44 @@
namespace Appwrite\Tests; namespace Appwrite\Tests;
use Exception; use Exception;
use Storage\Storage;
use Storage\Devices\Local; use Storage\Devices\Local;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class LocalTest extends TestCase class LocalTest extends TestCase
{ {
/**
* @var Local
*/
protected $object = null;
public function setUp() public function setUp()
{ {
$this->object = new Local(__DIR__ . '/../../../resources/disk-a');
} }
public function tearDown() public function tearDown()
{ {
} }
public function testExists() public function testName()
{ {
$this->assertEquals(Storage::exists('disk-a'), true); $this->assertEquals($this->object->getName(), 'Local Storage');
$this->assertEquals(Storage::exists('disk-b'), true); }
$this->assertEquals(Storage::exists('disk-c'), false);
public function testDescription()
{
$this->assertEquals($this->object->getDescription(), 'Adapter for Local storage that is in the physical or virtual machine or mounted to it.');
}
public function testRoot()
{
$this->assertEquals($this->object->getRoot(), '/storage/uploads//usr/share/nginx/html/tests/unit/Storage/Devices/../../../resources/disk-a');
}
public function testPath()
{
$this->assertEquals($this->object->getPath('image.png'), '/storage/uploads//usr/share/nginx/html/tests/unit/Storage/Devices/../../../resources/disk-a/i/m/a/g/image.png');
$this->assertEquals($this->object->getPath('x.png'), '/storage/uploads//usr/share/nginx/html/tests/unit/Storage/Devices/../../../resources/disk-a/x/./p/n/x.png');
$this->assertEquals($this->object->getPath('y'), '/storage/uploads//usr/share/nginx/html/tests/unit/Storage/Devices/../../../resources/disk-a/y/x/x/x/y');
} }
} }

View file

@ -7,8 +7,8 @@ use Storage\Storage;
use Storage\Devices\Local; use Storage\Devices\Local;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
Storage::addDevice('disk-a', new Local(__DIR__ . '../../resources/disk-a')); Storage::addDevice('disk-a', new Local(__DIR__ . '/../../resources/disk-a'));
Storage::addDevice('disk-b', new Local(__DIR__ . '../../resources/disk-b')); Storage::addDevice('disk-b', new Local(__DIR__ . '/../../resources/disk-b'));
class StorageTest extends TestCase class StorageTest extends TestCase
{ {