private function FileUploadSecureValidatorTest::mockFile in File Upload Secure Validator 8
Mock file entities.
We are only interested in the uri and mimetype getters.
1 call to FileUploadSecureValidatorTest::mockFile()
- FileUploadSecureValidatorTest::testFileUploadSecureValidatorValidate in tests/src/ Unit/ FileUploadSecureValidatorTest.php 
- Tests the file upload validate function of the provided service.
File
- tests/src/ Unit/ FileUploadSecureValidatorTest.php, line 108 
Class
- FileUploadSecureValidatorTest
- A class for unit testing the file_upload_secure_validator service.
Namespace
Drupal\Tests\file_upload_secure_validator\UnitCode
private function mockFile($uri, $mimetype) {
  $fileMock = $this
    ->getMockBuilder('Drupal\\file\\Entity\\File')
    ->disableOriginalConstructor()
    ->getMock();
  $fileMock
    ->expects($this
    ->any())
    ->method('getFileUri')
    ->willReturn($uri);
  $fileMock
    ->expects($this
    ->any())
    ->method('getMimeType')
    ->willReturn($mimetype);
  return $fileMock;
}