File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
app/code/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images
dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/Wysiwyg/Images Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public function execute()
79
79
/** @var \Magento\Framework\Filesystem $filesystem */
80
80
$ filesystem = $ this ->_objectManager ->get (\Magento \Framework \Filesystem::class);
81
81
$ dir = $ filesystem ->getDirectoryRead (DirectoryList::MEDIA );
82
- $ filePath = $ path . '/ ' . \ Magento \ Framework \ File \Uploader:: getCorrectFileName ( $ file) ;
82
+ $ filePath = $ path . '/ ' . $ file ;
83
83
if ($ dir ->isFile ($ dir ->getRelativePath ($ filePath )) && !preg_match ('#.htaccess# ' , $ file )) {
84
84
$ this ->getStorage ()->deleteFile ($ filePath );
85
85
}
Original file line number Diff line number Diff line change @@ -75,22 +75,43 @@ protected function setUp()
75
75
* Execute method with correct directory path and file name to check that files under WYSIWYG media directory
76
76
* can be removed.
77
77
*
78
+ * @param string $filename
78
79
* @return void
80
+ * @dataProvider executeDataProvider
79
81
*/
80
- public function testExecute ()
82
+ public function testExecute (string $ filename )
81
83
{
84
+ $ filePath = $ this ->fullDirectoryPath . DIRECTORY_SEPARATOR . $ filename ;
85
+ $ fixtureDir = realpath (__DIR__ . '/../../../../../Catalog/_files ' );
86
+ copy ($ fixtureDir . '/ ' . $ this ->fileName , $ filePath );
87
+
82
88
$ this ->model ->getRequest ()->setMethod ('POST ' )
83
- ->setPostValue ('files ' , [$ this ->imagesHelper ->idEncode ($ this -> fileName )]);
89
+ ->setPostValue ('files ' , [$ this ->imagesHelper ->idEncode ($ filename )]);
84
90
$ this ->model ->getStorage ()->getSession ()->setCurrentPath ($ this ->fullDirectoryPath );
85
91
$ this ->model ->execute ();
86
92
87
93
$ this ->assertFalse (
88
94
$ this ->mediaDirectory ->isExist (
89
- $ this ->mediaDirectory ->getRelativePath ($ this ->fullDirectoryPath . '/ ' . $ this -> fileName )
95
+ $ this ->mediaDirectory ->getRelativePath ($ this ->fullDirectoryPath . '/ ' . $ filename )
90
96
)
91
97
);
92
98
}
93
99
100
+ /**
101
+ * DataProvider for testExecute
102
+ *
103
+ * @return array
104
+ */
105
+ public function executeDataProvider (): array
106
+ {
107
+ return [
108
+ ['magento_small_image.jpg ' ],
109
+ ['_.jpg ' ],
110
+ [' - .jpg ' ],
111
+ ['-.jpg ' ],
112
+ ];
113
+ }
114
+
94
115
/**
95
116
* Check that htaccess file couldn't be removed via
96
117
* \Magento\Cms\Controller\Adminhtml\Wysiwyg\Images\DeleteFiles::execute method
You can’t perform that action at this time.
0 commit comments