You are here

protected function BambooTwigRenderTest::createFile in Bamboo Twig 8.5

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

Creates and gets test image file.

Return value

\Drupal\file\FileInterface File object.

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

File

tests/src/Functional/BambooTwigRenderTest.php, line 346

Class

BambooTwigRenderTest
Tests Renders 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;
}