[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: LfmPathTest.php
<?php namespace Tests; use Illuminate\Http\Request; use Mockery as m; use PHPUnit\Framework\TestCase; use UniSharp\LaravelFilemanager\Lfm; use UniSharp\LaravelFilemanager\LfmItem; use UniSharp\LaravelFilemanager\LfmPath; class LfmPathTest extends TestCase { public function tearDown(): void { m::close(); parent::tearDown(); } public function testMagicGet() { $storage = m::mock(LfmStorage::class); $helper = m::mock(Lfm::class); $helper->shouldReceive('getStorage')->with('files/bar')->andReturn($storage); $helper->shouldReceive('getCategoryName')->andReturn('files'); $helper->shouldReceive('input')->with('working_dir')->andReturn('/bar'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('ds')->andReturn('/'); $path = new LfmPath($helper); $this->assertEquals($storage, $path->storage); } public function testMagicCall() { $storage = m::mock(LfmStorage::class); $storage->shouldReceive('foo')->andReturn('bar'); $helper = m::mock(Lfm::class); $helper->shouldReceive('getStorage')->with('files/bar')->andReturn($storage); $helper->shouldReceive('getCategoryName')->andReturn('files'); $helper->shouldReceive('input')->with('working_dir')->andReturn('/bar'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('ds')->andReturn('/'); $path = new LfmPath($helper); $this->assertEquals('bar', $path->foo()); } public function testDirAndNormalizeWorkingDir() { $helper = m::mock(Lfm::class); $helper->shouldReceive('input')->with('working_dir')->once()->andReturn('foo'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $path = new LfmPath($helper); $this->assertEquals('foo', $path->normalizeWorkingDir()); $this->assertEquals('bar', $path->dir('bar')->normalizeWorkingDir()); } public function testSetNameAndGetName() { $path = new LfmPath(m::mock(Lfm::class)); $path->setName('bar'); $this->assertEquals('bar', $path->getName()); } public function testPath() { $helper = m::mock(Lfm::class); $helper->shouldReceive('getRootFolder')->andReturn('/foo'); $helper->shouldReceive('basePath')->andReturn(realpath(__DIR__ . '/../')); $helper->shouldReceive('input')->with('working_dir')->andReturnNull(); $helper->shouldReceive('getCategoryName')->andReturn('files'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('ds')->andReturn('/'); $storage = m::mock(LfmStorage::class); $storage->shouldReceive('rootPath')->andReturn(realpath(__DIR__ . '/../') . '/storage/app'); $helper->shouldReceive('getStorage')->andReturn($storage); $path = new LfmPath($helper); $this->assertEquals('files/foo', $path->path()); $this->assertEquals('files/foo/bar', $path->setName('bar')->path('storage')); } public function testUrl() { $helper = m::mock(Lfm::class); $helper->shouldReceive('getRootFolder')->andReturn('/foo'); $helper->shouldReceive('input')->with('working_dir')->andReturnNull(); $helper->shouldReceive('getCategoryName')->andReturn('files'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('ds')->andReturn('/'); $storage = m::mock(LfmStorage::class); $storage->shouldReceive('url')->andReturn('/files/foo/foo'); $helper->shouldReceive('getStorage')->andReturn($storage); $path = new LfmPath($helper); $this->assertEquals('/files/foo/foo', $path->setName('foo')->url()); } public function testFolders() { $storage = m::mock(LfmStorage::class); $storage->shouldReceive('directories')->andReturn(['foo/bar']); $helper = m::mock(Lfm::class); $helper->shouldReceive('getCategoryName')->andReturn('files'); $helper->shouldReceive('input')->with('working_dir')->andReturn('/shares'); $helper->shouldReceive('input')->with('sort_type')->andReturn('alphabetic'); $helper->shouldReceive('getStorage')->andReturn($storage); $helper->shouldReceive('getNameFromPath')->andReturn('bar'); $helper->shouldReceive('getThumbFolderName')->andReturn('thumbs'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('ds')->andReturn('/'); $helper->shouldReceive('config') ->with('item_columns') ->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']); $path = new LfmPath($helper); $this->assertInstanceOf(LfmItem::class, $path->folders()[0]); } public function testFiles() { $storage = m::mock(LfmStorage::class); $storage->shouldReceive('files')->andReturn(['foo/bar']); $helper = m::mock(Lfm::class); $helper->shouldReceive('getCategoryName')->andReturn('files'); $helper->shouldReceive('input')->with('working_dir')->andReturn('/shares'); $helper->shouldReceive('input')->with('sort_type')->andReturn('alphabetic'); $helper->shouldReceive('getStorage')->andReturn($storage); $helper->shouldReceive('getNameFromPath')->andReturn('bar'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('ds')->andReturn('/'); $helper->shouldReceive('config') ->with('item_columns') ->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']); $path = new LfmPath($helper); $this->assertInstanceOf(LfmItem::class, $path->files()[0]); } public function testPretty() { $helper = m::mock(Lfm::class); $helper->shouldReceive('getNameFromPath')->andReturn('bar'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('config') ->with('item_columns') ->andReturn(['name', 'url', 'time', 'icon', 'is_file', 'is_image', 'thumb_url']); $path = new LfmPath($helper); $this->assertInstanceOf(LfmItem::class, $path->pretty('foo')); } public function testCreateFolder() { $storage = m::mock(LfmStorage::class); $storage->shouldReceive('rootPath')->andReturn(realpath(__DIR__ . '/../') . '/storage/app'); $storage->shouldReceive('exists')->andReturn(false); $storage->shouldReceive('makeDirectory')->andReturn(true); $helper = m::mock(Lfm::class); $helper->shouldReceive('getStorage')->with('files/bar')->andReturn($storage); $helper->shouldReceive('getCategoryName')->andReturn('files'); $helper->shouldReceive('input')->with('working_dir')->andReturn('/bar'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('ds')->andReturn('/'); $path = new LfmPath($helper); $this->assertNull($path->createFolder('bar')); } public function testCreateFolderButFolderAlreadyExists() { $storage = m::mock(LfmStorage::class); $storage->shouldReceive('exists')->andReturn(true); $storage->shouldReceive('makeDirectory')->andReturn(true); $helper = m::mock(Lfm::class); $helper->shouldReceive('getStorage')->with('files/bar')->andReturn($storage); $helper->shouldReceive('getCategoryName')->andReturn('files'); $helper->shouldReceive('input')->with('working_dir')->andReturn('/bar'); $helper->shouldReceive('isRunningOnWindows')->andReturn(false); $helper->shouldReceive('ds')->andReturn('/'); $path = new LfmPath($helper); $this->assertFalse($path->createFolder('foo')); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: premium320.web-hosting.com
Server IP: 66.29.153.54
PHP Version: 8.2.29
Server Software: LiteSpeed
System: Linux premium320.web-hosting.com 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
HDD Total: 97.87 GB
HDD Free: 76.85 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: aoneqssk
User ID (UID): 1285
Group ID (GID): 1290
Script Owner UID: 1285
Current Dir Owner: 1285