ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 @inheritDoc More...
 

Private Attributes

string $storagePath
 
string $webPath
 
MockInterface Filesystems $filesystemsMock
 

Detailed Description

Member Function Documentation

◆ setUp()

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

@inheritDoc

Definition at line 53 of file LegacyPathHelperTestTBD.php.

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

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

◆ testCreateRelativePathWithInvalidTargetWhichShouldFail()

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

Definition at line 187 of file LegacyPathHelperTestTBD.php.

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

Definition at line 175 of file LegacyPathHelperTestTBD.php.

175 : void
176 {
177 $expectedPath = 'testtarget/subdir';
178 $target = $this->storagePath . '/' . $expectedPath;
179
180 $result = LegacyPathHelper::createRelativePath($target);
181 $this->assertSame($expectedPath, $result);
182 }

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

+ Here is the call graph for this function:

◆ testCreateRelativePathWithWebTargetWhichShouldSucceed()

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

Definition at line 163 of file LegacyPathHelperTestTBD.php.

163 : void
164 {
165 $expectedPath = 'testtarget/subdir';
166 $target = $this->webPath . '/' . $expectedPath;
167
168 $result = LegacyPathHelper::createRelativePath($target);
169 $this->assertSame($expectedPath, $result);
170 }

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

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithAbsoluteLibsTargetWhichShouldSucceed()

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

Definition at line 134 of file LegacyPathHelperTestTBD.php.

134 : void
135 {
136 $target = $this->libsPath . 'vendor/bower/bower_components/mediaelement/build';
137
138 $this->filesystemsMock
139 ->shouldReceive('libs')
140 ->once()
141 ->andReturn(Mockery::mock(Filesystem::class));
142
143 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
144 $this->assertInstanceOf(\ILIAS\Filesystem\Filesystem::class, $filesystem, 'Expecting filesystem instance.');
145 }
static deriveFilesystemFrom(string $absolute_path)
Tries to fetch the filesystem responsible for the absolute path.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

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

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithInvalidTargetWhichShouldFail()

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

Definition at line 150 of file LegacyPathHelperTestTBD.php.

150 : void
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 ( )

Definition at line 119 of file LegacyPathHelperTestTBD.php.

119 : void
120 {
121 $target = './vendor/bower/bower_components/mediaelement/build';
122
123 $this->filesystemsMock
124 ->shouldReceive('libs')
125 ->once()
126 ->andReturn(Mockery::mock(Filesystem::class));
127
128 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
129 $this->assertInstanceOf(\ILIAS\Filesystem\Filesystem::class, $filesystem, 'Expecting filesystem instance.');
130 }

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

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithStorageTargetWhichShouldSucceed()

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

Definition at line 103 of file LegacyPathHelperTestTBD.php.

103 : void
104 {
105 $target = $this->storagePath . '/testtarget';
106
107 $this->filesystemsMock
108 ->shouldReceive('storage')
109 ->once()
110 ->andReturn(Mockery::mock(Filesystem::class));
111
112 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
113 $this->assertInstanceOf(\ILIAS\Filesystem\Filesystem::class, $filesystem, 'Expecting filesystem instance.');
114 }

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

+ Here is the call graph for this function:

◆ testDeriveFilesystemFromWithWebTargetWhichShouldSucceed()

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

Definition at line 87 of file LegacyPathHelperTestTBD.php.

87 : void
88 {
89 $target = $this->webPath . '/testtarget';
90
91 $this->filesystemsMock
92 ->shouldReceive('web')
93 ->once()
94 ->andReturn(Mockery::mock(Filesystem::class));
95
96 $filesystem = LegacyPathHelper::deriveFilesystemFrom($target);
97 $this->assertInstanceOf(\ILIAS\Filesystem\Filesystem::class, $filesystem, 'Expecting filesystem instance.');
98 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $filesystemsMock

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

Definition at line 47 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 45 of file LegacyPathHelperTestTBD.php.

◆ $webPath

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

Definition at line 46 of file LegacyPathHelperTestTBD.php.


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