ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ILIAS\Filesystem\Util\LegacyPathHelperTest Class Reference
+ 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

string $vendorPath
 
string $storagePath
 
string $webPath
 
Mockery MockInterface ILIAS Filesystem Filesystems $filesystemsMock
 

Detailed Description

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

disabled disabled disabled

Definition at line 37 of file LegacyPathHelperTestTBD.php.

Member Function Documentation

◆ setUp()

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

Definition at line 48 of file LegacyPathHelperTestTBD.php.

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

48  : void
49  {
50  parent::setUp();
51 
52  $iliasAbsolutePath = '/dummy/var/www/html/ilias';
53  $dataDir = '/dummy/var/www/ildata';
54  $webDir = 'public/data';
55  $clientId = 'default';
56 
57  //constants needed for test subject
58  define("CLIENT_DATA_DIR", $dataDir . '/' . $clientId);
59  define("CLIENT_WEB_DIR", $iliasAbsolutePath . '/' . $webDir . '/' . $clientId);
60  define("ILIAS_ABSOLUTE_PATH", $iliasAbsolutePath);
61  define("ILIAS_WEB_DIR", $webDir);
62  define("CLIENT_ID", 'default');
63  $this->libsPath = $iliasAbsolutePath . '/' . 'vendor';
64  $this->webPath = CLIENT_WEB_DIR;
65  $this->storagePath = CLIENT_DATA_DIR;
66 
67  //create mock DI container
68  $this->filesystemsMock = \Mockery::mock(Filesystems::class);
69 
70  $containerMock = Mockery::mock(Container::class);
71  $containerMock->shouldReceive('filesystem')
72  ->withNoArgs()
73  ->zeroOrMoreTimes()
74  ->andReturn($this->filesystemsMock);
75 
76  $GLOBALS['DIC'] = $containerMock;
77  }
$clientId
Definition: ltiregend.php:26
const CLIENT_DATA_DIR
Definition: constants.php:46
$GLOBALS["DIC"]
Definition: wac.php:30
const CLIENT_WEB_DIR
Definition: constants.php:47

◆ testCreateRelativePathWithInvalidTargetWhichShouldFail()

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

Definition at line 198 of file LegacyPathHelperTestTBD.php.

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

198  : void
199  {
200  $target = '/invalid/path/to/target';
201 
202  $this->expectException(\InvalidArgumentException::class);
203  $this->expectExceptionMessage("Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
204 
206  }
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 184 of file LegacyPathHelperTestTBD.php.

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

184  : void
185  {
186  $expectedPath = 'testtarget/subdir';
187  $target = $this->storagePath . '/' . $expectedPath;
188 
189  $result = LegacyPathHelper::createRelativePath($target);
190  $this->assertEquals($expectedPath, $result);
191  }
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 170 of file LegacyPathHelperTestTBD.php.

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

170  : void
171  {
172  $expectedPath = 'testtarget/subdir';
173  $target = $this->webPath . '/' . $expectedPath;
174 
175  $result = LegacyPathHelper::createRelativePath($target);
176  $this->assertEquals($expectedPath, $result);
177  }
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 137 of file LegacyPathHelperTestTBD.php.

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

137  : void
138  {
139  $target = $this->libsPath . 'vendor/bower/bower_components/mediaelement/build';
140 
141  $this->filesystemsMock
142  ->shouldReceive('libs')
143  ->once()
144  ->andReturn(Mockery::mock(Filesystem::class));
145 
146  $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
147  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
148  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()

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

Definition at line 155 of file LegacyPathHelperTestTBD.php.

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

155  : void
156  {
157  $target = '/invalid/path/to/testtarget';
158 
159  $this->expectException(\InvalidArgumentException::class);
160  $this->expectExceptionMessage("Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
161 
163  }
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 120 of file LegacyPathHelperTestTBD.php.

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

120  : void
121  {
122  $target = './vendor/bower/bower_components/mediaelement/build';
123 
124  $this->filesystemsMock
125  ->shouldReceive('libs')
126  ->once()
127  ->andReturn(Mockery::mock(Filesystem::class));
128 
129  $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
130  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
131  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()

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

Definition at line 102 of file LegacyPathHelperTestTBD.php.

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

102  : void
103  {
104  $target = $this->storagePath . '/testtarget';
105 
106  $this->filesystemsMock
107  ->shouldReceive('storage')
108  ->once()
109  ->andReturn(Mockery::mock(Filesystem::class));
110 
111  $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
112  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
113  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()

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

Definition at line 84 of file LegacyPathHelperTestTBD.php.

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

84  : void
85  {
86  $target = $this->webPath . '/testtarget';
87 
88  $this->filesystemsMock
89  ->shouldReceive('web')
90  ->once()
91  ->andReturn(Mockery::mock(Filesystem::class));
92 
93  $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
94  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
95  }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
+ Here is the call graph for this function:

Field Documentation

◆ $filesystemsMock

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

Definition at line 42 of file LegacyPathHelperTestTBD.php.

◆ $storagePath

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

Definition at line 40 of file LegacyPathHelperTestTBD.php.

◆ $vendorPath

string ILIAS\Filesystem\Util\LegacyPathHelperTest::$vendorPath
private

Definition at line 39 of file LegacyPathHelperTestTBD.php.

◆ $webPath

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

Definition at line 41 of file LegacyPathHelperTestTBD.php.


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