You are here

private function FileUploadSecureValidatorTest::getConfigFactoryMock in File Upload Secure Validator 8

Utility function for getting a ConfigFactory service.

1 call to FileUploadSecureValidatorTest::getConfigFactoryMock()
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 161

Class

FileUploadSecureValidatorTest
A class for unit testing the file_upload_secure_validator service.

Namespace

Drupal\Tests\file_upload_secure_validator\Unit

Code

private function getConfigFactoryMock() {
  $mimeTypesEquivalenceGroups = [
    [
      'text/csv',
      'text/plain',
      'application/csv',
      'text/comma-separated-values',
      'application/excel',
      'application/vnd.ms-excel',
      'application/vnd.msexcel',
      'text/anytext',
      'application/octet-stream',
      'application/txt',
    ],
    [
      'text/xml',
      'text/plain',
      'application/xml',
    ],
    [
      'image/svg+xml',
      'image/svg',
    ],
    [
      'text/x-po',
      'application/octet-stream',
    ],
    [
      'text/plain',
      'application/pkix-cert',
      'application/pkix-crl',
      'application/x-x509-ca-cert',
      'application/x-x509-user-cert',
      'application/x-pem-file',
      'application/pgp-keys',
      'application/x-pkcs7-certificates',
      'application/x-pkcs7-certreqresp',
      'application/x-pkcs7-crl',
      'application/pkcs7-mime',
      'application/pkcs8',
      'application/pkcs10',
      'application/x-pkcs12',
    ],
    [
      'application/octet-stream',
      'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
      'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
    ],
  ];
  $configuration = $this
    ->getMockBuilder('Drupal\\Core\\Config\\ConfigFactory')
    ->disableOriginalConstructor()
    ->getMock();
  $configuration
    ->expects($this
    ->any())
    ->method('get')
    ->with($this
    ->equalTo('mime_types_equivalence_groups'))
    ->will($this
    ->returnValue($mimeTypesEquivalenceGroups));
  $configFactory = $this
    ->getMockBuilder('Drupal\\Core\\Config\\ConfigFactory')
    ->disableOriginalConstructor()
    ->getMock();
  $configFactory
    ->expects($this
    ->any())
    ->method('get')
    ->with($this
    ->equalTo('file_upload_secure_validator.settings'))
    ->will($this
    ->returnValue($configuration));
  return $configFactory;
}