Initial commit IQParts\Content

This commit is contained in:
2018-03-01 18:41:55 +01:00
commit 349fa9c003
23 changed files with 1535 additions and 0 deletions

43
test/Unit/FolderTest.php Normal file
View File

@@ -0,0 +1,43 @@
<?php
namespace IQParts\ContentTest\Unit;
use IQParts\Content\Object\Folder;
use IQParts\ContentTest\AbstractTestCase;
use League\Flysystem\Adapter\Local;
use League\Flysystem\Directory;
use League\Flysystem\Filesystem;
final class FolderTest extends AbstractTestCase
{
/**
* @test
*/
public function testFolder()
{
$folder = Folder::fromVariables(
base64_encode('folder'),
'folder',
'folder',
base64_encode('/'),
[],
[base64_encode('folder/test.txt')]
);
$this->assertInstanceOf(Folder::class, $folder);
$fs = new Filesystem(new Local(__DIR__ . '/../files'));
$folder = new Folder($fs->get('folder'));
$this->assertInstanceOf(Folder::class, $folder);
$this->assertEquals('folder', $folder->getBasename());
$this->assertEquals(base64_encode('/'), $folder->getParent());
$this->assertEquals([base64_encode('folder/folder')], $folder->getDirs());
$this->assertEquals([], $folder->getFiles());
$this->assertEquals('folder', $folder->getPath());
$this->assertEquals(base64_encode('folder'), $folder->getId());
$this->assertTrue($folder->isDir());
$this->assertEquals('folder', $folder->getPath());
$this->assertTrue(is_array($folder->toArray()));
$this->assertFalse($folder->isFile());
$this->assertInstanceOf(Directory::class, $folder->getDirectory());
}
}