File tree Expand file tree Collapse file tree 2 files changed +42
-4
lines changed
Controller/Adminhtml/Wysiwyg
Test/Unit/Controller/Adminhtml/Wysiwyg Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Original file line number Diff line number Diff line change 4
4
* Copyright © Magento, Inc. All rights reserved.
5
5
* See COPYING.txt for license details.
6
6
*/
7
+
8
+ declare (strict_types=1 );
9
+
7
10
namespace Magento \Cms \Controller \Adminhtml \Wysiwyg ;
8
11
9
12
use Magento \Backend \App \Action ;
13
16
14
17
/**
15
18
* Process template text for wysiwyg editor.
19
+ *
20
+ * Class Directive
16
21
*/
17
22
class Directive extends Action implements HttpGetActionInterface
18
23
{
@@ -73,10 +78,14 @@ public function execute()
73
78
/** @var Config $config */
74
79
$ config = $ this ->_objectManager ->get (Config::class);
75
80
$ imagePath = $ config ->getSkinImagePlaceholderPath ();
76
- $ image ->open ($ imagePath );
77
- $ resultRaw ->setHeader ('Content-Type ' , $ image ->getMimeType ());
78
- $ resultRaw ->setContents ($ image ->getImage ());
79
- $ this ->_objectManager ->get (\Psr \Log \LoggerInterface::class)->critical ($ e );
81
+ try {
82
+ $ image ->open ($ imagePath );
83
+ $ resultRaw ->setHeader ('Content-Type ' , $ image ->getMimeType ());
84
+ $ resultRaw ->setContents ($ image ->getImage ());
85
+ $ this ->_objectManager ->get (\Psr \Log \LoggerInterface::class)->critical ($ e );
86
+ } catch (\Exception $ e ) {
87
+ $ this ->_objectManager ->get (\Psr \Log \LoggerInterface::class)->critical ($ e );
88
+ }
80
89
}
81
90
return $ resultRaw ;
82
91
}
Original file line number Diff line number Diff line change @@ -274,4 +274,33 @@ protected function prepareExecuteTest()
274
274
->method ('create ' )
275
275
->willReturn ($ this ->imageAdapterMock );
276
276
}
277
+
278
+ /**
279
+ * Test Execute With Deleted Image
280
+ *
281
+ * @covers \Magento\Cms\Controller\Adminhtml\Wysiwyg\Directive::execute
282
+ */
283
+ public function testExecuteWithDeletedImage ()
284
+ {
285
+ $ exception = new \Exception ('epic fail ' );
286
+ $ placeholderPath = 'pub/static/adminhtml/Magento/backend/en_US/Magento_Cms/images/wysiwyg_skin_image.png ' ;
287
+ $ this ->prepareExecuteTest ();
288
+
289
+ $ this ->imageAdapterMock ->expects ($ this ->at (0 ))
290
+ ->method ('open ' )
291
+ ->with (self ::IMAGE_PATH )
292
+ ->willThrowException ($ exception );
293
+ $ this ->wysiwygConfigMock ->expects ($ this ->once ())
294
+ ->method ('getSkinImagePlaceholderPath ' )
295
+ ->willReturn ($ placeholderPath );
296
+ $ this ->imageAdapterMock ->expects ($ this ->at (1 ))
297
+ ->method ('open ' )
298
+ ->willThrowException ($ exception );
299
+
300
+ $ this ->loggerMock ->expects ($ this ->once ())
301
+ ->method ('critical ' )
302
+ ->with ($ exception );
303
+
304
+ $ this ->wysiwygDirective ->execute ();
305
+ }
277
306
}
You can’t perform that action at this time.
0 commit comments