You are here

protected function BambooTwigLoaderTest::createFile in Bamboo Twig 8.4

Same name and namespace in other branches
  1. 8.5 tests/src/Functional/BambooTwigLoaderTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigLoaderTest::createFile()
  2. 8.2 tests/src/Functional/BambooTwigLoaderTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigLoaderTest::createFile()
  3. 8.3 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 269

Class

BambooTwigLoaderTest
Tests Loaders twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

protected function createFile() {

  /** @var \Drupal\Component\PhpStorage\FileStorage $fileStorage */
  $fileStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('file');
  file_unmanaged_copy(drupal_get_path('module', 'bamboo_twig_test') . '/files/antistatique.jpg', PublicStream::basePath());
  $file = $fileStorage
    ->create([
    'uri' => 'public://antistatique.jpg',
    'status' => FILE_STATUS_PERMANENT,
  ]);
  $file
    ->save();
  return $file;
}