ILIAS  trunk Revision v5.2.0beta1-34115-g3a2438be29
Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest Class Reference
+ Inheritance diagram for Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest:
+ Collaboration diagram for Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest:

Public Member Functions

 testReadStreamWhichShouldSucceed ()
 
 testReadStreamWithMissingFileWhichShouldFail ()
 
 testReadStreamWithGeneralFailureWhichShouldFail ()
 
 testWriteStreamWhichShouldSucceed ()
 
 testWriteStreamWithDetachedStreamWhichShouldFail ()
 
 testWriteStreamWithExistingFileWhichShouldFail ()
 
 testWriteStreamWithFailingAdapterWhichShouldFail ()
 
 testPutStreamWhichShouldSucceed ()
 
 testPutStreamWithGeneralFailureWhichShouldFail ()
 
 testPutStreamWithDetachedStreamWhichShouldFail ()
 
 testUpdateStreamWhichShouldSucceed ()
 
 testUpdateStreamWithDetachedStreamWhichShouldFail ()
 
 testUpdateStreamWithGeneralFailureWhichShouldFail ()
 
 testUpdateStreamWithMissingFileWhichShouldFail ()
 

Protected Member Functions

 setUp ()
 Sets up the fixture, for example, open a network connection. More...
 

Private Attributes

Mockery LegacyMockInterface $filesystemMock
 
ILIAS Filesystem Provider FlySystem FlySystemFileStreamAccess $subject
 

Detailed Description

Member Function Documentation

◆ setUp()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::setUp ( )
protected

Sets up the fixture, for example, open a network connection.

This method is called before a test is executed.

Definition at line 56 of file FlySystemFileStreamAccessTest.php.

56  : void
57  {
58  parent::setUp();
59 
60  $this->filesystemMock = \Mockery::mock(FilesystemOperator::class);
61  $this->subject = new FlySystemFileStreamAccess($this->filesystemMock);
62  }

◆ testPutStreamWhichShouldSucceed()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testPutStreamWhichShouldSucceed ( )

Definition at line 213 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

213  : void
214  {
215  $path = '/path/to/your/file';
216  $fileContent = 'Awesome file content';
217  $stream = Streams::ofString($fileContent);
218 
219  $this->filesystemMock->shouldReceive('putStream')
220  ->once()
221  ->withArgs([$path, \resourceValue()])
222  ->andReturn(true);
223 
224  $this->subject->putStream($path, $stream);
225  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testPutStreamWithDetachedStreamWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testPutStreamWithDetachedStreamWhichShouldFail ( )

Definition at line 252 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

252  : void
253  {
254  $path = '/path/to/your/file';
255  $fileContent = 'Awesome file content';
256  $stream = Streams::ofString($fileContent);
257  $stream->detach();
258 
259  $this->expectException(\InvalidArgumentException::class);
260  $this->expectExceptionMessage('The given stream must not be detached.');
261 
262  $this->subject->putStream($path, $stream);
263  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testPutStreamWithGeneralFailureWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testPutStreamWithGeneralFailureWhichShouldFail ( )

Definition at line 231 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

231  : void
232  {
233  $path = '/path/to/your/file';
234  $fileContent = 'Awesome file content';
235  $stream = Streams::ofString($fileContent);
236 
237  $this->filesystemMock->shouldReceive('putStream')
238  ->once()
239  ->withArgs([$path, \resourceValue()])
240  ->andReturn(false);
241 
242  $this->expectException(IOException::class);
243  $this->expectExceptionMessage("Could not put stream content into \"$path\"");
244 
245  $this->subject->putStream($path, $stream);
246  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testReadStreamWhichShouldSucceed()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testReadStreamWhichShouldSucceed ( )

Definition at line 68 of file FlySystemFileStreamAccessTest.php.

References $path.

68  : void
69  {
70  $path = '/path/to/your/file';
71  $fileContent = 'Awesome file content';
72  $stream = fopen('data://text/plain,' . $fileContent, $fileContent, 'r');
73 
74  $this->filesystemMock->shouldReceive('readStream')
75  ->once()
76  ->with($path)
77  ->andReturn($stream);
78 
79  $wrappedStream = $this->subject->readStream($path);
80 
81  $this->assertSame($fileContent, $wrappedStream->getContents());
82  }
$path
Definition: ltiservices.php:30

◆ testReadStreamWithGeneralFailureWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testReadStreamWithGeneralFailureWhichShouldFail ( )

Definition at line 107 of file FlySystemFileStreamAccessTest.php.

References $path.

107  : void
108  {
109  $path = '/path/to/your/file';
110 
111  $this->filesystemMock->shouldReceive('readStream')
112  ->once()
113  ->with($path)
114  ->andReturn(false);
115 
116  $this->expectException(IOException::class);
117  $this->expectExceptionMessage("Could not open stream for file \"$path\"");
118 
119  $this->subject->readStream($path);
120  }
$path
Definition: ltiservices.php:30

◆ testReadStreamWithMissingFileWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testReadStreamWithMissingFileWhichShouldFail ( )

Definition at line 88 of file FlySystemFileStreamAccessTest.php.

References $path.

88  : void
89  {
90  $path = '/path/to/your/file';
91 
92  $this->filesystemMock->shouldReceive('readStream')
93  ->once()
94  ->with($path)
95  ->andThrow(UnableToReadFile::class);
96 
97  $this->expectException(\ILIAS\Filesystem\Exception\FileNotFoundException::class);
98  $this->expectExceptionMessage("File \"$path\" not found.");
99 
100  $this->subject->readStream($path);
101  }
Interface Observer Contains several chained tasks and infos about them.
$path
Definition: ltiservices.php:30

◆ testUpdateStreamWhichShouldSucceed()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testUpdateStreamWhichShouldSucceed ( )

Definition at line 269 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

269  : void
270  {
271  $path = '/path/to/your/file';
272  $fileContent = 'Awesome file content';
273  $stream = Streams::ofString($fileContent);
274 
275  $this->filesystemMock->shouldReceive('writeStream')
276  ->once()
277  ->withArgs([$path, \resourceValue()])
278  ->andReturn(true);
279 
280  $this->subject->updateStream($path, $stream);
281  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testUpdateStreamWithDetachedStreamWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testUpdateStreamWithDetachedStreamWhichShouldFail ( )

Definition at line 287 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

287  : void
288  {
289  $path = '/path/to/your/file';
290  $fileContent = 'Awesome file content';
291  $stream = Streams::ofString($fileContent);
292  $stream->detach();
293 
294  $this->expectException(\InvalidArgumentException::class);
295  $this->expectExceptionMessage('The given stream must not be detached.');
296 
297  $this->subject->updateStream($path, $stream);
298  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testUpdateStreamWithGeneralFailureWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testUpdateStreamWithGeneralFailureWhichShouldFail ( )

Definition at line 304 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

304  : void
305  {
306  $path = '/path/to/your/file';
307  $fileContent = 'Awesome file content';
308  $stream = Streams::ofString($fileContent);
309 
310  $this->filesystemMock
311  ->shouldReceive('writeStream')
312  ->once()
313  ->withArgs([$path, \resourceValue()])
314  ->andThrow(UnableToWriteFile::class);
315 
316  $this->expectException(IOException::class);
317  $this->expectExceptionMessage("Unable to update Stream in \"$path\".");
318 
319  $this->subject->updateStream($path, $stream);
320  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testUpdateStreamWithMissingFileWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testUpdateStreamWithMissingFileWhichShouldFail ( )

Definition at line 326 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

326  : void
327  {
328  $path = '/path/to/your/file';
329  $fileContent = 'Awesome file content';
330  $stream = Streams::ofString($fileContent);
331 
332  $this->filesystemMock
333  ->shouldReceive('writeStream')
334  ->once()
335  ->withArgs([$path, \resourceValue()])
336  ->andThrow(UnableToWriteFile::class);
337 
338  $this->expectException(\ILIAS\Filesystem\Exception\FileNotFoundException::class);
339  $this->expectExceptionMessage("Unable to update Stream in \"$path\".");
340 
341  $this->subject->updateStream($path, $stream);
342  }
Interface Observer Contains several chained tasks and infos about them.
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testWriteStreamWhichShouldSucceed()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testWriteStreamWhichShouldSucceed ( )

Definition at line 126 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

126  : void
127  {
128  $path = '/path/to/your/file';
129  $fileContent = 'Awesome file content';
130  $stream = Streams::ofString($fileContent);
131 
132  $this->filesystemMock
133  ->shouldReceive('fileExists')
134  ->once()
135  ->andReturn(false)
136  ->getMock()
137  ->shouldReceive('writeStream')
138  ->once()
139  ->withArgs([$path, \resourceValue()])
140  ->andReturn(true);
141 
142  $this->subject->writeStream($path, $stream);
143  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testWriteStreamWithDetachedStreamWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testWriteStreamWithDetachedStreamWhichShouldFail ( )

Definition at line 149 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

149  : void
150  {
151  $path = '/path/to/your/file';
152  $fileContent = 'Awesome file content';
153  $stream = Streams::ofString($fileContent);
154  $stream->detach();
155 
156  $this->expectException(\InvalidArgumentException::class);
157  $this->expectExceptionMessage('The given stream must not be detached.');
158 
159  $this->subject->writeStream($path, $stream);
160  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testWriteStreamWithExistingFileWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testWriteStreamWithExistingFileWhichShouldFail ( )

Definition at line 166 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

166  : void
167  {
168  $path = '/path/to/your/file';
169  $fileContent = 'Awesome file content';
170  $stream = Streams::ofString($fileContent);
171 
172  $this->filesystemMock
173  ->shouldReceive('fileExists')
174  ->once()
175  ->andReturn(true);
176 
177  $this->expectException(FileAlreadyExistsException::class);
178  $this->expectExceptionMessage("File \"$path\" already exists.");
179 
180  $this->subject->writeStream($path, $stream);
181  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

◆ testWriteStreamWithFailingAdapterWhichShouldFail()

Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::testWriteStreamWithFailingAdapterWhichShouldFail ( )

Definition at line 187 of file FlySystemFileStreamAccessTest.php.

References $path, and ILIAS\Filesystem\Stream\Streams\ofString().

187  : void
188  {
189  $path = '/path/to/your/file';
190  $fileContent = 'Awesome file content';
191  $stream = Streams::ofString($fileContent);
192 
193  $this->filesystemMock
194  ->shouldReceive('fileExists')
195  ->once()
196  ->andReturn(false)
197  ->getMock()
198  ->shouldReceive('writeStream')
199  ->once()
200  ->withArgs([$path, \resourceValue()])
201  ->andThrow(UnableToWriteFile::class);
202 
203  $this->expectException(IOException::class);
204  $this->expectExceptionMessage("Could not write stream to file \"$path\"");
205 
206  $this->subject->writeStream($path, $stream);
207  }
$path
Definition: ltiservices.php:30
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
+ Here is the call graph for this function:

Field Documentation

◆ $filesystemMock

Mockery LegacyMockInterface Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::$filesystemMock
private

Definition at line 48 of file FlySystemFileStreamAccessTest.php.

◆ $subject

ILIAS Filesystem Provider FlySystem FlySystemFileStreamAccess Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest::$subject
private

Definition at line 49 of file FlySystemFileStreamAccessTest.php.


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