UploadSourceTest.php in FileField Sources 8
File
tests/src/Functional/UploadSourceTest.php
View source
<?php
namespace Drupal\Tests\filefield_sources\Functional;
class UploadSourceTest extends FileFieldSourcesTestBase {
public function testUploadSourceEnabled() {
$this
->enableSources([
'upload' => TRUE,
]);
$this
->assertUploadSourceWorkProperly();
}
public function testAllSourcesEnabled() {
$this
->enableSources([
'upload' => TRUE,
'remote' => TRUE,
'clipboard' => TRUE,
'reference' => TRUE,
'attach' => TRUE,
]);
$this
->assertUploadSourceWorkProperly();
}
protected function assertUploadSourceWorkProperly() {
$file = $this
->createTemporaryFileEntity();
$this
->uploadFileByUploadSource($file
->getFileUri(), $file
->getFilename(), 0, FALSE);
$this
->assertNoFieldByXPath('//input[@type="submit"]', t('Upload'), t('After uploading a file, "Upload" button is no longer displayed.'));
$this
->removeFile($file
->getFilename(), 0);
$this
->assertFieldByXpath('//input[@type="submit"]', t('Upload'), 'After clicking the "Remove" button, the "Upload" button is displayed.');
}
}