21 \Hamcrest\Util::registerGlobalFunctions();
    49     private \ILIAS\Filesystem\Provider\FlySystem\FlySystemFileStreamAccess 
$subject;
    56     protected function setUp(): void
    60         $this->filesystemMock = \Mockery::mock(FilesystemOperator::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(UnableToReadFile::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
   133             ->shouldReceive(
'fileExists')
   137             ->shouldReceive(
'writeStream')
   139             ->withArgs([
$path, \resourceValue()])
   142         $this->subject->writeStream(
$path, $stream);
   151         $path = 
'/path/to/your/file';
   152         $fileContent = 
'Awesome file content';
   156         $this->expectException(\InvalidArgumentException::class);
   157         $this->expectExceptionMessage(
'The given stream must not be detached.');
   159         $this->subject->writeStream(
$path, $stream);
   168         $path = 
'/path/to/your/file';
   169         $fileContent = 
'Awesome file content';
   172         $this->filesystemMock
   173             ->shouldReceive(
'fileExists')
   177         $this->expectException(FileAlreadyExistsException::class);
   178         $this->expectExceptionMessage(
"File \"$path\" already exists.");
   180         $this->subject->writeStream(
$path, $stream);
   189         $path = 
'/path/to/your/file';
   190         $fileContent = 
'Awesome file content';
   193         $this->filesystemMock
   194             ->shouldReceive(
'fileExists')
   198             ->shouldReceive(
'writeStream')
   200             ->withArgs([
$path, \resourceValue()])
   201             ->andThrow(UnableToWriteFile::class);
   203         $this->expectException(IOException::class);
   204         $this->expectExceptionMessage(
"Could not write stream to file \"$path\"");
   206         $this->subject->writeStream(
$path, $stream);
   215         $path = 
'/path/to/your/file';
   216         $fileContent = 
'Awesome file content';
   219         $this->filesystemMock->shouldReceive(
'putStream')
   221             ->withArgs([
$path, \resourceValue()])
   224         $this->subject->putStream(
$path, $stream);
   233         $path = 
'/path/to/your/file';
   234         $fileContent = 
'Awesome file content';
   237         $this->filesystemMock->shouldReceive(
'putStream')
   239             ->withArgs([
$path, \resourceValue()])
   242         $this->expectException(IOException::class);
   243         $this->expectExceptionMessage(
"Could not put stream content into \"$path\"");
   245         $this->subject->putStream(
$path, $stream);
   254         $path = 
'/path/to/your/file';
   255         $fileContent = 
'Awesome file content';
   259         $this->expectException(\InvalidArgumentException::class);
   260         $this->expectExceptionMessage(
'The given stream must not be detached.');
   262         $this->subject->putStream(
$path, $stream);
   271         $path = 
'/path/to/your/file';
   272         $fileContent = 
'Awesome file content';
   275         $this->filesystemMock->shouldReceive(
'writeStream')
   277             ->withArgs([
$path, \resourceValue()])
   280         $this->subject->updateStream(
$path, $stream);
   289         $path = 
'/path/to/your/file';
   290         $fileContent = 
'Awesome file content';
   294         $this->expectException(\InvalidArgumentException::class);
   295         $this->expectExceptionMessage(
'The given stream must not be detached.');
   297         $this->subject->updateStream(
$path, $stream);
   306         $path = 
'/path/to/your/file';
   307         $fileContent = 
'Awesome file content';
   310         $this->filesystemMock
   311             ->shouldReceive(
'writeStream')
   313             ->withArgs([
$path, \resourceValue()])
   314             ->andThrow(UnableToWriteFile::class);
   316         $this->expectException(IOException::class);
   317         $this->expectExceptionMessage(
"Unable to update Stream in \"$path\".");
   319         $this->subject->updateStream(
$path, $stream);
   328         $path = 
'/path/to/your/file';
   329         $fileContent = 
'Awesome file content';
   332         $this->filesystemMock
   333             ->shouldReceive(
'writeStream')
   335             ->withArgs([
$path, \resourceValue()])
   336             ->andThrow(UnableToWriteFile::class);
   339         $this->expectExceptionMessage(
"Unable to update Stream in \"$path\".");
   341         $this->subject->updateStream(
$path, $stream);
 testWriteStreamWithExistingFileWhichShouldFail()
 
ILIAS Filesystem Provider FlySystem FlySystemFileStreamAccess $subject
 
testWriteStreamWhichShouldSucceed()
 
testPutStreamWithDetachedStreamWhichShouldFail()
 
testPutStreamWhichShouldSucceed()
 
Class ChatMainBarProvider . 
 
testWriteStreamWithDetachedStreamWhichShouldFail()
 
testReadStreamWhichShouldSucceed()
 
testUpdateStreamWithDetachedStreamWhichShouldFail()
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
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()
 
Mockery LegacyMockInterface $filesystemMock
 
testReadStreamWithGeneralFailureWhichShouldFail()