protected function PdfPreviewGeneratorTest::getFileMock in PDFPreview 2.0.x
Same name and namespace in other branches
- 8 tests/src/Unit/PDFPreviewGeneratorTest.php \Drupal\Tests\pdfpreview\Unit\PDFPreviewGeneratorTest::getFileMock()
Gets a mocked file for testing.
Parameters
string $filename: The filename.
int $id: The file id.
Return value
\Drupal\file\FileInterface The mocked file.
1 call to PdfPreviewGeneratorTest::getFileMock()
- PdfPreviewGeneratorTest::testGetDestinationUri in tests/
src/ Unit/ PdfPreviewGeneratorTest.php - @covers ::getDestinationURI
File
- tests/
src/ Unit/ PdfPreviewGeneratorTest.php, line 140
Class
- PdfPreviewGeneratorTest
- @coversDefaultClass \Drupal\pdfpreview\PdfPreviewGenerator
Namespace
Drupal\Tests\pdfpreview\UnitCode
protected function getFileMock($filename, $id) {
$methods = [
'id',
'getFileUri',
];
$file = $this
->getMockBuilder('\\Drupal\\file\\Entity\\File')
->disableOriginalConstructor()
->setMethods($methods)
->getMock();
$file
->expects($this
->any())
->method('id')
->willReturn($id);
$file
->expects($this
->any())
->method('getFileUri')
->willReturn('public://' . $filename);
return $file;
}