Skip to content

Commit 07f0c70

Browse files
committed
Static tests and additional test cases
1 parent 1b8a371 commit 07f0c70

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFiles.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,15 @@ public function __construct(
6060
*/
6161
public function execute()
6262
{
63+
$resultJson = $this->resultJsonFactory->create();
64+
65+
if (!$this->getRequest()->isPost()) {
66+
$result = ['error' => true, 'message' => __('Wrong request.')];
67+
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
68+
return $resultJson->setData($result);
69+
}
70+
6371
try {
64-
if (!$this->getRequest()->isPost()) {
65-
//phpcs:ignore Magento2.Exceptions.DirectThrow
66-
throw new \Exception('Wrong request.');
67-
}
6872
$files = $this->getRequest()->getParam('files');
6973

7074
/** @var $helper \Magento\Cms\Helper\Wysiwyg\Images */
@@ -90,8 +94,6 @@ public function execute()
9094
// phpcs:ignore Magento2.Exceptions.ThrowCatch
9195
} catch (\Exception $e) {
9296
$result = ['error' => true, 'message' => $e->getMessage()];
93-
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
94-
$resultJson = $this->resultJsonFactory->create();
9597

9698
return $resultJson->setData($result);
9799
}

dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images/DeleteFilesTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ public function testExecute(string $filename)
105105
public function executeDataProvider(): array
106106
{
107107
return [
108+
['name with spaces.jpg'],
109+
['name with, comma.jpg'],
110+
['name with* asterisk.jpg'],
111+
['name with[ bracket.jpg'],
108112
['magento_small_image.jpg'],
109113
['_.jpg'],
110114
[' - .jpg'],

0 commit comments

Comments
 (0)