Skip to content

Commit 6045497

Browse files
committed
Fix unit tests
1 parent 3fc31f4 commit 6045497

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/internal/Magento/Framework/File/Mime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function getMimeType($file)
115115

116116
$mimeType = '';
117117
if ($driver instanceof Filesystem\DriverInterface) {
118-
$mimeType = $driver->getMetadata($file)['mimetype'];
118+
$mimeType = $driver->getMetadata($file)['mimetype'] ?? '';
119119
}
120120

121121
if (!$mimeType) {

lib/internal/Magento/Framework/File/Test/Unit/MimeTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public function testGetMimeTypeNonexistentFileException(): void
8383
->method('isExists')
8484
->with('nonexistent.file')
8585
->willReturn(true);
86-
86+
$this->localDriverMock->method('getMetadata')
87+
->willThrowException(new FileSystemException(__('File \'nonexistent.file\' doesn\'t exist')));
8788
$file = 'nonexistent.file';
8889
$this->object->getMimeType($file);
8990
}
@@ -103,7 +104,8 @@ public function testGetMimeType($file, $expectedType): void
103104
->method('isExists')
104105
->with($file)
105106
->willReturn(true);
106-
107+
$this->localDriverMock->method('getMetadata')
108+
->willReturn(['mimetype' => $expectedType]);
107109
$actualType = $this->object->getMimeType($file);
108110
self::assertSame($expectedType, $actualType);
109111
}

0 commit comments

Comments
 (0)