/** * {@inheritdoc} */ public function dispatch(\Magento\Framework\App\RequestInterface $request) { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'dispatch'); if (!$pluginInfo) { return parent::dispatch($request); } else { return $this->___callPlugins('dispatch', func_get_args(), $pluginInfo); } }
public function testExecute() { $data = ['tmp_name' => 'tmp_name', 'path' => 'path', 'file' => 'file']; $uploader = $this->getMockBuilder('Magento\\MediaStorage\\Model\\File\\Uploader')->disableOriginalConstructor()->getMock(); $resultJson = $this->getMockBuilder('Magento\\Framework\\Controller\\Result\\Json')->disableOriginalConstructor()->setMethods(['setData'])->getMock(); $this->request->expects($this->once())->method('getParam')->with('type')->willReturn('samples'); $this->sample->expects($this->once())->method('getBaseTmpPath')->willReturn('base_tmp_path'); $this->uploaderFactory->expects($this->once())->method('create')->willReturn($uploader); $this->fileHelper->expects($this->once())->method('uploadFromTmp')->willReturn($data); $this->storageDatabase->expects($this->once())->method('saveFile'); $this->session->expects($this->once())->method('getName')->willReturn('Name'); $this->session->expects($this->once())->method('getSessionId')->willReturn('SessionId'); $this->session->expects($this->once())->method('getCookieLifetime')->willReturn('CookieLifetime'); $this->session->expects($this->once())->method('getCookiePath')->willReturn('CookiePath'); $this->session->expects($this->once())->method('getCookieDomain')->willReturn('CookieDomain'); $this->resultFactory->expects($this->once())->method('create')->willReturn($resultJson); $resultJson->expects($this->once())->method('setData')->willReturnSelf(); $this->assertEquals($resultJson, $this->upload->execute()); }