5require_once(
'./libs/composer/vendor/autoload.php');
11use Mockery\MockInterface;
12use PHPUnit\Framework\TestCase;
40 protected function setUp() : void
45 $dataDir =
'/dummy/var/www/ildata';
47 $clientId =
'default';
50 define(
"CLIENT_DATA_DIR", $dataDir .
'/' . $clientId);
53 define(
"ILIAS_WEB_DIR", $webDir);
54 define(
"CLIENT_ID",
'default');
60 $this->tempPath = sys_get_temp_dir();
63 $this->filesystemsMock = \Mockery::mock(Filesystems::class);
65 $containerMock = Mockery::mock(Container::class);
66 $containerMock->shouldReceive(
'filesystem')
69 ->andReturn($this->filesystemsMock);
81 $target = $this->webPath .
'/testtarget';
83 $this->filesystemsMock
84 ->shouldReceive(
'web')
86 ->andReturn(Mockery::mock(Filesystem::class));
89 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
99 $target = $this->storagePath .
'/testtarget';
101 $this->filesystemsMock
102 ->shouldReceive(
'storage')
104 ->andReturn(Mockery::mock(Filesystem::class));
107 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
117 $target =
'./libs/bower/bower_components/mediaelement/build';
119 $this->filesystemsMock
120 ->shouldReceive(
'libs')
122 ->andReturn(Mockery::mock(Filesystem::class));
125 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
134 $target = $this->libsPath .
'libs/bower/bower_components/mediaelement/build';
136 $this->filesystemsMock
137 ->shouldReceive(
'libs')
139 ->andReturn(Mockery::mock(Filesystem::class));
142 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
152 $target =
'/invalid/path/to/testtarget';
154 $this->expectException(\InvalidArgumentException::class);
155 $this->expectExceptionMessage(
"Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
167 $expectedPath =
'testtarget/subdir';
168 $target = $this->webPath .
'/' . $expectedPath;
171 $this->assertEquals($expectedPath,
$result);
181 $expectedPath =
'testtarget/subdir';
182 $target = $this->storagePath .
'/' . $expectedPath;
185 $this->assertEquals($expectedPath,
$result);
195 $target =
'/invalid/path/to/target';
197 $this->expectException(\InvalidArgumentException::class);
198 $this->expectExceptionMessage(
"Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Class LegacyPathHelperTest.
testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()
@Test @small
testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed()
@Test @small
testCreateRelativePathWithInvalidTargetWhichShouldFail()
@Test @small
testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()
@Test @small
testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()
@Test @small
testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()
@Test @small
testCreateRelativePathWithStorageTargetWhichShouldSucceed()
@Test @small
testCreateRelativePathWithWebTargetWhichShouldSucceed()
@Test @small
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
Interface Filesystem The filesystem interface provides the public interface for the Filesystem servic...
Class Filesystems The Filesystems interface defines the access methods which can be used to fetch the...
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...