You are here

protected function FileEntityNormalizerTest::getTestFiles in File Entity (fieldable files) 8.2

Create some test files like WebTestBase::drupalGetTestFiles().

Return value

array An associative array (keyed on uri) of objects with 'uri', 'filename', and 'name' properties corresponding to the test files.

1 call to FileEntityNormalizerTest::getTestFiles()
FileEntityNormalizerTest::testFileSerialize in tests/src/Kernel/FileEntityNormalizerTest.php
Tests that file entities are correctly serialized, including file contents.

File

tests/src/Kernel/FileEntityNormalizerTest.php, line 221

Class

FileEntityNormalizerTest
Tests the File entity normalizer.

Namespace

Drupal\Tests\file_entity\Kernel

Code

protected function getTestFiles() {

  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
  $file_system = \Drupal::service('file_system');
  $files = $file_system
    ->scanDirectory(DRUPAL_ROOT . '/core/tests/fixtures/files/', '/(html|image|javascript|php|sql)-.*/');
  foreach ($files as $file) {
    unset($files[$file->uri]);
    $new_path = $file_system
      ->copy($file->uri, PublicStream::basePath());
    $file->uri = $new_path;
    $files[$new_path] = $file;
  }
  return $files;
}