You are here

public function FileFieldSourcesTestBase::uploadFileByAttachSource in FileField Sources 8

Upload file by 'Attach' source.

Parameters

string $uri: File uri.

string $filename: File name.

int $delta: Delta in multiple values field.

4 calls to FileFieldSourcesTestBase::uploadFileByAttachSource()
AttachSourceTest::fileCanBeUploadAndDeleted in tests/src/Functional/AttachSourceTest.php
AttachSourceTest::testCopyFileFromAbsolutePath in tests/src/Functional/AttachSourceTest.php
Tests copy file from absolute path.
EmptyValuesTest::testAllSourcesEnabled in tests/src/Functional/EmptyValuesTest.php
Tests all sources enabled.
MultipleValuesTest::uploadFiles in tests/src/Functional/MultipleValuesTest.php
Upload files.

File

tests/src/Functional/FileFieldSourcesTestBase.php, line 240

Class

FileFieldSourcesTestBase
Base class for File Field Sources test cases.

Namespace

Drupal\Tests\filefield_sources\Functional

Code

public function uploadFileByAttachSource($uri = '', $filename = '', $delta = 0) {
  if ($uri) {
    $edit = [
      $this->fieldName . '[' . $delta . '][filefield_attach][filename]' => $uri,
    ];
  }
  else {
    $edit = [];
  }
  $this
    ->drupalPostForm(NULL, $edit, $this->fieldName . '_' . $delta . '_attach');
  if ($filename) {
    $this
      ->assertFileUploaded($filename, $delta);
  }
  else {
    $this
      ->assertFileNotUploaded($delta);
  }
}