ILIAS  release_7 Revision v7.30-3-g800a261c036
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 24 of file LegacyPathHelperTest.php.

Member Function Documentation

◆ setUp()

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

@inheritDoc

Definition at line 40 of file LegacyPathHelperTest.php.

40 : void
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 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
const CLIENT_WEB_DIR
Definition: constants.php:45
const CLIENT_DATA_DIR
Definition: constants.php:44
$iliasAbsolutePath
Definition: imgupload.php:33

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

◆ testCreateRelativePathWithInvalidTargetWhichShouldFail()

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

@Test @small

Definition at line 193 of file LegacyPathHelperTest.php.

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.

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 179 of file LegacyPathHelperTest.php.

180 {
181 $expectedPath = 'testtarget/subdir';
182 $target = $this->storagePath . '/' . $expectedPath;
183
185 $this->assertEquals($expectedPath, $result);
186 }
$result

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

+ Here is the call graph for this function:

◆ testCreateRelativePathWithWebTargetWhichShouldSucceed()

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

@Test @small

Definition at line 165 of file LegacyPathHelperTest.php.

166 {
167 $expectedPath = 'testtarget/subdir';
168 $target = $this->webPath . '/' . $expectedPath;
169
171 $this->assertEquals($expectedPath, $result);
172 }

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

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()

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

@Test @small

Definition at line 132 of file LegacyPathHelperTest.php.

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
141 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
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.
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 150 of file LegacyPathHelperTest.php.

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 }

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 115 of file LegacyPathHelperTest.php.

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
124 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
125 $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
126 }

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 97 of file LegacyPathHelperTest.php.

98 {
99 $target = $this->storagePath . '/testtarget';
100
101 $this->filesystemsMock
102 ->shouldReceive('storage')
103 ->once()
104 ->andReturn(Mockery::mock(Filesystem::class));
105
106 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
107 $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
108 }

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 79 of file LegacyPathHelperTest.php.

80 {
81 $target = $this->webPath . '/testtarget';
82
83 $this->filesystemsMock
84 ->shouldReceive('web')
85 ->once()
86 ->andReturn(Mockery::mock(Filesystem::class));
87
88 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
89 $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
90 }

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 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: