You are here

public function RemoteStreamWrapperWidgetTest::setUp in Remote stream wrapper widget 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/RemoteStreamWrapperWidgetTest.php, line 59

Class

RemoteStreamWrapperWidgetTest
Tests the Remote Stream Wrapper Widget.

Namespace

Drupal\Tests\remote_stream_wrapper_widget\Functional

Code

public function setUp() {
  parent::setUp();
  $this->contentType = $this
    ->drupalCreateContentType();
  $this->fieldName = strtolower($this
    ->randomMachineName());
  $this->fieldStorage = FieldStorageConfig::create([
    'field_name' => $this->fieldName,
    'entity_type' => 'node',
    'type' => 'file',
  ]);
  $this->fieldStorage
    ->save();
  $this->field = FieldConfig::create([
    'field_storage' => $this->fieldStorage,
    'bundle' => $this->contentType
      ->id(),
  ]);
  $this->field
    ->save();
  \Drupal::service('entity_display.repository')
    ->getFormDisplay('node', $this->contentType
    ->id(), 'default')
    ->setComponent($this->fieldName, [
    'type' => 'remote_stream_wrapper',
  ])
    ->save();
  \Drupal::service('entity_display.repository')
    ->getViewDisplay('node', $this->contentType
    ->id(), 'full')
    ->setComponent($this->fieldName, [
    'type' => 'file_url_plain',
  ])
    ->save();
  $this->user = $this
    ->drupalCreateUser([
    'bypass node access',
  ]);
  $this
    ->drupalLogin($this->user);
}