ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ()
 @Test @small More...
 
 testReadStreamWithMissingFileWhichShouldFail ()
 @Test @small More...
 
 testReadStreamWithGeneralFailureWhichShouldFail ()
 @Test @small More...
 
 testWriteStreamWhichShouldSucceed ()
 @Test @small More...
 
 testWriteStreamWithDetachedStreamWhichShouldFail ()
 @Test @small More...
 
 testWriteStreamWithExistingFileWhichShouldFail ()
 @Test @small More...
 
 testWriteStreamWithFailingAdapterWhichShouldFail ()
 @Test @small More...
 
 testPutStreamWhichShouldSucceed ()
 @Test @small More...
 
 testPutStreamWithGeneralFailureWhichShouldFail ()
 @Test @small More...
 
 testPutStreamWithDetachedStreamWhichShouldFail ()
 @Test @small More...
 
 testUpdateStreamWhichShouldSucceed ()
 @Test @small More...
 
 testUpdateStreamWithDetachedStreamWhichShouldFail ()
 @Test @small More...
 
 testUpdateStreamWithGeneralFailureWhichShouldFail ()
 @Test @small More...
 
 testUpdateStreamWithMissingFileWhichShouldFail ()
 @Test @small More...
 

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

@runTestsInSeparateProcesses @preserveGlobalState disabled @backupGlobals disabled @backupStaticAttributes 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 ( )

@Test @small

Definition at line 193 of file FlySystemFileStreamAccessTest.php.

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 }
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:29
$stream
PHP stream implementation.

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

+ Here is the call graph for this function:

◆ testPutStreamWithDetachedStreamWhichShouldFail()

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

@Test @small

Definition at line 232 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testPutStreamWithGeneralFailureWhichShouldFail()

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

@Test @small

Definition at line 211 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testReadStreamWhichShouldSucceed()

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

@Test @small

Definition at line 58 of file FlySystemFileStreamAccessTest.php.

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 }

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

◆ testReadStreamWithGeneralFailureWhichShouldFail()

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

@Test @small

Definition at line 97 of file FlySystemFileStreamAccessTest.php.

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 }

References $path.

◆ testReadStreamWithMissingFileWhichShouldFail()

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

@Test @small

Definition at line 78 of file FlySystemFileStreamAccessTest.php.

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 }
Class FlySystemFileAccessTest.
Class BaseForm.

References $path.

◆ testUpdateStreamWhichShouldSucceed()

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

@Test @small

Definition at line 249 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testUpdateStreamWithDetachedStreamWhichShouldFail()

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

@Test @small

Definition at line 267 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testUpdateStreamWithGeneralFailureWhichShouldFail()

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

@Test @small

Definition at line 284 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testUpdateStreamWithMissingFileWhichShouldFail()

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

@Test @small

Definition at line 305 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testWriteStreamWhichShouldSucceed()

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

@Test @small

Definition at line 116 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testWriteStreamWithDetachedStreamWhichShouldFail()

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

@Test @small

Definition at line 134 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testWriteStreamWithExistingFileWhichShouldFail()

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

@Test @small

Definition at line 151 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ Here is the call graph for this function:

◆ testWriteStreamWithFailingAdapterWhichShouldFail()

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

@Test @small

Definition at line 172 of file FlySystemFileStreamAccessTest.php.

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 }

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

+ 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: