removing duplicated storage tests
This commit is contained in:
parent
d4c7ab045a
commit
9f949cedab
|
@ -1,80 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use Utopia\Storage\Compression\Algorithms\GZIP;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class GZIPTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var GZIP
|
||||
*/
|
||||
protected $object = null;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->object = new GZIP();
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testName()
|
||||
{
|
||||
$this->assertEquals($this->object->getName(), 'gzip');
|
||||
}
|
||||
|
||||
public function testCompressDecompressWithText()
|
||||
{
|
||||
$demo = 'This is a demo string';
|
||||
$demoSize = mb_strlen($demo, '8bit');
|
||||
|
||||
$data = $this->object->compress($demo);
|
||||
$dataSize = mb_strlen($data, '8bit');
|
||||
|
||||
$this->assertEquals($demoSize, 21);
|
||||
$this->assertEquals($dataSize, 39);
|
||||
|
||||
$this->assertEquals($this->object->decompress($data), $demo);
|
||||
}
|
||||
|
||||
public function testCompressDecompressWithJPGImage()
|
||||
{
|
||||
$demo = \file_get_contents(__DIR__ . '/../../../../resources/disk-a/kitten-1.jpg');
|
||||
$demoSize = mb_strlen($demo, '8bit');
|
||||
|
||||
$data = $this->object->compress($demo);
|
||||
$dataSize = mb_strlen($data, '8bit');
|
||||
|
||||
$this->assertEquals($demoSize, 599639);
|
||||
$this->assertEquals($dataSize, 599107);
|
||||
|
||||
$this->assertGreaterThan($dataSize, $demoSize);
|
||||
|
||||
$data = $this->object->decompress($data);
|
||||
$dataSize = mb_strlen($data, '8bit');
|
||||
|
||||
$this->assertEquals($dataSize, 599639);
|
||||
}
|
||||
|
||||
public function testCompressDecompressWithPNGImage()
|
||||
{
|
||||
$demo = \file_get_contents(__DIR__ . '/../../../../resources/disk-b/kitten-1.png');
|
||||
$demoSize = mb_strlen($demo, '8bit');
|
||||
|
||||
$data = $this->object->compress($demo);
|
||||
$dataSize = mb_strlen($data, '8bit');
|
||||
|
||||
$this->assertEquals($demoSize, 3038056);
|
||||
$this->assertEquals($dataSize, 3029202);
|
||||
|
||||
$this->assertGreaterThan($dataSize, $demoSize);
|
||||
|
||||
$data = $this->object->decompress($data);
|
||||
$dataSize = mb_strlen($data, '8bit');
|
||||
|
||||
$this->assertEquals($dataSize, 3038056);
|
||||
}
|
||||
}
|
|
@ -1,123 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use Utopia\Storage\Device\Local;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class LocalTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Local
|
||||
*/
|
||||
protected $object = null;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->object = new Local(realpath(__DIR__ . '/../../../resources/disk-a'));
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testName()
|
||||
{
|
||||
$this->assertEquals($this->object->getName(), 'Local Storage');
|
||||
}
|
||||
|
||||
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(), '/usr/src/code/tests/resources/disk-a');
|
||||
}
|
||||
|
||||
public function testPath()
|
||||
{
|
||||
$this->assertEquals($this->object->getPath('image.png'), '/usr/src/code/tests/resources/disk-a/i/m/a/g/image.png');
|
||||
$this->assertEquals($this->object->getPath('x.png'), '/usr/src/code/tests/resources/disk-a/x/./p/n/x.png');
|
||||
$this->assertEquals($this->object->getPath('y'), '/usr/src/code/tests/resources/disk-a/y/x/x/x/y');
|
||||
}
|
||||
|
||||
public function testWrite()
|
||||
{
|
||||
$this->assertEquals($this->object->write($this->object->getPath('text.txt'), 'Hello World'), true);
|
||||
$this->assertEquals(file_exists($this->object->getPath('text.txt')), true);
|
||||
$this->assertEquals(is_readable($this->object->getPath('text.txt')), true);
|
||||
|
||||
$this->object->delete($this->object->getPath('text.txt'));
|
||||
}
|
||||
|
||||
public function testRead()
|
||||
{
|
||||
$this->assertEquals($this->object->write($this->object->getPath('text-for-read.txt'), 'Hello World'), true);
|
||||
$this->assertEquals($this->object->read($this->object->getPath('text-for-read.txt')), 'Hello World');
|
||||
|
||||
$this->object->delete($this->object->getPath('text-for-read.txt'));
|
||||
}
|
||||
|
||||
public function testMove()
|
||||
{
|
||||
$this->assertEquals($this->object->write($this->object->getPath('text-for-move.txt'), 'Hello World'), true);
|
||||
$this->assertEquals($this->object->read($this->object->getPath('text-for-move.txt')), 'Hello World');
|
||||
$this->assertEquals($this->object->move($this->object->getPath('text-for-move.txt'), $this->object->getPath('text-for-move-new.txt')), true);
|
||||
$this->assertEquals($this->object->read($this->object->getPath('text-for-move-new.txt')), 'Hello World');
|
||||
$this->assertEquals(file_exists($this->object->getPath('text-for-move.txt')), false);
|
||||
$this->assertEquals(is_readable($this->object->getPath('text-for-move.txt')), false);
|
||||
$this->assertEquals(file_exists($this->object->getPath('text-for-move-new.txt')), true);
|
||||
$this->assertEquals(is_readable($this->object->getPath('text-for-move-new.txt')), true);
|
||||
|
||||
$this->object->delete($this->object->getPath('text-for-move-new.txt'));
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$this->assertEquals($this->object->write($this->object->getPath('text-for-delete.txt'), 'Hello World'), true);
|
||||
$this->assertEquals($this->object->read($this->object->getPath('text-for-delete.txt')), 'Hello World');
|
||||
$this->assertEquals($this->object->delete($this->object->getPath('text-for-delete.txt')), true);
|
||||
$this->assertEquals(file_exists($this->object->getPath('text-for-delete.txt')), false);
|
||||
$this->assertEquals(is_readable($this->object->getPath('text-for-delete.txt')), false);
|
||||
}
|
||||
|
||||
public function testFileSize()
|
||||
{
|
||||
$this->assertEquals($this->object->getFileSize(__DIR__ . '/../../../resources/disk-a/kitten-1.jpg'), 599639);
|
||||
$this->assertEquals($this->object->getFileSize(__DIR__ . '/../../../resources/disk-a/kitten-2.jpg'), 131958);
|
||||
}
|
||||
|
||||
public function testFileMimeType()
|
||||
{
|
||||
$this->assertEquals($this->object->getFileMimeType(__DIR__ . '/../../../resources/disk-a/kitten-1.jpg'), 'image/jpeg');
|
||||
$this->assertEquals($this->object->getFileMimeType(__DIR__ . '/../../../resources/disk-a/kitten-2.jpg'), 'image/jpeg');
|
||||
$this->assertEquals($this->object->getFileMimeType(__DIR__ . '/../../../resources/disk-b/kitten-1.png'), 'image/png');
|
||||
$this->assertEquals($this->object->getFileMimeType(__DIR__ . '/../../../resources/disk-b/kitten-2.png'), 'image/png');
|
||||
}
|
||||
|
||||
public function testFileHash()
|
||||
{
|
||||
$this->assertEquals($this->object->getFileHash(__DIR__ . '/../../../resources/disk-a/kitten-1.jpg'), '7551f343143d2e24ab4aaf4624996b6a');
|
||||
$this->assertEquals($this->object->getFileHash(__DIR__ . '/../../../resources/disk-a/kitten-2.jpg'), '81702fdeef2e55b1a22617bce4951cb5');
|
||||
$this->assertEquals($this->object->getFileHash(__DIR__ . '/../../../resources/disk-b/kitten-1.png'), '03010f4f02980521a8fd6213b52ec313');
|
||||
$this->assertEquals($this->object->getFileHash(__DIR__ . '/../../../resources/disk-b/kitten-2.png'), '8a9ed992b77e4b62b10e3a5c8ed72062');
|
||||
}
|
||||
|
||||
public function testDirectorySize()
|
||||
{
|
||||
$this->assertGreaterThan(0, $this->object->getDirectorySize(__DIR__ . '/../../../resources/disk-a/'));
|
||||
$this->assertGreaterThan(0, $this->object->getDirectorySize(__DIR__ . '/../../../resources/disk-b/'));
|
||||
}
|
||||
|
||||
public function testPartitionFreeSpace()
|
||||
{
|
||||
$this->assertGreaterThan(0, $this->object->getPartitionFreeSpace());
|
||||
}
|
||||
|
||||
public function testPartitionTotalSpace()
|
||||
{
|
||||
$this->assertGreaterThan(0, $this->object->getPartitionTotalSpace());
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use Exception;
|
||||
use Utopia\Storage\Storage;
|
||||
use Utopia\Storage\Device\Local;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
Storage::setDevice('disk-a', new Local(__DIR__ . '/../../resources/disk-a'));
|
||||
Storage::setDevice('disk-b', new Local(__DIR__ . '/../../resources/disk-b'));
|
||||
|
||||
class StorageTest extends TestCase
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testGetters()
|
||||
{
|
||||
$this->assertEquals(get_class(Storage::getDevice('disk-a')), 'Utopia\Storage\Device\Local');
|
||||
$this->assertEquals(get_class(Storage::getDevice('disk-b')), 'Utopia\Storage\Device\Local');
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use Utopia\Storage\Validator\FileName;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FileNameTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var FileName
|
||||
*/
|
||||
protected $object = null;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->object = new FileName();
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testValues()
|
||||
{
|
||||
$this->assertEquals($this->object->isValid(''), false);
|
||||
$this->assertEquals($this->object->isValid(null), false);
|
||||
$this->assertEquals($this->object->isValid(false), false);
|
||||
$this->assertEquals($this->object->isValid('../test'), false);
|
||||
$this->assertEquals($this->object->isValid('test.png'), true);
|
||||
$this->assertEquals($this->object->isValid('test'), true);
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use Utopia\Storage\Validator\FileSize;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FileSizeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var FileSize
|
||||
*/
|
||||
protected $object = null;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->object = new FileSize(1000);
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testValues()
|
||||
{
|
||||
$this->assertEquals($this->object->isValid(1001), false);
|
||||
$this->assertEquals($this->object->isValid(1000), true);
|
||||
$this->assertEquals($this->object->isValid(999), true);
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use Utopia\Storage\Validator\FileType;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class FileTypeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var FileType
|
||||
*/
|
||||
protected $object = null;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->object = new FileType([FileType::FILE_TYPE_JPEG]);
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testValues()
|
||||
{
|
||||
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-1.jpg'), true);
|
||||
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-2.jpg'), true);
|
||||
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-b/kitten-1.png'), false);
|
||||
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-b/kitten-2.png'), false);
|
||||
}
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Tests;
|
||||
|
||||
use Utopia\Storage\Validator\Upload;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UploadTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var Upload
|
||||
*/
|
||||
protected $object = null;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->object = new Upload();
|
||||
}
|
||||
|
||||
public function tearDown(): void
|
||||
{
|
||||
}
|
||||
|
||||
public function testValues()
|
||||
{
|
||||
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-1.jpg'), false);
|
||||
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-a/kitten-2.jpg'), false);
|
||||
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-b/kitten-1.png'), false);
|
||||
$this->assertEquals($this->object->isValid(__DIR__ . '/../../../resources/disk-b/kitten-2.png'), false);
|
||||
$this->assertEquals($this->object->isValid(__FILE__), false);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue