48 protected function setUp(): void
52 $iliasAbsolutePath =
'/dummy/var/www/html/ilias';
53 $dataDir =
'/dummy/var/www/ildata';
58 define(
"CLIENT_DATA_DIR", $dataDir .
'/' .
$clientId);
59 define(
"CLIENT_WEB_DIR", $iliasAbsolutePath .
'/' . $webDir .
'/' . $clientId);
60 define(
"ILIAS_ABSOLUTE_PATH", $iliasAbsolutePath);
61 define(
"ILIAS_WEB_DIR", $webDir);
62 define(
"CLIENT_ID",
'default');
63 $this->libsPath = $iliasAbsolutePath .
'/' .
'libs';
68 $this->filesystemsMock = \Mockery::mock(Filesystems::class);
70 $containerMock = Mockery::mock(Container::class);
71 $containerMock->shouldReceive(
'filesystem')
74 ->andReturn($this->filesystemsMock);
86 $target = $this->webPath .
'/testtarget';
88 $this->filesystemsMock
89 ->shouldReceive(
'web')
91 ->andReturn(Mockery::mock(Filesystem::class));
94 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
104 $target = $this->storagePath .
'/testtarget';
106 $this->filesystemsMock
107 ->shouldReceive(
'storage')
109 ->andReturn(Mockery::mock(Filesystem::class));
112 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
122 $target =
'./libs/bower/bower_components/mediaelement/build';
124 $this->filesystemsMock
125 ->shouldReceive(
'libs')
127 ->andReturn(Mockery::mock(Filesystem::class));
130 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
139 $target = $this->libsPath .
'libs/bower/bower_components/mediaelement/build';
141 $this->filesystemsMock
142 ->shouldReceive(
'libs')
144 ->andReturn(Mockery::mock(Filesystem::class));
147 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
157 $target =
'/invalid/path/to/testtarget';
159 $this->expectException(\InvalidArgumentException::class);
160 $this->expectExceptionMessage(
"Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
172 $expectedPath =
'testtarget/subdir';
173 $target = $this->webPath .
'/' . $expectedPath;
176 $this->assertEquals($expectedPath, $result);
186 $expectedPath =
'testtarget/subdir';
187 $target = $this->storagePath .
'/' . $expectedPath;
190 $this->assertEquals($expectedPath, $result);
200 $target =
'/invalid/path/to/target';
202 $this->expectException(\InvalidArgumentException::class);
203 $this->expectExceptionMessage(
"Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
testCreateRelativePathWithStorageTargetWhichShouldSucceed()
testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed()
testCreateRelativePathWithInvalidTargetWhichShouldFail()
testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()
testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()
testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testCreateRelativePathWithWebTargetWhichShouldSucceed()
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
Mockery MockInterface ILIAS Filesystem Filesystems $filesystemsMock
testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()
The Filesystems interface defines the access methods which can be used to fetch the different filesys...