You are here

protected function EntityEmbedTestBase::getTestFile in Entity Embed 8

Retrieves a sample file of the specified type.

Return value

\Drupal\file\FileInterface The test file created.

2 calls to EntityEmbedTestBase::getTestFile()
FileFieldFormatterTest::setUp in tests/src/Functional/FileFieldFormatterTest.php
ImageFieldFormatterTest::setUp in tests/src/Functional/ImageFieldFormatterTest.php

File

tests/src/Functional/EntityEmbedTestBase.php, line 119

Class

EntityEmbedTestBase
Base class for all entity_embed tests.

Namespace

Drupal\Tests\entity_embed\Functional

Code

protected function getTestFile($type_name, $size = NULL) {

  // Get a file to upload.
  $file = current($this
    ->getTestFiles($type_name, $size));

  // Add a filesize property to files as would be read by
  // \Drupal\file\Entity\File::load().
  $file->filesize = filesize($file->uri);
  $file = File::create((array) $file);
  $file
    ->save();
  return $file;
}