You are here

public function AttachSourceTest::fileCanBeUploadAndDeleted in FileField Sources 8

Parameters

object $file: The file object.

string $dest_uri: The dest Uri where the file was uploaded.

1 call to AttachSourceTest::fileCanBeUploadAndDeleted()
AttachSourceTest::testMoveFilesFromRelativePath in tests/src/Functional/AttachSourceTest.php
Tests move relative files with different names.

File

tests/src/Functional/AttachSourceTest.php, line 55

Class

AttachSourceTest
Tests the attach source.

Namespace

Drupal\Tests\filefield_sources\Functional

Code

public function fileCanBeUploadAndDeleted($file, $dest_uri) {
  $this
    ->assertCanAttachFile($file);

  // Upload a file.
  $this
    ->uploadFileByAttachSource($file->uri, $file->filename, 0);

  // We can only attach one file on single value field.
  $this
    ->assertNoFieldByXPath('//input[@type="submit"]', t('Attach'), 'After uploading a file, "Attach" button is no longer displayed.');

  // Ensure file is moved.
  $this
    ->assertFalse(is_file($file->uri), 'Source file has been removed.');
  $this
    ->assertTrue(is_file($dest_uri), 'Destination file has been created.');
  $this
    ->removeFile($file->filename, 0);
  $this
    ->assertCanNotAttachFile($file);
}