You are here

protected function UploadSourceTest::assertUploadSourceWorkProperly in FileField Sources 8

Tests upload source still working properly.

2 calls to UploadSourceTest::assertUploadSourceWorkProperly()
UploadSourceTest::testAllSourcesEnabled in tests/src/Functional/UploadSourceTest.php
Tests all sources enabled.
UploadSourceTest::testUploadSourceEnabled in tests/src/Functional/UploadSourceTest.php
Tests upload source enabled.

File

tests/src/Functional/UploadSourceTest.php, line 41

Class

UploadSourceTest
Tests the upload source.

Namespace

Drupal\Tests\filefield_sources\Functional

Code

protected function assertUploadSourceWorkProperly() {
  $file = $this
    ->createTemporaryFileEntity();

  // Upload a file by 'Upload' source.
  $this
    ->uploadFileByUploadSource($file
    ->getFileUri(), $file
    ->getFilename(), 0, FALSE);

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

  // Remove uploaded file.
  $this
    ->removeFile($file
    ->getFilename(), 0);

  // Can upload file again.
  $this
    ->assertFieldByXpath('//input[@type="submit"]', t('Upload'), 'After clicking the "Remove" button, the "Upload" button is displayed.');
}