You are here

protected function BambooTwigLoaderTest::createFile in Bamboo Twig 8.5

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/BambooTwigLoaderTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigLoaderTest::createFile()
  2. 8.3 tests/src/Functional/BambooTwigLoaderTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigLoaderTest::createFile()
  3. 8.4 tests/src/Functional/BambooTwigLoaderTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigLoaderTest::createFile()

Creates and gets test image file.

Return value

\Drupal\file\FileInterface File object.

1 call to BambooTwigLoaderTest::createFile()
BambooTwigLoaderTest::setUp in tests/src/Functional/BambooTwigLoaderTest.php

File

tests/src/Functional/BambooTwigLoaderTest.php, line 271

Class

BambooTwigLoaderTest
Tests Loaders twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

protected function createFile() {

  /** @var \Drupal\Component\PhpStorage\FileStorage $file_storage */
  $file_storage = $this->container
    ->get('entity_type.manager')
    ->getStorage('file');

  /** @var \Drupal\Core\File\FileSystemInterface $file_system */
  $file_system = $this->container
    ->get('file_system');
  $file_system
    ->copy(drupal_get_path('module', 'bamboo_twig_test') . '/files/antistatique.jpg', PublicStream::basePath());
  $file = $file_storage
    ->create([
    'uri' => 'public://antistatique.jpg',
    'status' => FILE_STATUS_PERMANENT,
  ]);
  $file
    ->save();
  return $file;
}