File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -188,7 +188,9 @@ private function createDirectoryRecursively(string $path): bool
188
188
$ parentDir = dirname ($ path );
189
189
190
190
while (!$ this ->isDirectory ($ parentDir )) {
191
- $ this ->createDirectoryRecursively ($ parentDir );
191
+ if (!$ this ->createDirectoryRecursively ($ parentDir )) {
192
+ return false ;
193
+ }
192
194
}
193
195
194
196
if (!$ this ->isDirectory ($ path )) {
Original file line number Diff line number Diff line change @@ -497,6 +497,23 @@ public function testCreateDirectory(): void
497
497
self ::assertTrue ($ this ->driver ->createDirectory (self ::URL . 'test/test2/ ' ));
498
498
}
499
499
500
+ /**
501
+ * This test ensures that the method does not loop infinitely in case of an exception
502
+ *
503
+ * @return void
504
+ * @throws FileSystemException
505
+ * @throws \PHPUnit\Framework\MockObject\Exception
506
+ */
507
+ public function testShouldFailSafelyIfUnableToCreateDirectory (): void
508
+ {
509
+ $ this ->adapterMock ->expects (self ::once ())
510
+ ->method ('createDirectory ' )
511
+ ->willThrowException ($ this ->createMock (\League \Flysystem \FilesystemException::class))
512
+ ->with ('test ' );
513
+
514
+ self ::assertFalse ($ this ->driver ->createDirectory (self ::URL . 'test/test2/ ' ));
515
+ }
516
+
500
517
public function testRename (): void
501
518
{
502
519
$ this ->adapterMock ->expects (self ::once ())
You can’t perform that action at this time.
0 commit comments