ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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
 
ILIAS Filesystem Provider FlySystem FlySystemFileStreamAccess $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 41 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 56 of file FlySystemFileStreamAccessTest.php.

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

◆ testPutStreamWhichShouldSucceed()

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

Definition at line 203 of file FlySystemFileStreamAccessTest.php.

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

203  : void
204  {
205  $path = '/path/to/your/file';
206  $fileContent = 'Awesome file content';
207  $stream = Streams::ofString($fileContent);
208 
209  $this->filesystemMock->shouldReceive('putStream')
210  ->once()
211  ->withArgs([$path, \resourceValue()])
212  ->andReturn(true);
213 
214  $this->subject->putStream($path, $stream);
215  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

◆ testPutStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 242 of file FlySystemFileStreamAccessTest.php.

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

242  : void
243  {
244  $path = '/path/to/your/file';
245  $fileContent = 'Awesome file content';
246  $stream = Streams::ofString($fileContent);
247  $stream->detach();
248 
249  $this->expectException(\InvalidArgumentException::class);
250  $this->expectExceptionMessage('The given stream must not be detached.');
251 
252  $this->subject->putStream($path, $stream);
253  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

◆ testPutStreamWithGeneralFailureWhichShouldFail()

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

Definition at line 221 of file FlySystemFileStreamAccessTest.php.

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

221  : void
222  {
223  $path = '/path/to/your/file';
224  $fileContent = 'Awesome file content';
225  $stream = Streams::ofString($fileContent);
226 
227  $this->filesystemMock->shouldReceive('putStream')
228  ->once()
229  ->withArgs([$path, \resourceValue()])
230  ->andReturn(false);
231 
232  $this->expectException(IOException::class);
233  $this->expectExceptionMessage("Could not put stream content into \"$path\"");
234 
235  $this->subject->putStream($path, $stream);
236  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ 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:32

◆ 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:32

◆ 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(FileNotFoundException::class);
96 
97  $this->expectException(\ILIAS\Filesystem\Exception\FileNotFoundException::class);
98  $this->expectExceptionMessage("File \"$path\" not found.");
99 
100  $this->subject->readStream($path);
101  }
Class ChatMainBarProvider .
$path
Definition: ltiservices.php:32
Class FlySystemFileAccessTest disabled disabled disabled.

◆ testUpdateStreamWhichShouldSucceed()

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

Definition at line 259 of file FlySystemFileStreamAccessTest.php.

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

259  : void
260  {
261  $path = '/path/to/your/file';
262  $fileContent = 'Awesome file content';
263  $stream = Streams::ofString($fileContent);
264 
265  $this->filesystemMock->shouldReceive('updateStream')
266  ->once()
267  ->withArgs([$path, \resourceValue()])
268  ->andReturn(true);
269 
270  $this->subject->updateStream($path, $stream);
271  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

◆ testUpdateStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 277 of file FlySystemFileStreamAccessTest.php.

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

277  : void
278  {
279  $path = '/path/to/your/file';
280  $fileContent = 'Awesome file content';
281  $stream = Streams::ofString($fileContent);
282  $stream->detach();
283 
284  $this->expectException(\InvalidArgumentException::class);
285  $this->expectExceptionMessage('The given stream must not be detached.');
286 
287  $this->subject->updateStream($path, $stream);
288  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

◆ testUpdateStreamWithGeneralFailureWhichShouldFail()

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

Definition at line 294 of file FlySystemFileStreamAccessTest.php.

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

294  : void
295  {
296  $path = '/path/to/your/file';
297  $fileContent = 'Awesome file content';
298  $stream = Streams::ofString($fileContent);
299 
300  $this->filesystemMock->shouldReceive('updateStream')
301  ->once()
302  ->withArgs([$path, \resourceValue()])
303  ->andReturn(false);
304 
305  $this->expectException(IOException::class);
306  $this->expectExceptionMessage("Could not update file \"$path\"");
307 
308  $this->subject->updateStream($path, $stream);
309  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

◆ testUpdateStreamWithMissingFileWhichShouldFail()

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

Definition at line 315 of file FlySystemFileStreamAccessTest.php.

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

315  : void
316  {
317  $path = '/path/to/your/file';
318  $fileContent = 'Awesome file content';
319  $stream = Streams::ofString($fileContent);
320 
321  $this->filesystemMock->shouldReceive('updateStream')
322  ->once()
323  ->withArgs([$path, \resourceValue()])
324  ->andThrow(FileNotFoundException::class);
325 
326  $this->expectException(\ILIAS\Filesystem\Exception\FileNotFoundException::class);
327  $this->expectExceptionMessage("File \"$path\" not found.");
328 
329  $this->subject->updateStream($path, $stream);
330  }
Class ChatMainBarProvider .
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
Class FlySystemFileAccessTest disabled disabled disabled.
+ 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->shouldReceive('writeStream')
133  ->once()
134  ->withArgs([$path, \resourceValue()])
135  ->andReturn(true);
136 
137  $this->subject->writeStream($path, $stream);
138  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

◆ testWriteStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 144 of file FlySystemFileStreamAccessTest.php.

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

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

◆ testWriteStreamWithExistingFileWhichShouldFail()

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

Definition at line 161 of file FlySystemFileStreamAccessTest.php.

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

161  : void
162  {
163  $path = '/path/to/your/file';
164  $fileContent = 'Awesome file content';
165  $stream = Streams::ofString($fileContent);
166 
167  $this->filesystemMock->shouldReceive('writeStream')
168  ->once()
169  ->withArgs([$path, \resourceValue()])
170  ->andThrow(FileExistsException::class);
171 
172  $this->expectException(FileAlreadyExistsException::class);
173  $this->expectExceptionMessage("File \"$path\" already exists.");
174 
175  $this->subject->writeStream($path, $stream);
176  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

◆ testWriteStreamWithFailingAdapterWhichShouldFail()

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

Definition at line 182 of file FlySystemFileStreamAccessTest.php.

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

182  : void
183  {
184  $path = '/path/to/your/file';
185  $fileContent = 'Awesome file content';
186  $stream = Streams::ofString($fileContent);
187 
188  $this->filesystemMock->shouldReceive('writeStream')
189  ->once()
190  ->withArgs([$path, \resourceValue()])
191  ->andReturn(false);
192 
193  $this->expectException(IOException::class);
194  $this->expectExceptionMessage("Could not write stream to file \"$path\"");
195 
196  $this->subject->writeStream($path, $stream);
197  }
$path
Definition: ltiservices.php:32
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:43
+ Here is the call graph for this function:

Field Documentation

◆ $filesystemMock

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: