5 \Hamcrest\Util::registerGlobalFunctions();
49 private \ILIAS\Filesystem\Provider\FlySystem\FlySystemFileStreamAccess
$subject;
56 protected function setUp(): void
60 $this->filesystemMock = \Mockery::mock(FilesystemInterface::class);
70 $path =
'/path/to/your/file';
71 $fileContent =
'Awesome file content';
72 $stream = fopen(
'data://text/plain,' . $fileContent, $fileContent,
'r');
74 $this->filesystemMock->shouldReceive(
'readStream')
79 $wrappedStream = $this->subject->readStream(
$path);
81 $this->assertSame($fileContent, $wrappedStream->getContents());
90 $path =
'/path/to/your/file';
92 $this->filesystemMock->shouldReceive(
'readStream')
95 ->andThrow(FileNotFoundException::class);
98 $this->expectExceptionMessage(
"File \"$path\" not found.");
100 $this->subject->readStream(
$path);
109 $path =
'/path/to/your/file';
111 $this->filesystemMock->shouldReceive(
'readStream')
116 $this->expectException(IOException::class);
117 $this->expectExceptionMessage(
"Could not open stream for file \"$path\"");
119 $this->subject->readStream(
$path);
128 $path =
'/path/to/your/file';
129 $fileContent =
'Awesome file content';
132 $this->filesystemMock->shouldReceive(
'writeStream')
134 ->withArgs([
$path, \resourceValue()])
137 $this->subject->writeStream(
$path, $stream);
146 $path =
'/path/to/your/file';
147 $fileContent =
'Awesome file content';
151 $this->expectException(\InvalidArgumentException::class);
152 $this->expectExceptionMessage(
'The given stream must not be detached.');
154 $this->subject->writeStream(
$path, $stream);
163 $path =
'/path/to/your/file';
164 $fileContent =
'Awesome file content';
167 $this->filesystemMock->shouldReceive(
'writeStream')
169 ->withArgs([
$path, \resourceValue()])
170 ->andThrow(FileExistsException::class);
172 $this->expectException(FileAlreadyExistsException::class);
173 $this->expectExceptionMessage(
"File \"$path\" already exists.");
175 $this->subject->writeStream(
$path, $stream);
184 $path =
'/path/to/your/file';
185 $fileContent =
'Awesome file content';
188 $this->filesystemMock->shouldReceive(
'writeStream')
190 ->withArgs([
$path, \resourceValue()])
193 $this->expectException(IOException::class);
194 $this->expectExceptionMessage(
"Could not write stream to file \"$path\"");
196 $this->subject->writeStream(
$path, $stream);
205 $path =
'/path/to/your/file';
206 $fileContent =
'Awesome file content';
209 $this->filesystemMock->shouldReceive(
'putStream')
211 ->withArgs([
$path, \resourceValue()])
214 $this->subject->putStream(
$path, $stream);
223 $path =
'/path/to/your/file';
224 $fileContent =
'Awesome file content';
227 $this->filesystemMock->shouldReceive(
'putStream')
229 ->withArgs([
$path, \resourceValue()])
232 $this->expectException(IOException::class);
233 $this->expectExceptionMessage(
"Could not put stream content into \"$path\"");
235 $this->subject->putStream(
$path, $stream);
244 $path =
'/path/to/your/file';
245 $fileContent =
'Awesome file content';
249 $this->expectException(\InvalidArgumentException::class);
250 $this->expectExceptionMessage(
'The given stream must not be detached.');
252 $this->subject->putStream(
$path, $stream);
261 $path =
'/path/to/your/file';
262 $fileContent =
'Awesome file content';
265 $this->filesystemMock->shouldReceive(
'updateStream')
267 ->withArgs([
$path, \resourceValue()])
270 $this->subject->updateStream(
$path, $stream);
279 $path =
'/path/to/your/file';
280 $fileContent =
'Awesome file content';
284 $this->expectException(\InvalidArgumentException::class);
285 $this->expectExceptionMessage(
'The given stream must not be detached.');
287 $this->subject->updateStream(
$path, $stream);
296 $path =
'/path/to/your/file';
297 $fileContent =
'Awesome file content';
300 $this->filesystemMock->shouldReceive(
'updateStream')
302 ->withArgs([
$path, \resourceValue()])
305 $this->expectException(IOException::class);
306 $this->expectExceptionMessage(
"Could not update file \"$path\"");
308 $this->subject->updateStream(
$path, $stream);
317 $path =
'/path/to/your/file';
318 $fileContent =
'Awesome file content';
321 $this->filesystemMock->shouldReceive(
'updateStream')
323 ->withArgs([
$path, \resourceValue()])
324 ->andThrow(FileNotFoundException::class);
327 $this->expectExceptionMessage(
"File \"$path\" not found.");
329 $this->subject->updateStream(
$path, $stream);
testWriteStreamWithExistingFileWhichShouldFail()
ILIAS Filesystem Provider FlySystem FlySystemFileStreamAccess $subject
testWriteStreamWhichShouldSucceed()
testPutStreamWithDetachedStreamWhichShouldFail()
testPutStreamWhichShouldSucceed()
Class ChatMainBarProvider .
testWriteStreamWithDetachedStreamWhichShouldFail()
testReadStreamWhichShouldSucceed()
Class FlySystemFileStreamAccessTest.
Class FlySystemFileStreamAccess.
testUpdateStreamWithDetachedStreamWhichShouldFail()
testWriteStreamWithFailingAdapterWhichShouldFail()
testUpdateStreamWithGeneralFailureWhichShouldFail()
testUpdateStreamWithMissingFileWhichShouldFail()
testReadStreamWithMissingFileWhichShouldFail()
testUpdateStreamWhichShouldSucceed()
static ofString(string $string)
Creates a new stream with an initial value.
setUp()
Sets up the fixture, for example, open a network connection.
testPutStreamWithGeneralFailureWhichShouldFail()
Class FlySystemFileAccessTest disabled disabled disabled.
testReadStreamWithGeneralFailureWhichShouldFail()