You are here

protected function PDFPreviewGeneratorTest::getFileMock in PDFPreview 8

Same name and namespace in other branches
  1. 2.0.x 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\Unit

Code

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;
}