ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
 
 $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 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 ( )

Definition at line 194 of file FlySystemFileStreamAccessTest.php.

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

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:30
+ Here is the call graph for this function:

◆ testPutStreamWithDetachedStreamWhichShouldFail()

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

Definition at line 233 of file FlySystemFileStreamAccessTest.php.

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

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

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

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  }
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 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 ( )

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 ( )

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 ChatMainBarProvider .
Class FlySystemFileAccessTest.

◆ testUpdateStreamWhichShouldSucceed()

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

Definition at line 250 of file FlySystemFileStreamAccessTest.php.

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

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

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

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

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

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

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

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  }
Class ChatMainBarProvider .
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 117 of file FlySystemFileStreamAccessTest.php.

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

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

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

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

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

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

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

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