ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Filesystem\Provider\FlySystem\FlySystemFileStreamAccessTest Class Reference

Class FlySystemFileStreamAccessTest. More...

+ 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

 $filesystemMock
 
 $subject
 

Detailed Description

Class FlySystemFileStreamAccessTest.

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch

disabled disabled disabled

Definition at line 28 of file FlySystemFileStreamAccessTest.php.

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 46 of file FlySystemFileStreamAccessTest.php.

47  {
48  parent::setUp();
49 
50  $this->filesystemMock = \Mockery::mock(FilesystemInterface::class);
51  $this->subject = new FlySystemFileStreamAccess($this->filesystemMock);
52  }

◆ testPutStreamWhichShouldSucceed()

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

Definition at line 193 of file FlySystemFileStreamAccessTest.php.

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

194  {
195  $path = '/path/to/your/file';
196  $fileContent = 'Awesome file content';
197  $stream = Streams::ofString($fileContent);
198 
199  $this->filesystemMock->shouldReceive('putStream')
200  ->once()
201  ->withArgs([$path, resourceValue()])
202  ->andReturn(true);
203 
204  $this->subject->putStream($path, $stream);
205  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testPutStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 232 of file FlySystemFileStreamAccessTest.php.

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

233  {
234  $path = '/path/to/your/file';
235  $fileContent = 'Awesome file content';
236  $stream = Streams::ofString($fileContent);
237  $stream->detach();
238 
239  $this->expectException(\InvalidArgumentException::class);
240  $this->expectExceptionMessage('The given stream must not be detached.');
241 
242  $this->subject->putStream($path, $stream);
243  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testPutStreamWithGeneralFailureWhichShouldFail()

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

Definition at line 211 of file FlySystemFileStreamAccessTest.php.

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

212  {
213  $path = '/path/to/your/file';
214  $fileContent = 'Awesome file content';
215  $stream = Streams::ofString($fileContent);
216 
217  $this->filesystemMock->shouldReceive('putStream')
218  ->once()
219  ->withArgs([$path, resourceValue()])
220  ->andReturn(false);
221 
222  $this->expectException(IOException::class);
223  $this->expectExceptionMessage("Could not put stream content into \"$path\"");
224 
225  $this->subject->putStream($path, $stream);
226  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testReadStreamWhichShouldSucceed()

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

Definition at line 58 of file FlySystemFileStreamAccessTest.php.

References $path, and GuzzleHttp\Psr7\$stream.

59  {
60  $path = '/path/to/your/file';
61  $fileContent = 'Awesome file content';
62  $stream = fopen('data://text/plain,' . $fileContent, $fileContent, 'r');
63 
64  $this->filesystemMock->shouldReceive('readStream')
65  ->once()
66  ->with($path)
67  ->andReturn($stream);
68 
69  $wrappedStream = $this->subject->readStream($path);
70 
71  $this->assertSame($fileContent, $wrappedStream->getContents());
72  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.

◆ testReadStreamWithGeneralFailureWhichShouldFail()

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

Definition at line 97 of file FlySystemFileStreamAccessTest.php.

References $path.

98  {
99  $path = '/path/to/your/file';
100 
101  $this->filesystemMock->shouldReceive('readStream')
102  ->once()
103  ->with($path)
104  ->andReturn(false);
105 
106  $this->expectException(IOException::class);
107  $this->expectExceptionMessage("Could not open stream for file \"$path\"");
108 
109  $this->subject->readStream($path);
110  }
$path
Definition: aliased.php:25

◆ testReadStreamWithMissingFileWhichShouldFail()

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

Definition at line 78 of file FlySystemFileStreamAccessTest.php.

References $path.

79  {
80  $path = '/path/to/your/file';
81 
82  $this->filesystemMock->shouldReceive('readStream')
83  ->once()
84  ->with($path)
85  ->andThrow(FileNotFoundException::class);
86 
87  $this->expectException(\ILIAS\Filesystem\Exception\FileNotFoundException::class);
88  $this->expectExceptionMessage("File \"$path\" not found.");
89 
90  $this->subject->readStream($path);
91  }
$path
Definition: aliased.php:25
Class BaseForm.
Class FlySystemFileAccessTest.

◆ testUpdateStreamWhichShouldSucceed()

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

Definition at line 249 of file FlySystemFileStreamAccessTest.php.

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

250  {
251  $path = '/path/to/your/file';
252  $fileContent = 'Awesome file content';
253  $stream = Streams::ofString($fileContent);
254 
255  $this->filesystemMock->shouldReceive('updateStream')
256  ->once()
257  ->withArgs([$path, resourceValue()])
258  ->andReturn(true);
259 
260  $this->subject->updateStream($path, $stream);
261  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testUpdateStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 267 of file FlySystemFileStreamAccessTest.php.

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

268  {
269  $path = '/path/to/your/file';
270  $fileContent = 'Awesome file content';
271  $stream = Streams::ofString($fileContent);
272  $stream->detach();
273 
274  $this->expectException(\InvalidArgumentException::class);
275  $this->expectExceptionMessage('The given stream must not be detached.');
276 
277  $this->subject->updateStream($path, $stream);
278  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testUpdateStreamWithGeneralFailureWhichShouldFail()

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

Definition at line 284 of file FlySystemFileStreamAccessTest.php.

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

285  {
286  $path = '/path/to/your/file';
287  $fileContent = 'Awesome file content';
288  $stream = Streams::ofString($fileContent);
289 
290  $this->filesystemMock->shouldReceive('updateStream')
291  ->once()
292  ->withArgs([$path, resourceValue()])
293  ->andReturn(false);
294 
295  $this->expectException(IOException::class);
296  $this->expectExceptionMessage("Could not update file \"$path\"");
297 
298  $this->subject->updateStream($path, $stream);
299  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testUpdateStreamWithMissingFileWhichShouldFail()

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

Definition at line 305 of file FlySystemFileStreamAccessTest.php.

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

306  {
307  $path = '/path/to/your/file';
308  $fileContent = 'Awesome file content';
309  $stream = Streams::ofString($fileContent);
310 
311  $this->filesystemMock->shouldReceive('updateStream')
312  ->once()
313  ->withArgs([$path, resourceValue()])
314  ->andThrow(FileNotFoundException::class);
315 
316  $this->expectException(\ILIAS\Filesystem\Exception\FileNotFoundException::class);
317  $this->expectExceptionMessage("File \"$path\" not found.");
318 
319  $this->subject->updateStream($path, $stream);
320  }
$path
Definition: aliased.php:25
Class BaseForm.
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
Class FlySystemFileAccessTest.
+ Here is the call graph for this function:

◆ testWriteStreamWhichShouldSucceed()

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

Definition at line 116 of file FlySystemFileStreamAccessTest.php.

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

117  {
118  $path = '/path/to/your/file';
119  $fileContent = 'Awesome file content';
120  $stream = Streams::ofString($fileContent);
121 
122  $this->filesystemMock->shouldReceive('writeStream')
123  ->once()
124  ->withArgs([$path, resourceValue()])
125  ->andReturn(true);
126 
127  $this->subject->writeStream($path, $stream);
128  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testWriteStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 134 of file FlySystemFileStreamAccessTest.php.

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

135  {
136  $path = '/path/to/your/file';
137  $fileContent = 'Awesome file content';
138  $stream = Streams::ofString($fileContent);
139  $stream->detach();
140 
141  $this->expectException(\InvalidArgumentException::class);
142  $this->expectExceptionMessage('The given stream must not be detached.');
143 
144  $this->subject->writeStream($path, $stream);
145  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testWriteStreamWithExistingFileWhichShouldFail()

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

Definition at line 151 of file FlySystemFileStreamAccessTest.php.

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

152  {
153  $path = '/path/to/your/file';
154  $fileContent = 'Awesome file content';
155  $stream = Streams::ofString($fileContent);
156 
157  $this->filesystemMock->shouldReceive('writeStream')
158  ->once()
159  ->withArgs([$path, resourceValue()])
160  ->andThrow(FileExistsException::class);
161 
162  $this->expectException(FileAlreadyExistsException::class);
163  $this->expectExceptionMessage("File \"$path\" already exists.");
164 
165  $this->subject->writeStream($path, $stream);
166  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

◆ testWriteStreamWithFailingAdapterWhichShouldFail()

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

Definition at line 172 of file FlySystemFileStreamAccessTest.php.

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

173  {
174  $path = '/path/to/your/file';
175  $fileContent = 'Awesome file content';
176  $stream = Streams::ofString($fileContent);
177 
178  $this->filesystemMock->shouldReceive('writeStream')
179  ->once()
180  ->withArgs([$path, resourceValue()])
181  ->andReturn(false);
182 
183  $this->expectException(IOException::class);
184  $this->expectExceptionMessage("Could not write stream to file \"$path\"");
185 
186  $this->subject->writeStream($path, $stream);
187  }
$path
Definition: aliased.php:25
$stream
PHP stream implementation.
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:30
+ Here is the call graph for this function:

Field Documentation

◆ $filesystemMock

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

Definition at line 35 of file FlySystemFileStreamAccessTest.php.

◆ $subject

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

Definition at line 39 of file FlySystemFileStreamAccessTest.php.


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