/** * @return void */ public function testExecute() { $content = ['export']; $fileName = 'products_mostviewed.csv'; $this->abstractBlockMock->expects($this->once())->method('getCsvFile')->willReturn($content); $this->layoutMock->expects($this->once())->method('createBlock')->with('Magento\\Reports\\Block\\Adminhtml\\Product\\Viewed\\Grid')->willReturn($this->abstractBlockMock); $this->fileFactoryMock->expects($this->once())->method('create')->with($fileName, $content, \Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR); $this->exportViewedCsv->execute(); }