本文整理汇总了PHP中Magento\Framework\App\Response\Http\FileFactory::expects方法的典型用法代码示例。如果您正苦于以下问题:PHP FileFactory::expects方法的具体用法?PHP FileFactory::expects怎么用?PHP FileFactory::expects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Response\Http\FileFactory
的用法示例。
在下文中一共展示了FileFactory::expects方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExportVarnishConfigAction
public function testExportVarnishConfigAction()
{
$fileContent = 'some conetnt';
$filename = 'varnish.vcl';
$responseMock = $this->getMockBuilder('Magento\\Framework\\App\\ResponseInterface')->disableOriginalConstructor()->getMock();
$this->configMock->expects($this->once())->method('getVclFile')->will($this->returnValue($fileContent));
$this->fileFactoryMock->expects($this->once())->method('create')->with($this->equalTo($filename), $this->equalTo($fileContent), $this->equalTo(DirectoryList::VAR_DIR))->will($this->returnValue($responseMock));
$result = $this->action->executeInternal();
$this->assertInstanceOf('Magento\\Framework\\App\\ResponseInterface', $result);
}
示例2: fileCreate
/**
* Run file create section
*
* @return string
*/
protected function fileCreate()
{
$resultContent = 'result-pdf-content';
$incrementId = '1000001';
$this->shipmentMock->expects($this->once())->method('getIncrementId')->will($this->returnValue($incrementId));
$this->fileFactoryMock->expects($this->once())->method('create')->will($this->returnValue($resultContent));
return $resultContent;
}
示例3: testExecute
/**
* Run test execute method
*/
public function testExecute()
{
$date = '9999-99-99_77-77-77';
$content = 'PDF content';
$packagingMock = $this->getMock(
'Magento\Shipping\Model\Order\Pdf\Packaging',
['getPdf'],
[],
'',
false
);
$pdfMock = $this->getMock(
'Zend_Pdf',
['render'],
[],
'',
false
);
$dateTimeMock = $this->getMock(
'Magento\Framework\Stdlib\DateTime\DateTime',
['date'],
[],
'',
false
);
$this->shipmentLoaderMock->expects($this->once())
->method('load')
->will($this->returnValue($this->shipmentMock));
$this->objectManagerMock->expects($this->once())
->method('create')
->with('Magento\Shipping\Model\Order\Pdf\Packaging')
->will($this->returnValue($packagingMock));
$packagingMock->expects($this->once())
->method('getPdf')
->with($this->shipmentMock)
->will($this->returnValue($pdfMock));
$this->objectManagerMock->expects($this->once())
->method('get')
->with('Magento\Framework\Stdlib\DateTime\DateTime')
->will($this->returnValue($dateTimeMock));
$dateTimeMock->expects($this->once())->method('date')->with('Y-m-d_H-i-s')->will($this->returnValue($date));
$pdfMock->expects($this->once())->method('render')->will($this->returnValue($content));
$this->fileFactoryMock->expects($this->once())
->method('create')
->with(
'packingslip' . $date . '.pdf',
$content,
DirectoryList::VAR_DIR,
'application/pdf'
)->will($this->returnValue('result-pdf-content'));
$this->assertEquals('result-pdf-content', $this->controller->executeInternal());
}
示例4: testExecute
public function testExecute()
{
$themeId = 1;
$fileName = 'file.ext';
$fullPath = 'path/to/file';
$file = $this->getMockBuilder('Magento\Framework\View\Design\Theme\FileInterface')->getMock();
$customization = $this->getMockBuilder('Magento\Framework\View\Design\Theme\Customization')
->disableOriginalConstructor()
->getMock();
$theme = $this->getMockBuilder('Magento\Framework\View\Design\ThemeInterface')
->setMethods(['getCustomization'])
->getMockForAbstractClass();
$file->expects($this->once())
->method('getContent')
->willReturn('some_content');
$file->expects($this->once())
->method('getFilename')
->willReturn($fileName);
$file->expects($this->once())
->method('getFullPath')
->willReturn($fullPath);
$theme->expects($this->once())
->method('getCustomization')
->willReturn($customization);
$customization->expects($this->once())
->method('getFilesByType')
->with(\Magento\Theme\Model\Theme\Customization\File\CustomCss::TYPE)
->willReturn([$file]);
$this->request->expects($this->any())
->method('getParam')
->with('theme_id')
->willReturn($themeId);
$themeFactory = $this->getMockBuilder('Magento\Framework\View\Design\Theme\FlyweightFactory')
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
$this->objectManager->expects($this->any())
->method('create')
->with('Magento\Framework\View\Design\Theme\FlyweightFactory')
->willReturn($themeFactory);
$themeFactory->expects($this->once())
->method('create')
->with($themeId)
->willReturn($theme);
$this->fileFactory->expects($this->once())
->method('create')
->with($fileName, ['type' => 'filename', 'value' => $fullPath], DirectoryList::ROOT)
->willReturn($this->getMockBuilder('Magento\Framework\App\ResponseInterface')->getMock());
$this->assertInstanceOf('Magento\Framework\App\ResponseInterface', $this->controller->executeInternal());
}
示例5: testExecute
/**
* @covers \Magento\Sales\Controller\Adminhtml\Order\Creditmemo\PrintAction::executeInternal
*/
public function testExecute()
{
$creditmemoId = 2;
$date = '2015-01-19_13-03-45';
$fileName = 'creditmemo2015-01-19_13-03-45.pdf';
$fileContents = 'pdf0123456789';
$this->prepareTestExecute($creditmemoId);
$this->objectManagerMock->expects($this->any())
->method('create')
->willReturnMap(
[
['Magento\Sales\Model\Order\Creditmemo', [], $this->creditmemoMock],
['Magento\Sales\Model\Order\Pdf\Creditmemo', [], $this->creditmemoPdfMock]
]
);
$this->creditmemoRepositoryMock->expects($this->once())
->method('get')
->with($creditmemoId)
->willReturn($this->creditmemoMock);
$this->creditmemoPdfMock->expects($this->once())
->method('getPdf')
->with([$this->creditmemoMock])
->willReturn($this->pdfMock);
$this->objectManagerMock->expects($this->once())
->method('get')
->with('Magento\Framework\Stdlib\DateTime\DateTime')
->willReturn($this->dateTimeMock);
$this->dateTimeMock->expects($this->once())
->method('date')
->with('Y-m-d_H-i-s')
->willReturn($date);
$this->pdfMock->expects($this->once())
->method('render')
->willReturn($fileContents);
$this->fileFactoryMock->expects($this->once())
->method('create')
->with(
$fileName,
$fileContents,
\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR,
'application/pdf'
)
->willReturn($this->responseMock);
$this->assertInstanceOf(
'Magento\Framework\App\ResponseInterface',
$this->printAction->executeInternal()
);
}
示例6: testExecuteBackupFound
/**
* @covers \Magento\Backup\Controller\Adminhtml\Index\Download::execute
*/
public function testExecuteBackupFound()
{
$time = 1;
$type = 'db';
$filename = 'filename';
$size = 10;
$output = 'test';
$this->backupModelMock->expects($this->atLeastOnce())->method('getTime')->willReturn($time);
$this->backupModelMock->expects($this->atLeastOnce())->method('exists')->willReturn(true);
$this->backupModelMock->expects($this->atLeastOnce())->method('getSize')->willReturn($size);
$this->backupModelMock->expects($this->atLeastOnce())->method('output')->willReturn($output);
$this->requestMock->expects($this->any())->method('getParam')->willReturnMap([['time', null, $time], ['type', null, $type]]);
$this->backupModelFactoryMock->expects($this->once())->method('create')->with($time, $type)->willReturn($this->backupModelMock);
$this->dataHelperMock->expects($this->once())->method('generateBackupDownloadName')->with($this->backupModelMock)->willReturn($filename);
$this->objectManagerMock->expects($this->once())->method('get')->with('Magento\\Backup\\Helper\\Data')->willReturn($this->dataHelperMock);
$this->fileFactoryMock->expects($this->once())->method('create')->with($filename, null, DirectoryList::VAR_DIR, 'application/octet-stream', $size)->willReturn($this->responseMock);
$this->resultRawMock->expects($this->once())->method('setContents')->with($output);
$this->resultRawFactoryMock->expects($this->once())->method('create')->willReturn($this->resultRawMock);
$this->assertSame($this->resultRawMock, $this->downloadController->execute());
}
示例7: testExecute
public function testExecute()
{
$themeId = 1;
$fileParam = '/path/to/file.ext';
$fileId = 'fileId';
$sourceFile = '/source/file.ext';
$relPath = 'file.ext';
$this->request->expects($this->any())->method('getParam')->willReturnMap([['theme_id', null, $themeId], ['file', null, $fileParam]]);
$file = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File')->disableOriginalConstructor()->getMock();
$theme = $this->getMockBuilder('Magento\\Framework\\View\\Design\\ThemeInterface')->setMethods(['getId', 'load'])->getMockForAbstractClass();
$urlDecoder = $this->getMockBuilder('Magento\\Framework\\Url\\DecoderInterface')->getMock();
$directoryRead = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->getMock();
$this->objectManager->expects($this->any())->method('get')->with('Magento\\Framework\\Url\\DecoderInterface')->willReturn($urlDecoder);
$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($themeId);
$this->repository->expects($this->once())->method('createAsset')->with($fileId, ['themeModel' => $theme])->willReturn($file);
$this->filesystem->expects($this->once())->method('getDirectoryRead')->with(DirectoryList::ROOT)->willReturn($directoryRead);
$file->expects($this->once())->method('getSourceFile')->willReturn($sourceFile);
$directoryRead->expects($this->once())->method('getRelativePath')->with($sourceFile)->willReturn($relPath);
$this->fileFactory->expects($this->once())->method('create')->with($relPath, ['type' => 'filename', 'value' => $relPath], DirectoryList::ROOT)->willReturn($this->getMockBuilder('Magento\\Framework\\App\\ResponseInterface')->getMock());
$this->assertInstanceOf('Magento\\Framework\\App\\ResponseInterface', $this->controller->execute());
}