You are here

public function MinisiteTestBase::uploadNodeFile in Mini site 8

Uploads a file to a node.

Parameters

\Drupal\file\FileInterface $file: The File to be uploaded.

string $field_name: The name of the field on which the files should be saved.

int|string $nid_or_type: A numeric node id to upload files to an existing node, or a string indicating the desired bundle for a new node.

bool $new_revision: The revision number.

array $extras: Additional values when a new node is created.

Return value

int The node id.

2 calls to MinisiteTestBase::uploadNodeFile()
FieldValidationTest::testValidateArchiveFormat in tests/src/Functional/FieldValidationTest.php
Tests the archive format on minisite field.
FieldValidationTest::testValidateRequired in tests/src/Functional/FieldValidationTest.php
Tests the required property on minisite field.

File

tests/src/Functional/MinisiteTestBase.php, line 155

Class

MinisiteTestBase
Provides methods specifically for testing Minisite module's field handling.

Namespace

Drupal\Tests\minisite\Functional

Code

public function uploadNodeFile(FileInterface $file, $field_name, $nid_or_type, $new_revision = TRUE, array $extras = []) {
  return $this
    ->uploadNodeFiles([
    $file,
  ], $field_name, $nid_or_type, $new_revision, $extras);
}