ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ILIAS\Filesystem\Util\LegacyPathHelperTest Class Reference

Class LegacyPathHelperTest. More...

+ Inheritance diagram for ILIAS\Filesystem\Util\LegacyPathHelperTest:
+ Collaboration diagram for ILIAS\Filesystem\Util\LegacyPathHelperTest:

Public Member Functions

 testDeriveFilesystemFromWithWebTargetWhichShouldSucceed ()
 @Test @small More...
 
 testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed ()
 @Test @small More...
 
 testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed ()
 @Test @small More...
 
 testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed ()
 @Test @small More...
 
 testDeriveFilesystemFromWithInvalidTargetWhichShouldFail ()
 @Test @small More...
 
 testCreateRelativePathWithWebTargetWhichShouldSucceed ()
 @Test @small More...
 
 testCreateRelativePathWithStorageTargetWhichShouldSucceed ()
 @Test @small More...
 
 testCreateRelativePathWithInvalidTargetWhichShouldFail ()
 @Test @small More...
 

Protected Member Functions

 setUp ()
 @inheritDoc More...
 

Private Attributes

 $libsPath
 
 $customizingPath
 
 $tempPath
 
 $storagePath
 
 $webPath
 
 $filesystemsMock
 

Detailed Description

Class LegacyPathHelperTest.

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

@runTestsInSeparateProcesses @preserveGlobalState disabled @backupGlobals disabled @backupStaticAttributes disabled

Definition at line 35 of file LegacyPathHelperTest.php.

Member Function Documentation

◆ setUp()

ILIAS\Filesystem\Util\LegacyPathHelperTest::setUp ( )
protected

@inheritDoc

Definition at line 51 of file LegacyPathHelperTest.php.

