You are here

protected function NumericFormatPluralTest::createFile in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php \Drupal\Tests\views\Functional\Plugin\NumericFormatPluralTest::createFile()

Creates and saves a test file.

Return value

\Drupal\Core\Entity\EntityInterface A file entity.

1 call to NumericFormatPluralTest::createFile()
NumericFormatPluralTest::testNumericFormatPlural in core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php
Test plural formatting setting on a numeric views handler.

File

core/modules/views/tests/src/Functional/Plugin/NumericFormatPluralTest.php, line 150

Class

NumericFormatPluralTest
Tests the creation of numeric fields.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

protected function createFile() {

  // Create a new file entity.
  $file = File::create([
    'uid' => 1,
    'filename' => 'druplicon.txt',
    'uri' => 'public://druplicon.txt',
    'filemime' => 'text/plain',
    'created' => 1,
    'changed' => 1,
    'status' => FILE_STATUS_PERMANENT,
  ]);
  file_put_contents($file
    ->getFileUri(), 'hello world');

  // Save it, inserting a new record.
  $file
    ->save();
  return $file;
}