You are here

public function FileUploadSecureValidatorTest::testFileUploadSecureValidatorValidate in File Upload Secure Validator 8

Tests the file upload validate function of the provided service.

@dataProvider fileUploadScenariosProvider

File

tests/src/Unit/FileUploadSecureValidatorTest.php, line 21

Class

FileUploadSecureValidatorTest
A class for unit testing the file_upload_secure_validator service.

Namespace

Drupal\Tests\file_upload_secure_validator\Unit

Code

public function testFileUploadSecureValidatorValidate($case, $uri, $mimetype, $expectedError) {

  // This is the main class of the service.
  $file_upload_secure_validator_service = new FileUploadSecureValidator($this
    ->getLoggerFactoryMock(), $this
    ->getTranslationManagerMock(), $this
    ->getConfigFactoryMock());
  $errors = $file_upload_secure_validator_service
    ->validate($this
    ->mockFile($uri, $mimetype));
  $error = array_pop($errors);
  $this
    ->assertEquals($error, $expectedError);
}