33 $this->view = $this->createMock(\
Magento\Framework\
App\ViewInterface::class);
34 $this->objectManager = $this->createMock(\
Magento\Framework\ObjectManagerInterface::class);
35 $this->session = $this->createMock(\
Magento\Backend\Model\Session::class);
37 $this->storage = $this->createMock(\
Magento\Theme\Helper\Storage::class);
39 $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
40 $this->controller =
$helper->getObject(
41 \
Magento\Theme\Controller\Adminhtml\System\Design\Wysiwyg\Files\Contents::class,
43 'objectManager' => $this->objectManager,
44 'view' => $this->view,
45 'session' => $this->session,
46 'response' => $this->response,
47 'storage' => $this->storage
54 $layout = $this->getMockForAbstractClass(\
Magento\Framework\View\LayoutInterface::class, [],
'',
false);
55 $storage = $this->createMock(\
Magento\Theme\Model\Wysiwyg\Storage::class);
56 $block = $this->getMockForAbstractClass(
57 \
Magento\Framework\View\Element\BlockInterface::class,
66 $this->view->expects($this->once())
67 ->method(
'loadLayout')
69 $this->view->expects($this->once())
71 ->willReturn($layout);
72 $layout->expects($this->once())
74 ->with(
'wysiwyg_files.files')
76 $block->expects($this->once())
77 ->method(
'setStorage')
79 $this->objectManager->expects($this->at(0))
81 ->with(\
Magento\Theme\Model\Wysiwyg\Storage::class)
83 $this->storage->expects($this->once())
84 ->method(
'getCurrentPath')
85 ->willThrowException(
new \Exception(
'Message'));
87 $jsonData = $this->createMock(\
Magento\Framework\Json\Helper\Data::class);
88 $jsonData->expects($this->once())
89 ->method(
'jsonEncode')
90 ->with([
'error' =>
true,
'message' =>
'Message'])
91 ->willReturn(
'{"error":"true","message":"Message"}');
93 $this->objectManager->expects($this->at(1))
95 ->with(\
Magento\Framework\Json\Helper\Data::class)
96 ->willReturn($jsonData);
98 $this->response->expects($this->once())
99 ->method(
'representJson');
101 $this->controller->execute();