/** * @covers \Magento\Cms\Controller\Adminhtml\Wysiwyg\Directive::execute */ public function testExecuteException() { $exception = new \Exception('epic fail'); $placeholderPath = 'pub/static/adminhtml/Magento/backend/en_US/Magento_Cms/images/wysiwyg_skin_image.png'; $mimeType = 'image/png'; $imageBody = '0123456789abcdefghijklmnopqrstuvwxyz'; $this->prepareExecuteTest(); $this->imageAdapterMock->expects($this->at(0))->method('open')->with(self::IMAGE_PATH)->willThrowException($exception); $this->wysiwygConfigMock->expects($this->once())->method('getSkinImagePlaceholderPath')->willReturn($placeholderPath); $this->imageAdapterMock->expects($this->at(1))->method('open')->with($placeholderPath); $this->imageAdapterMock->expects($this->once())->method('getMimeType')->willReturn($mimeType); $this->responseMock->expects($this->once())->method('setHeader')->with('Content-Type', $mimeType)->willReturnSelf(); $this->imageAdapterMock->expects($this->once())->method('getImage')->willReturn($imageBody); $this->responseMock->expects($this->once())->method('setBody')->with($imageBody)->willReturnSelf(); $this->loggerMock->expects($this->once())->method('critical')->with($exception); $this->wysiwygDirective->execute(); }