You are here

protected function BambooTwigRenderTest::createFile in Bamboo Twig 8.3

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

Class

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