ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 24 of file LegacyPathHelperTest.php.

Member Function Documentation

◆ setUp()

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

Definition at line 40 of file LegacyPathHelperTest.php.

References PHPMailer\PHPMailer\$clientId, $GLOBALS, and $iliasAbsolutePath.

41  {
42  parent::setUp();
43 
44  $iliasAbsolutePath = '/dummy/var/www/html/ilias';
45  $dataDir = '/dummy/var/www/ildata';
46  $webDir = 'data';
47  $clientId = 'default';
48 
49  //constants needed for test subject
50  define("CLIENT_DATA_DIR", $dataDir . '/' . $clientId);
51  define("CLIENT_WEB_DIR", $iliasAbsolutePath . '/' . $webDir . '/' . $clientId);
52  define("ILIAS_ABSOLUTE_PATH", $iliasAbsolutePath);
53  define("ILIAS_WEB_DIR", $webDir);
54  define("CLIENT_ID", 'default');
55 
56  $this->customizingPath = $iliasAbsolutePath . '/' . 'Customizing';
57  $this->libsPath = $iliasAbsolutePath . '/' . 'libs';
58  $this->webPath = CLIENT_WEB_DIR;
59  $this->storagePath = CLIENT_DATA_DIR;
60  $this->tempPath = sys_get_temp_dir();
61 
62  //create mock DI container
63  $this->filesystemsMock = \Mockery::mock(Filesystems::class);
64 
65  $containerMock = Mockery::mock(Container::class);
66  $containerMock->shouldReceive('filesystem')
67  ->withNoArgs()
68  ->zeroOrMoreTimes()
69  ->andReturn($this->filesystemsMock);
70 
71  $GLOBALS['DIC'] = $containerMock;
72  }
$iliasAbsolutePath
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
if(array_key_exists('provider', $_GET)) elseif(array_key_exists('provider', $_SESSION)) if(!in_array($providerName, ['Google', 'Microsoft', 'Yahoo'])) $clientId

◆ testCreateRelativePathWithInvalidTargetWhichShouldFail()

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

Definition at line 193 of file LegacyPathHelperTest.php.

References $target, and ILIAS\Filesystem\Util\LegacyPathHelper\createRelativePath().

194  {
195  $target = '/invalid/path/to/target';
196 
197  $this->expectException(\InvalidArgumentException::class);
198  $this->expectExceptionMessage("Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
199 
201  }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
$target
Definition: test.php:19
+ Here is the call graph for this function:

◆ testCreateRelativePathWithStorageTargetWhichShouldSucceed()

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

Definition at line 179 of file LegacyPathHelperTest.php.

References $result, $target, and ILIAS\Filesystem\Util\LegacyPathHelper\createRelativePath().

180  {
181  $expectedPath = 'testtarget/subdir';
182  $target = $this->storagePath . '/' . $expectedPath;
183 
185  $this->assertEquals($expectedPath, $result);
186  }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
$result
$target
Definition: test.php:19
+ Here is the call graph for this function:

◆ testCreateRelativePathWithWebTargetWhichShouldSucceed()

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

Definition at line 165 of file LegacyPathHelperTest.php.

References $result, $target, and ILIAS\Filesystem\Util\LegacyPathHelper\createRelativePath().

166  {
167  $expectedPath = 'testtarget/subdir';
168  $target = $this->webPath . '/' . $expectedPath;
169 
171  $this->assertEquals($expectedPath, $result);
172  }
static createRelativePath(string $absolute_path)
Creates a relative path from an absolute path which starts with a valid storage location.
$result
$target
Definition: test.php:19
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()

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

Definition at line 132 of file LegacyPathHelperTest.php.

References $target, and ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

133  {
134  $target = $this->libsPath . 'libs/bower/bower_components/mediaelement/build';
135 
136  $this->filesystemsMock
137  ->shouldReceive('libs')
138  ->once()
139  ->andReturn(Mockery::mock(Filesystem::class));
140 
142  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
143  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
$target
Definition: test.php:19
Class FlySystemFileAccessTest.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()

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

Definition at line 150 of file LegacyPathHelperTest.php.

References $target, and ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

151  {
152  $target = '/invalid/path/to/testtarget';
153 
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}'");
156 
158  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
$target
Definition: test.php:19
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithRelativeLibsTargetWhichShouldSucceed()

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

Definition at line 115 of file LegacyPathHelperTest.php.

References $target, and ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

116  {
117  $target = './libs/bower/bower_components/mediaelement/build';
118 
119  $this->filesystemsMock
120  ->shouldReceive('libs')
121  ->once()
122  ->andReturn(Mockery::mock(Filesystem::class));
123 
125  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
126  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
$target
Definition: test.php:19
Class FlySystemFileAccessTest.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()

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

Definition at line 97 of file LegacyPathHelperTest.php.

References $target, and ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

98  {
99  $target = $this->storagePath . '/testtarget';
100 
101  $this->filesystemsMock
102  ->shouldReceive('storage')
103  ->once()
104  ->andReturn(Mockery::mock(Filesystem::class));
105 
107  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
108  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
$target
Definition: test.php:19
Class FlySystemFileAccessTest.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()

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

Definition at line 79 of file LegacyPathHelperTest.php.

References $target, and ILIAS\Filesystem\Util\LegacyPathHelper\deriveFilesystemFrom().

80  {
81  $target = $this->webPath . '/testtarget';
82 
83  $this->filesystemsMock
84  ->shouldReceive('web')
85  ->once()
86  ->andReturn(Mockery::mock(Filesystem::class));
87 
89  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
90  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
$target
Definition: test.php:19
Class FlySystemFileAccessTest.
+ Here is the call graph for this function:

Field Documentation

◆ $customizingPath

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

Definition at line 27 of file LegacyPathHelperTest.php.

◆ $filesystemsMock

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

Definition at line 34 of file LegacyPathHelperTest.php.

◆ $libsPath

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

Definition at line 26 of file LegacyPathHelperTest.php.

◆ $storagePath

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

Definition at line 29 of file LegacyPathHelperTest.php.

◆ $tempPath

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

Definition at line 28 of file LegacyPathHelperTest.php.

◆ $webPath

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

Definition at line 30 of file LegacyPathHelperTest.php.


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