ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed ()
 
 testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed ()
 
 testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed ()
 
 testDeriveFilesystemFromWithInvalidTargetWhichShouldFail ()
 
 testCreateRelativePathWithWebTargetWhichShouldSucceed ()
 
 testCreateRelativePathWithStorageTargetWhichShouldSucceed ()
 
 testCreateRelativePathWithInvalidTargetWhichShouldFail ()
 

Protected Member Functions

 setUp ()
 

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

disabled disabled disabled

Definition at line 35 of file LegacyPathHelperTest.php.

Member Function Documentation

◆ setUp()

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

Definition at line 51 of file LegacyPathHelperTest.php.

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

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  }
$clientId
Definition: ltiregend.php:27
$iliasAbsolutePath
Definition: imgupload.php:49
const CLIENT_DATA_DIR
Definition: constants.php:46
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const CLIENT_WEB_DIR
Definition: constants.php:47

◆ testCreateRelativePathWithInvalidTargetWhichShouldFail()

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

Definition at line 204 of file LegacyPathHelperTest.php.

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

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.
+ Here is the call graph for this function:

◆ testCreateRelativePathWithStorageTargetWhichShouldSucceed()

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

Definition at line 190 of file LegacyPathHelperTest.php.

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

190  : void
191  {
192  $expectedPath = 'testtarget/subdir';
193  $target = $this->storagePath . '/' . $expectedPath;
194 
195  $result = LegacyPathHelper::createRelativePath($target);
196  $this->assertEquals($expectedPath, $result);
197  }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
+ Here is the call graph for this function:

◆ testCreateRelativePathWithWebTargetWhichShouldSucceed()

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

Definition at line 176 of file LegacyPathHelperTest.php.

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

176  : void
177  {
178  $expectedPath = 'testtarget/subdir';
179  $target = $this->webPath . '/' . $expectedPath;
180 
181  $result = LegacyPathHelper::createRelativePath($target);
182  $this->assertEquals($expectedPath, $result);
183  }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()

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

Definition at line 143 of file LegacyPathHelperTest.php.

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

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 disabled disabled disabled.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()

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

Definition at line 161 of file LegacyPathHelperTest.php.

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

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  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed()

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

Definition at line 126 of file LegacyPathHelperTest.php.

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

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  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
Class FlySystemFileAccessTest disabled disabled disabled.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()

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

Definition at line 108 of file LegacyPathHelperTest.php.

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

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  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
Class FlySystemFileAccessTest disabled disabled disabled.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()

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

Definition at line 90 of file LegacyPathHelperTest.php.

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

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  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
Class FlySystemFileAccessTest disabled disabled disabled.
+ 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: