21use PHPUnit\Framework\Attributes\BackupGlobals;
22use PHPUnit\Framework\Attributes\BackupStaticProperties;
23use PHPUnit\Framework\Attributes\PreserveGlobalState;
24use PHPUnit\Framework\Attributes\RunTestsInSeparateProcesses;
25use PHPUnit\Framework\Attributes\Test;
26use PHPUnit\Framework\Attributes\Small;
31use Mockery\MockInterface;
32use PHPUnit\Framework\TestCase;
38#[BackupGlobals(false)]
39#[BackupStaticProperties(false)]
40#[PreserveGlobalState(false)]
41#[RunTestsInSeparateProcesses]
53 protected function setUp(): void
57 $iliasAbsolutePath =
'/dummy/var/www/html/ilias';
58 $dataDir =
'/dummy/var/www/ildata';
59 $webDir =
'public/data';
63 define(
"CLIENT_DATA_DIR", $dataDir .
'/' .
$clientId);
64 define(
"CLIENT_WEB_DIR", $iliasAbsolutePath .
'/' . $webDir .
'/' .
$clientId);
65 define(
"ILIAS_ABSOLUTE_PATH", $iliasAbsolutePath);
66 define(
"ILIAS_WEB_DIR", $webDir);
67 define(
"CLIENT_ID",
'default');
68 $this->libsPath = $iliasAbsolutePath .
'/' .
'vendor';
73 $this->filesystemsMock = \Mockery::mock(Filesystems::class);
75 $containerMock = Mockery::mock(Container::class);
76 $containerMock->shouldReceive(
'filesystem')
79 ->andReturn($this->filesystemsMock);
89 $target = $this->webPath .
'/testtarget';
91 $this->filesystemsMock
92 ->shouldReceive(
'web')
94 ->andReturn(Mockery::mock(Filesystem::class));
97 $this->assertInstanceOf(\
ILIAS\
Filesystem\Filesystem::class, $filesystem,
'Expecting filesystem instance.');
105 $target = $this->storagePath .
'/testtarget';
107 $this->filesystemsMock
108 ->shouldReceive(
'storage')
110 ->andReturn(Mockery::mock(Filesystem::class));
113 $this->assertInstanceOf(\
ILIAS\
Filesystem\Filesystem::class, $filesystem,
'Expecting filesystem instance.');
121 $target =
'./vendor/bower/bower_components/mediaelement/build';
123 $this->filesystemsMock
124 ->shouldReceive(
'libs')
126 ->andReturn(Mockery::mock(Filesystem::class));
129 $this->assertInstanceOf(\
ILIAS\
Filesystem\Filesystem::class, $filesystem,
'Expecting filesystem instance.');
136 $target = $this->libsPath .
'vendor/bower/bower_components/mediaelement/build';
138 $this->filesystemsMock
139 ->shouldReceive(
'libs')
141 ->andReturn(Mockery::mock(Filesystem::class));
144 $this->assertInstanceOf(\
ILIAS\
Filesystem\Filesystem::class, $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}'");
165 $expectedPath =
'testtarget/subdir';
166 $target = $this->webPath .
'/' . $expectedPath;
169 $this->assertSame($expectedPath, $result);
177 $expectedPath =
'testtarget/subdir';
178 $target = $this->storagePath .
'/' . $expectedPath;
181 $this->assertSame($expectedPath, $result);
189 $target =
'/invalid/path/to/target';
191 $this->expectException(\InvalidArgumentException::class);
192 $this->expectExceptionMessage(
"Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
Customizing of pimple-DIC for ILIAS.
testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()
testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed()
testCreateRelativePathWithInvalidTargetWhichShouldFail()
testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()
testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()
testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()
testCreateRelativePathWithStorageTargetWhichShouldSucceed()
MockInterface Filesystems $filesystemsMock
testCreateRelativePathWithWebTargetWhichShouldSucceed()
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.
The filesystem interface provides the public interface for the Filesystem service API consumer.
The Filesystems interface defines the access methods which can be used to fetch the different filesys...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.