Ejemplo n.º 1
0
 public function testExecuteInvalidArgument()
 {
     $themeId = 1;
     $fileParam = '/path/to/file.ext';
     $fileId = 'fileId';
     $refererUrl = 'referer/url';
     $this->request->expects($this->any())->method('getParam')->willReturnMap([['theme_id', null, $themeId], ['file', null, $fileParam]]);
     $theme = $this->getMockBuilder('Magento\\Framework\\View\\Design\\ThemeInterface')->setMethods(['getId', 'load'])->getMockForAbstractClass();
     $urlDecoder = $this->getMockBuilder('Magento\\Framework\\Url\\DecoderInterface')->getMock();
     $logger = $this->getMockBuilder('Psr\\Log\\LoggerInterface')->getMock();
     $this->objectManager->expects($this->any())->method('get')->willReturnMap([['Magento\\Framework\\Url\\DecoderInterface', $urlDecoder], ['Psr\\Log\\LoggerInterface', $logger]]);
     $this->objectManager->expects($this->any())->method('create')->with('Magento\\Framework\\View\\Design\\ThemeInterface')->willReturn($theme);
     $urlDecoder->expects($this->once())->method('decode')->with($fileParam)->willReturn($fileId);
     $theme->expects($this->once())->method('load')->with($themeId)->willReturnSelf();
     $theme->expects($this->once())->method('getId')->willReturn(null);
     $this->messageManager->expects($this->once())->method('addException');
     $logger->expects($this->once())->method('critical');
     $this->redirect->expects($this->once())->method('getRefererUrl')->willReturn($refererUrl);
     $this->response->expects($this->once())->method('setRedirect')->with($refererUrl);
     $this->controller->execute();
 }