ILIAS  release_7 Revision v7.30-3-g800a261c036
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 29 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 47 of file FlySystemFileStreamAccessTest.php.

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

◆ testPutStreamWhichShouldSucceed()

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

@Test @small

Definition at line 194 of file FlySystemFileStreamAccessTest.php.

195 {
196 $path = '/path/to/your/file';
197 $fileContent = 'Awesome file content';
198 $stream = Streams::ofString($fileContent);
199
200 $this->filesystemMock->shouldReceive('putStream')
201 ->once()
202 ->withArgs([$path, \resourceValue()])
203 ->andReturn(true);
204
205 $this->subject->putStream($path, $stream);
206 }
static ofString($string)
Creates a new stream with an initial value.
Definition: Streams.php:25

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testPutStreamWithDetachedStreamWhichShouldFail()

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

@Test @small

Definition at line 233 of file FlySystemFileStreamAccessTest.php.

234 {
235 $path = '/path/to/your/file';
236 $fileContent = 'Awesome file content';
237 $stream = Streams::ofString($fileContent);
238 $stream->detach();
239
240 $this->expectException(\InvalidArgumentException::class);
241 $this->expectExceptionMessage('The given stream must not be detached.');
242
243 $this->subject->putStream($path, $stream);
244 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testPutStreamWithGeneralFailureWhichShouldFail()

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

@Test @small

Definition at line 212 of file FlySystemFileStreamAccessTest.php.

213 {
214 $path = '/path/to/your/file';
215 $fileContent = 'Awesome file content';
216 $stream = Streams::ofString($fileContent);
217
218 $this->filesystemMock->shouldReceive('putStream')
219 ->once()
220 ->withArgs([$path, \resourceValue()])
221 ->andReturn(false);
222
223 $this->expectException(IOException::class);
224 $this->expectExceptionMessage("Could not put stream content into \"$path\"");
225
226 $this->subject->putStream($path, $stream);
227 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testReadStreamWhichShouldSucceed()

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

@Test @small

Definition at line 59 of file FlySystemFileStreamAccessTest.php.

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

◆ testReadStreamWithGeneralFailureWhichShouldFail()

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

@Test @small

Definition at line 98 of file FlySystemFileStreamAccessTest.php.

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

◆ testReadStreamWithMissingFileWhichShouldFail()

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

@Test @small

Definition at line 79 of file FlySystemFileStreamAccessTest.php.

80 {
81 $path = '/path/to/your/file';
82
83 $this->filesystemMock->shouldReceive('readStream')
84 ->once()
85 ->with($path)
86 ->andThrow(FileNotFoundException::class);
87
88 $this->expectException(\ILIAS\Filesystem\Exception\FileNotFoundException::class);
89 $this->expectExceptionMessage("File \"$path\" not found.");
90
91 $this->subject->readStream($path);
92 }
Class FlySystemFileAccessTest \Provider\FlySystem @runTestsInSeparateProcesses @preserveGlobalState d...
Class ChatMainBarProvider \MainMenu\Provider.

◆ testUpdateStreamWhichShouldSucceed()

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

@Test @small

Definition at line 250 of file FlySystemFileStreamAccessTest.php.

251 {
252 $path = '/path/to/your/file';
253 $fileContent = 'Awesome file content';
254 $stream = Streams::ofString($fileContent);
255
256 $this->filesystemMock->shouldReceive('updateStream')
257 ->once()
258 ->withArgs([$path, \resourceValue()])
259 ->andReturn(true);
260
261 $this->subject->updateStream($path, $stream);
262 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testUpdateStreamWithDetachedStreamWhichShouldFail()

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

@Test @small

Definition at line 268 of file FlySystemFileStreamAccessTest.php.

269 {
270 $path = '/path/to/your/file';
271 $fileContent = 'Awesome file content';
272 $stream = Streams::ofString($fileContent);
273 $stream->detach();
274
275 $this->expectException(\InvalidArgumentException::class);
276 $this->expectExceptionMessage('The given stream must not be detached.');
277
278 $this->subject->updateStream($path, $stream);
279 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testUpdateStreamWithGeneralFailureWhichShouldFail()

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

@Test @small

Definition at line 285 of file FlySystemFileStreamAccessTest.php.

286 {
287 $path = '/path/to/your/file';
288 $fileContent = 'Awesome file content';
289 $stream = Streams::ofString($fileContent);
290
291 $this->filesystemMock->shouldReceive('updateStream')
292 ->once()
293 ->withArgs([$path, \resourceValue()])
294 ->andReturn(false);
295
296 $this->expectException(IOException::class);
297 $this->expectExceptionMessage("Could not update file \"$path\"");
298
299 $this->subject->updateStream($path, $stream);
300 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testUpdateStreamWithMissingFileWhichShouldFail()

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

@Test @small

Definition at line 306 of file FlySystemFileStreamAccessTest.php.

307 {
308 $path = '/path/to/your/file';
309 $fileContent = 'Awesome file content';
310 $stream = Streams::ofString($fileContent);
311
312 $this->filesystemMock->shouldReceive('updateStream')
313 ->once()
314 ->withArgs([$path, \resourceValue()])
315 ->andThrow(FileNotFoundException::class);
316
317 $this->expectException(\ILIAS\Filesystem\Exception\FileNotFoundException::class);
318 $this->expectExceptionMessage("File \"$path\" not found.");
319
320 $this->subject->updateStream($path, $stream);
321 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testWriteStreamWhichShouldSucceed()

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

@Test @small

Definition at line 117 of file FlySystemFileStreamAccessTest.php.

118 {
119 $path = '/path/to/your/file';
120 $fileContent = 'Awesome file content';
121 $stream = Streams::ofString($fileContent);
122
123 $this->filesystemMock->shouldReceive('writeStream')
124 ->once()
125 ->withArgs([$path, \resourceValue()])
126 ->andReturn(true);
127
128 $this->subject->writeStream($path, $stream);
129 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testWriteStreamWithDetachedStreamWhichShouldFail()

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

@Test @small

Definition at line 135 of file FlySystemFileStreamAccessTest.php.

136 {
137 $path = '/path/to/your/file';
138 $fileContent = 'Awesome file content';
139 $stream = Streams::ofString($fileContent);
140 $stream->detach();
141
142 $this->expectException(\InvalidArgumentException::class);
143 $this->expectExceptionMessage('The given stream must not be detached.');
144
145 $this->subject->writeStream($path, $stream);
146 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testWriteStreamWithExistingFileWhichShouldFail()

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

@Test @small

Definition at line 152 of file FlySystemFileStreamAccessTest.php.

153 {
154 $path = '/path/to/your/file';
155 $fileContent = 'Awesome file content';
156 $stream = Streams::ofString($fileContent);
157
158 $this->filesystemMock->shouldReceive('writeStream')
159 ->once()
160 ->withArgs([$path, \resourceValue()])
161 ->andThrow(FileExistsException::class);
162
163 $this->expectException(FileAlreadyExistsException::class);
164 $this->expectExceptionMessage("File \"$path\" already exists.");
165
166 $this->subject->writeStream($path, $stream);
167 }

References ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testWriteStreamWithFailingAdapterWhichShouldFail()

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

@Test @small

Definition at line 173 of file FlySystemFileStreamAccessTest.php.

174 {
175 $path = '/path/to/your/file';
176 $fileContent = 'Awesome file content';
177 $stream = Streams::ofString($fileContent);
178
179 $this->filesystemMock->shouldReceive('writeStream')
180 ->once()
181 ->withArgs([$path, \resourceValue()])
182 ->andReturn(false);
183
184 $this->expectException(IOException::class);
185 $this->expectExceptionMessage("Could not write stream to file \"$path\"");
186
187 $this->subject->writeStream($path, $stream);
188 }

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

◆ $subject

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

Definition at line 40 of file FlySystemFileStreamAccessTest.php.


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