ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 

Data Fields

 $libsPath
 

Protected Member Functions

 setUp ()
 

Private Attributes

string $vendorPath
 
string $storagePath
 
string $webPath
 
MockInterface Filesystems $filesystemsMock
 

Detailed Description

Member Function Documentation

◆ setUp()

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

Definition at line 54 of file LegacyPathHelperTestTBD.php.

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

54  : void
55  {
56  parent::setUp();
57 
58  $iliasAbsolutePath = '/dummy/var/www/html/ilias';
59  $dataDir = '/dummy/var/www/ildata';
60  $webDir = 'public/data';
61  $clientId = 'default';
62 
63  //constants needed for test subject
64  define("CLIENT_DATA_DIR", $dataDir . '/' . $clientId);
65  define("CLIENT_WEB_DIR", $iliasAbsolutePath . '/' . $webDir . '/' . $clientId);
66  define("ILIAS_ABSOLUTE_PATH", $iliasAbsolutePath);
67  define("ILIAS_WEB_DIR", $webDir);
68  define("CLIENT_ID", 'default');
69  $this->libsPath = $iliasAbsolutePath . '/' . 'vendor';
70  $this->webPath = CLIENT_WEB_DIR;
71  $this->storagePath = CLIENT_DATA_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:25
const CLIENT_DATA_DIR
Definition: constants.php:46
$GLOBALS["DIC"]
Definition: wac.php:53
const CLIENT_WEB_DIR
Definition: constants.php:47

◆ testCreateRelativePathWithInvalidTargetWhichShouldFail()

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

Definition at line 188 of file LegacyPathHelperTestTBD.php.

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

188  : void
189  {
190  $target = '/invalid/path/to/target';
191 
192  $this->expectException(\InvalidArgumentException::class);
193  $this->expectExceptionMessage("Invalid path supplied. Path must start with the web, storage, temp, customizing or libs storage location. Path given: '{$target}'");
194 
196  }
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 176 of file LegacyPathHelperTestTBD.php.

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

176  : void
177  {
178  $expectedPath = 'testtarget/subdir';
179  $target = $this->storagePath . '/' . $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:

◆ testCreateRelativePathWithWebTargetWhichShouldSucceed()

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

Definition at line 164 of file LegacyPathHelperTestTBD.php.

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

164  : void
165  {
166  $expectedPath = 'testtarget/subdir';
167  $target = $this->webPath . '/' . $expectedPath;
168 
169  $result = LegacyPathHelper::createRelativePath($target);
170  $this->assertEquals($expectedPath, $result);
171  }
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 135 of file LegacyPathHelperTestTBD.php.

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

135  : void
136  {
137  $target = $this->libsPath . 'vendor/bower/bower_components/mediaelement/build';
138 
139  $this->filesystemsMock
140  ->shouldReceive('libs')
141  ->once()
142  ->andReturn(Mockery::mock(Filesystem::class));
143 
144  $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
145  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
146  }
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 151 of file LegacyPathHelperTestTBD.php.

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

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

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

104  : void
105  {
106  $target = $this->storagePath . '/testtarget';
107 
108  $this->filesystemsMock
109  ->shouldReceive('storage')
110  ->once()
111  ->andReturn(Mockery::mock(Filesystem::class));
112 
113  $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
114  $this->assertTrue($filesystem instanceof Filesystem, 'Expecting filesystem instance.');
115  }
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 88 of file LegacyPathHelperTestTBD.php.

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

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

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

Definition at line 48 of file LegacyPathHelperTestTBD.php.

◆ $libsPath

ILIAS\Filesystem\Util\LegacyPathHelperTest::$libsPath

Definition at line 44 of file LegacyPathHelperTestTBD.php.

◆ $storagePath

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

Definition at line 46 of file LegacyPathHelperTestTBD.php.

◆ $vendorPath

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

Definition at line 45 of file LegacyPathHelperTestTBD.php.

◆ $webPath

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

Definition at line 47 of file LegacyPathHelperTestTBD.php.


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