function FileEntityFormatterTest::setUp

Same name in other branches
  1. 9 core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::setUp()
  2. 8.9.x core/modules/file/tests/src/Kernel/Formatter/FileEntityFormatterTest.php \Drupal\Tests\file\Kernel\Formatter\FileEntityFormatterTest::setUp()
  3. 10 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 40

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.