File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-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 18
18
19
19
/**
20
20
* @see AwsS3
21
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21
22
*/
22
23
class AwsS3Test extends TestCase
23
24
{
@@ -497,6 +498,23 @@ public function testCreateDirectory(): void
497
498
self ::assertTrue ($ this ->driver ->createDirectory (self ::URL . 'test/test2/ ' ));
498
499
}
499
500
501
+ /**
502
+ * This test ensures that the method does not loop infinitely in case of an exception
503
+ *
504
+ * @return void
505
+ * @throws FileSystemException
506
+ * @throws \PHPUnit\Framework\MockObject\Exception
507
+ */
508
+ public function testShouldFailSafelyIfUnableToCreateDirectory (): void
509
+ {
510
+ $ this ->adapterMock ->expects (self ::once ())
511
+ ->method ('createDirectory ' )
512
+ ->willThrowException ($ this ->createMock (\League \Flysystem \FilesystemException::class))
513
+ ->with ('test ' );
514
+
515
+ self ::assertFalse ($ this ->driver ->createDirectory (self ::URL . 'test/test2/ ' ));
516
+ }
517
+
500
518
public function testRename (): void
501
519
{
502
520
$ this ->adapterMock ->expects (self ::once ())
You can’t perform that action at this time.
0 commit comments