38 #[BackupGlobals(false)] 39 #[BackupStaticProperties(false)] 40 #[PreserveGlobalState(false)] 41 #[RunTestsInSeparateProcesses] 54 protected function setUp(): void
58 $iliasAbsolutePath =
'/dummy/var/www/html/ilias';
59 $dataDir =
'/dummy/var/www/ildata';
60 $webDir =
'public/data';
64 define(
"CLIENT_DATA_DIR", $dataDir .
'/' .
$clientId);
65 define(
"CLIENT_WEB_DIR", $iliasAbsolutePath .
'/' . $webDir .
'/' . $clientId);
66 define(
"ILIAS_ABSOLUTE_PATH", $iliasAbsolutePath);
67 define(
"ILIAS_WEB_DIR", $webDir);
68 define(
"CLIENT_ID",
'default');
69 $this->libsPath = $iliasAbsolutePath .
'/' .
'vendor';
74 $this->filesystemsMock = \Mockery::mock(Filesystems::class);
76 $containerMock = Mockery::mock(Container::class);
77 $containerMock->shouldReceive(
'filesystem')
80 ->andReturn($this->filesystemsMock);
90 $target = $this->webPath .
'/testtarget';
92 $this->filesystemsMock
93 ->shouldReceive(
'web')
95 ->andReturn(Mockery::mock(Filesystem::class));
98 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
106 $target = $this->storagePath .
'/testtarget';
108 $this->filesystemsMock
109 ->shouldReceive(
'storage')
111 ->andReturn(Mockery::mock(Filesystem::class));
114 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
122 $target =
'./vendor/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.');
137 $target = $this->libsPath .
'vendor/bower/bower_components/mediaelement/build';
139 $this->filesystemsMock
140 ->shouldReceive(
'libs')
142 ->andReturn(Mockery::mock(Filesystem::class));
145 $this->assertTrue($filesystem instanceof
Filesystem,
'Expecting filesystem instance.');
153 $target =
'/invalid/path/to/testtarget';
155 $this->expectException(\InvalidArgumentException::class);
156 $this->expectExceptionMessage(
"Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
166 $expectedPath =
'testtarget/subdir';
167 $target = $this->webPath .
'/' . $expectedPath;
170 $this->assertEquals($expectedPath, $result);
178 $expectedPath =
'testtarget/subdir';
179 $target = $this->storagePath .
'/' . $expectedPath;
182 $this->assertEquals($expectedPath, $result);
190 $target =
'/invalid/path/to/target';
192 $this->expectException(\InvalidArgumentException::class);
193 $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()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed()
testCreateRelativePathWithInvalidTargetWhichShouldFail()
testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()
testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()
testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
MockInterface Filesystems $filesystemsMock
testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()