Skip to content

Commit dce54ce

Browse files
committed
Removed unnecessary check from the plugin
1 parent 57a6a4b commit dce54ce

File tree

2 files changed

+0
-21
lines changed

2 files changed

+0
-21
lines changed

app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ public function afterDeleteFile(StorageSubject $subject, StorageSubject $result,
111111
*
112112
* @return null
113113
*
114-
* @throws CouldNotDeleteException
115114
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
116115
*/
117116
public function afterDeleteDirectory(StorageSubject $subject, $result, $path)
@@ -123,9 +122,6 @@ public function afterDeleteDirectory(StorageSubject $subject, $result, $path)
123122
try {
124123
$mediaDirectoryRead = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
125124
$relativePath = $mediaDirectoryRead->getRelativePath($path);
126-
if ($mediaDirectoryRead->isExist($relativePath) === false) {
127-
throw new CouldNotDeleteException(__('Cannot remove assets, the provided path does not exist'));
128-
}
129125
$this->deleteMediaAssetByDirectoryPath->execute($relativePath);
130126
} catch (ValidatorException $exception) {
131127
$this->logger->critical($exception);

app/code/Magento/MediaGallery/Test/Unit/Plugin/Images/StorageTest.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,18 +105,6 @@ public function testAfterDeleteDirectory(string $path): void
105105
$result = $this->storagePlugin->afterDeleteDirectory($storageSubject, null, (int)$path);
106106
self::assertNull($result);
107107
break;
108-
case self::NON_EXISTENT_PATH:
109-
$directoryRead->expects($this->once())
110-
->method('getRelativePath')
111-
->with($path)
112-
->willReturn($path);
113-
$directoryRead->expects($this->once())
114-
->method('isExist')
115-
->with($path)
116-
->willReturn(false);
117-
self::expectException('Magento\Framework\Exception\CouldNotDeleteException');
118-
$this->storagePlugin->afterDeleteDirectory($storageSubject, null, $path);
119-
break;
120108
case self::INVALID_PATH:
121109
$exception = new ValidatorException(__('Path cannot be used with directory'));
122110
$directoryRead->expects($this->once())
@@ -133,10 +121,6 @@ public function testAfterDeleteDirectory(string $path): void
133121
->method('getRelativePath')
134122
->with($path)
135123
->willReturn($path);
136-
$directoryRead->expects($this->once())
137-
->method('isExist')
138-
->with($path)
139-
->willReturn(true);
140124
$this->deleteMediaAssetByDirectoryPath->expects($this->once())
141125
->method('execute')
142126
->with($path);
@@ -154,7 +138,6 @@ public function pathPathDataProvider(): array
154138
{
155139
return [
156140
'Non string path' => [2020],
157-
'Non-existent path' => [self::NON_EXISTENT_PATH],
158141
'Invalid path' => [self::INVALID_PATH],
159142
'Existent path' => [self::VALID_PATH]
160143
];

0 commit comments

Comments
 (0)