You are here

protected function FileEntityFormatterTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::setUp()
  2. 9 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php, line 38

Class

FileEntityFormatterTest
Tests the default file formatter.

Namespace

Drupal\Tests\file\Kernel\Formatter

Code

protected function setUp() : void {
  parent::setUp();
  $this->fileUrlGenerator = $this->container
    ->get('file_url_generator');
  $this
    ->installEntitySchema('file');
  $this->files = [];
  file_put_contents('public://file.png', str_repeat('t', 10));
  $file = File::create([
    'uri' => 'public://file.png',
    'filename' => 'file.png',
  ]);
  $file
    ->save();
  $this->files[] = $file;
  file_put_contents('public://file.tar', str_repeat('t', 200));
  $file = File::create([
    'uri' => 'public://file.tar',
    'filename' => 'file.tar',
  ]);
  $file
    ->save();
  $this->files[] = $file;
  file_put_contents('public://file.tar.gz', str_repeat('t', 40000));
  $file = File::create([
    'uri' => 'public://file.tar.gz',
    'filename' => 'file.tar.gz',
  ]);
  $file
    ->save();
  $this->files[] = $file;
  file_put_contents('public://file', str_repeat('t', 8000000));
  $file = File::create([
    'uri' => 'public://file',
    'filename' => 'file',
  ]);
  $file
    ->save();
  $this->files[] = $file;
}