5 * Definition of Drupal\filefield_sources\Tests\UploadSourceTest.
8 namespace Drupal\filefield_sources\Tests;
11 * Tests the upload source.
13 * @group filefield_sources
15 class UploadSourceTest extends FileFieldSourcesTestBase {
18 * Tests upload source enabled.
20 public function testUploadSourceEnabled() {
21 $this->enableSources(array(
25 $this->assertUploadSourceWorkProperly();
29 * Tests all sources enabled.
31 public function testAllSourcesEnabled() {
32 $this->enableSources(array(
40 $this->assertUploadSourceWorkProperly();
44 * Tests upload source still working properly.
46 protected function assertUploadSourceWorkProperly() {
47 $file = $this->createTemporaryFileEntity();
49 // Upload a file by 'Upload' source.
50 $this->uploadFileByUploadSource($file->getFileUri(), $file->getFilename(), 0, FALSE);
52 // We can only upload one file on single value field.
53 $this->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), t('After uploading a file, "Upload" button is no longer displayed.'));
55 // Remove uploaded file.
56 $this->removeFile($file->getFilename(), 0);
58 // Can upload file again.
59 $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), 'After clicking the "Remove" button, the "Upload" button is displayed.');