You are here

public function FileFieldPathsGeneralTest::testNoFile in File (Field) Paths 8

Test File (Field) Paths works as normal when no file uploaded.

This test is simply to prove that there are no exceptions/errors when submitting a form with no File (Field) Paths affected files attached.

File

tests/src/Functional/FileFieldPathsGeneralTest.php, line 46

Class

FileFieldPathsGeneralTest
Test general functionality.

Namespace

Drupal\Tests\filefield_paths\Functional

Code

public function testNoFile() {

  // Create a File field.
  $field_name = mb_strtolower($this
    ->randomMachineName());
  $third_party_settings['filefield_paths']['file_path']['value'] = 'node/[node:nid]';
  $third_party_settings['filefield_paths']['file_name']['value'] = '[node:nid].[file:ffp-extension-original]';
  $this
    ->createFileField($field_name, 'node', $this->contentType, [], [], $third_party_settings);

  // Create a node without a file attached.
  $this
    ->drupalGet('node/add/' . $this->contentType);
  $this
    ->submitForm([
    'title[0][value]' => $this
      ->randomMachineName(8),
  ], 'Save');
}