You are here

protected function NumericFormatPluralTest::createFile in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php \Drupal\views\Tests\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/src/Tests/Plugin/NumericFormatPluralTest.php
Test plural formatting setting on a numeric views handler.

File

core/modules/views/src/Tests/Plugin/NumericFormatPluralTest.php, line 145
Contains \Drupal\views\Tests\Plugin\NumericFormatPluralTest.

Class

NumericFormatPluralTest
Tests the creation of numeric fields.

Namespace

Drupal\views\Tests\Plugin

Code

protected function createFile() {

  // Create a new file entity.
  $file = entity_create('file', array(
    '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;
}