51 : void
52 {
53 parent::setUp();
54
55 $iliasAbsolutePath = '/dummy/var/www/html/ilias';
56 $dataDir = '/dummy/var/www/ildata';
57 $webDir = 'data';
58 $clientId = 'default';
59
60 //constants needed for test subject
61 define("CLIENT_DATA_DIR", $dataDir . '/' . $clientId);
62 define("CLIENT_WEB_DIR", $iliasAbsolutePath . '/' . $webDir . '/' . $clientId);
63 define("ILIAS_ABSOLUTE_PATH", $iliasAbsolutePath);
64 define("ILIAS_WEB_DIR", $webDir);
65 define("CLIENT_ID", 'default');
66
67 $this->customizingPath = $iliasAbsolutePath . '/' . 'Customizing';
68 $this->libsPath = $iliasAbsolutePath . '/' . 'libs';
69 $this->webPath = CLIENT_WEB_DIR;
70 $this->storagePath = CLIENT_DATA_DIR;
71 $this->tempPath = sys_get_temp_dir();
72
73 //create mock DI container
74 $this->filesystemsMock = \Mockery::mock(Filesystems::class);
75
76 $containerMock = Mockery::mock(Container::class);
77 $containerMock->shouldReceive('filesystem')
78 ->withNoArgs()
79 ->zeroOrMoreTimes()
80 ->andReturn($this->filesystemsMock);
81
82 $GLOBALS['DIC'] = $containerMock;
83 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const CLIENT_WEB_DIR
Definition: constants.php:47
const CLIENT_DATA_DIR
Definition: constants.php:46
$iliasAbsolutePath
Definition: imgupload.php:49
$clientId
Definition: ltiregend.php:27

References $clientId, $GLOBALS, $iliasAbsolutePath, CLIENT_DATA_DIR, and CLIENT_WEB_DIR.

◆ testCreateRelativePathWithInvalidTargetWhichShouldFail()

ILIAS\Filesystem\Util\LegacyPathHelperTest::testCreateRelativePathWithInvalidTargetWhichShouldFail ( )

@Test @small

Definition at line 204 of file LegacyPathHelperTest.php.

204 : void
205 {
206 $target = '/invalid/path/to/target';
207
208 $this->expectException(\InvalidArgumentException::class);
209 $this->expectExceptionMessage("Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
210
212 }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.

References ILIAS\Filesystem\Util\LegacyPathHelper\createRelativePath().

+ Here is the call graph for this function:

◆ testCreateRelativePathWithStorageTargetWhichShouldSucceed()

ILIAS\Filesystem\Util\LegacyPathHelperTest::testCreateRelativePathWithStorageTargetWhichShouldSucceed ( )

@Test @small

Definition at line 190 of file LegacyPathHelperTest.php.

190 : void
191 {
192 $expectedPath = 'testtarget/subdir';
193 $target = $this->storagePath . '/' . $expectedPath;
194
195 $result = LegacyPathHelper::createRelativePath($target);
196 $this->assertEquals($expectedPath, $result);
197 }

References ILIAS\Filesystem\Util\LegacyPathHelper\createRelativePath().

+ Here is the call graph for this function:

◆ testCreateRelativePathWithWebTargetWhichShouldSucceed()

ILIAS\Filesystem\Util\LegacyPathHelperTest::testCreateRelativePathWithWebTargetWhichShouldSucceed ( )

@Test @small

Definition at line 176 of file LegacyPathHelperTest.php.

176 : void
177 {
178 $expectedPath = 'testtarget/subdir';
179 $target = $this->webPath . '/' . $expectedPath;
180
181 $result = LegacyPathHelper::createRelativePath($target);
182 $this->assertEquals($expectedPath, $result);
183 }

References ILIAS\Filesystem\Util\LegacyPathHelper\createRelativePath().

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()

ILIAS\Filesystem\Util\LegacyPathHelperTest::testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed ( )

@Test @small

Definition at line 143 of file LegacyPathHelperTest.php.

143 : void
144 {
145 $target = $this->libsPath . 'libs/bower/bower_components/mediaelement/build';
146
147 $this->filesystemsMock
148 ->shouldReceive('libs')
149 ->once()
150 ->andReturn(Mockery::mock(Filesystem::class));
151
152 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
153 $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
154 }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...

References ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()

ILIAS\Filesystem\Util\LegacyPathHelperTest::testDeriveFilesystemFromWithInvalidTargetWhichShouldFail ( )

@Test @small

Definition at line 161 of file LegacyPathHelperTest.php.

161 : void
162 {
163 $target = '/invalid/path/to/testtarget';
164
165 $this->expectException(\InvalidArgumentException::class);
166 $this->expectExceptionMessage("Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
167
169 }

References ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed()

ILIAS\Filesystem\Util\LegacyPathHelperTest::testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed ( )

@Test @small

Definition at line 126 of file LegacyPathHelperTest.php.

126 : void
127 {
128 $target = './libs/bower/bower_components/mediaelement/build';
129
130 $this->filesystemsMock
131 ->shouldReceive('libs')
132 ->once()
133 ->andReturn(Mockery::mock(Filesystem::class));
134
135 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
136 $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
137 }

References ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()

ILIAS\Filesystem\Util\LegacyPathHelperTest::testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed ( )

@Test @small

Definition at line 108 of file LegacyPathHelperTest.php.

108 : void
109 {
110 $target = $this->storagePath . '/testtarget';
111
112 $this->filesystemsMock
113 ->shouldReceive('storage')
114 ->once()
115 ->andReturn(Mockery::mock(Filesystem::class));
116
117 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
118 $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
119 }

References ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()

ILIAS\Filesystem\Util\LegacyPathHelperTest::testDeriveFilesystemFromWithWebTargetWhichShouldSucceed ( )

@Test @small

Definition at line 90 of file LegacyPathHelperTest.php.

90 : void
91 {
92 $target = $this->webPath . '/testtarget';
93
94 $this->filesystemsMock
95 ->shouldReceive('web')
96 ->once()
97 ->andReturn(Mockery::mock(Filesystem::class));
98
99 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
100 $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
101 }

References ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

+ Here is the call graph for this function:

Field Documentation

◆ $customizingPath

ILIAS\Filesystem\Util\LegacyPathHelperTest::$customizingPath
private

Definition at line 38 of file LegacyPathHelperTest.php.

◆ $filesystemsMock

MockInterface Filesystems ILIAS\Filesystem\Util\LegacyPathHelperTest::$filesystemsMock
private

Definition at line 45 of file LegacyPathHelperTest.php.

◆ $libsPath

ILIAS\Filesystem\Util\LegacyPathHelperTest::$libsPath
private

Definition at line 37 of file LegacyPathHelperTest.php.

◆ $storagePath

ILIAS\Filesystem\Util\LegacyPathHelperTest::$storagePath
private

Definition at line 40 of file LegacyPathHelperTest.php.

◆ $tempPath

ILIAS\Filesystem\Util\LegacyPathHelperTest::$tempPath
private

Definition at line 39 of file LegacyPathHelperTest.php.

◆ $webPath

ILIAS\Filesystem\Util\LegacyPathHelperTest::$webPath
private

Definition at line 41 of file LegacyPathHelperTest.php.


The documentation for this class was generated from the following file: