You are here

protected function FileUrlWidgetTest::setUp in File URL 8

Same name and namespace in other branches
  1. 2.0.x tests/src/FunctionalJavascript/FileUrlWidgetTest.php \Drupal\Tests\file_url\FunctionalJavascript\FileUrlWidgetTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/FileUrlWidgetTest.php, line 52

Class

FileUrlWidgetTest
Tests the file URL widget.

Namespace

Drupal\Tests\file_url\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();

  // Create two file URL fields.
  $display = EntityFormDisplay::load('entity_test.entity_test.default');
  foreach (static::$fields as $field_name => $cardinality) {
    FieldStorageConfig::create([
      'type' => 'file_url',
      'entity_type' => 'entity_test',
      'field_name' => $field_name,
      'cardinality' => $cardinality,
    ])
      ->save();
    FieldConfig::create([
      'entity_type' => 'entity_test',
      'bundle' => 'entity_test',
      'field_type' => 'file_url',
      'field_name' => $field_name,
      'label' => $field_name,
    ])
      ->save();
    $display
      ->setComponent($field_name, [
      'type' => 'file_url_generic',
      'region' => 'content',
    ]);
  }
  $display
    ->save();

  // Generate some files for upload test.
  $this->files = $this
    ->getTestFiles('text');
  $this
    ->drupalLogin($this
    ->createUser([
    'administer entity_test content',
  ]));
}