ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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

LegacyMockInterface $filesystemMock
 
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 60 of file FlySystemFileStreamAccessTestTBD.php.

60 : void
61 {
62 parent::setUp();
63
64 $this->filesystemMock = \Mockery::mock(FilesystemOperator::class);
65 $this->subject = new FlySystemFileStreamAccess($this->filesystemMock);
66 }

◆ testPutStreamWhichShouldSucceed()

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

Definition at line 201 of file FlySystemFileStreamAccessTestTBD.php.

201 : void
202 {
203 $path = '/path/to/your/file';
204 $fileContent = 'Awesome file content';
205 $stream = Streams::ofString($fileContent);
206
207 $this->filesystemMock->shouldReceive('putStream')
208 ->once()
209 ->withArgs([$path, \resourceValue()])
210 ->andReturn(true);
211
212 $this->subject->putStream($path, $stream);
213 }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
$path
Definition: ltiservices.php:30

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

+ Here is the call graph for this function:

◆ testPutStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 236 of file FlySystemFileStreamAccessTestTBD.php.

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

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

+ Here is the call graph for this function:

◆ testPutStreamWithGeneralFailureWhichShouldFail()

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

Definition at line 217 of file FlySystemFileStreamAccessTestTBD.php.

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

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

+ Here is the call graph for this function:

◆ testReadStreamWhichShouldSucceed()

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

Definition at line 70 of file FlySystemFileStreamAccessTestTBD.php.

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

References $path.

◆ testReadStreamWithGeneralFailureWhichShouldFail()

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

Definition at line 105 of file FlySystemFileStreamAccessTestTBD.php.

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

References $path.

◆ testReadStreamWithMissingFileWhichShouldFail()

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

Definition at line 88 of file FlySystemFileStreamAccessTestTBD.php.

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(FileNotFoundException::class);
98 $this->expectExceptionMessage("File \"$path\" not found.");
99
100 $this->subject->readStream($path);
101 }

References $path.

◆ testUpdateStreamWhichShouldSucceed()

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

Definition at line 251 of file FlySystemFileStreamAccessTestTBD.php.

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

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

+ Here is the call graph for this function:

◆ testUpdateStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 267 of file FlySystemFileStreamAccessTestTBD.php.

267 : void
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, and ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

◆ testUpdateStreamWithGeneralFailureWhichShouldFail()

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

Definition at line 282 of file FlySystemFileStreamAccessTestTBD.php.

282 : void
283 {
284 $path = '/path/to/your/file';
285 $fileContent = 'Awesome file content';
286 $stream = Streams::ofString($fileContent);
287
288 $this->filesystemMock
289 ->shouldReceive('writeStream')
290 ->once()
291 ->withArgs([$path, \resourceValue()])
292 ->andThrow(UnableToWriteFile::class);
293
294 $this->expectException(IOException::class);
295 $this->expectExceptionMessage("Unable to update Stream in \"$path\".");
296
297 $this->subject->updateStream($path, $stream);
298 }

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

+ Here is the call graph for this function:

◆ testUpdateStreamWithMissingFileWhichShouldFail()

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

Definition at line 302 of file FlySystemFileStreamAccessTestTBD.php.

302 : void
303 {
304 $path = '/path/to/your/file';
305 $fileContent = 'Awesome file content';
306 $stream = Streams::ofString($fileContent);
307
308 $this->filesystemMock
309 ->shouldReceive('writeStream')
310 ->once()
311 ->withArgs([$path, \resourceValue()])
312 ->andThrow(UnableToWriteFile::class);
313
314 $this->expectException(FileNotFoundException::class);
315 $this->expectExceptionMessage("Unable to update Stream in \"$path\".");
316
317 $this->subject->updateStream($path, $stream);
318 }

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

+ Here is the call graph for this function:

◆ testWriteStreamWhichShouldSucceed()

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

Definition at line 122 of file FlySystemFileStreamAccessTestTBD.php.

122 : void
123 {
124 $path = '/path/to/your/file';
125 $fileContent = 'Awesome file content';
126 $stream = Streams::ofString($fileContent);
127
128 $this->filesystemMock
129 ->shouldReceive('fileExists')
130 ->once()
131 ->andReturn(false)
132 ->getMock()
133 ->shouldReceive('writeStream')
134 ->once()
135 ->withArgs([$path, \resourceValue()])
136 ->andReturn(true);
137
138 $this->subject->writeStream($path, $stream);
139 }

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

+ Here is the call graph for this function:

◆ testWriteStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 143 of file FlySystemFileStreamAccessTestTBD.php.

143 : void
144 {
145 $path = '/path/to/your/file';
146 $fileContent = 'Awesome file content';
147 $stream = Streams::ofString($fileContent);
148 $stream->detach();
149
150 $this->expectException(\InvalidArgumentException::class);
151 $this->expectExceptionMessage('The given stream must not be detached.');
152
153 $this->subject->writeStream($path, $stream);
154 }

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

+ Here is the call graph for this function:

◆ testWriteStreamWithExistingFileWhichShouldFail()

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

Definition at line 158 of file FlySystemFileStreamAccessTestTBD.php.

158 : void
159 {
160 $path = '/path/to/your/file';
161 $fileContent = 'Awesome file content';
162 $stream = Streams::ofString($fileContent);
163
164 $this->filesystemMock
165 ->shouldReceive('fileExists')
166 ->once()
167 ->andReturn(true);
168
169 $this->expectException(FileAlreadyExistsException::class);
170 $this->expectExceptionMessage("File \"$path\" already exists.");
171
172 $this->subject->writeStream($path, $stream);
173 }

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

+ Here is the call graph for this function:

◆ testWriteStreamWithFailingAdapterWhichShouldFail()

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

Definition at line 177 of file FlySystemFileStreamAccessTestTBD.php.

177 : void
178 {
179 $path = '/path/to/your/file';
180 $fileContent = 'Awesome file content';
181 $stream = Streams::ofString($fileContent);
182
183 $this->filesystemMock
184 ->shouldReceive('fileExists')
185 ->once()
186 ->andReturn(false)
187 ->getMock()
188 ->shouldReceive('writeStream')
189 ->once()
190 ->withArgs([$path, \resourceValue()])
191 ->andThrow(UnableToWriteFile::class);
192
193 $this->expectException(IOException::class);
194 $this->expectExceptionMessage("Could not write stream to file \"$path\"");
195
196 $this->subject->writeStream($path, $stream);
197 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $filesystemMock

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

Definition at line 52 of file FlySystemFileStreamAccessTestTBD.php.

◆ $subject

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

Definition at line 53 of file FlySystemFileStreamAccessTestTBD.php.


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