public function ReferenceSourceTest::testReferenceSourceEnabled in FileField Sources 8
Tests reference source enabled.
File
- tests/
src/ Functional/ ReferenceSourceTest.php, line 18
Class
- ReferenceSourceTest
- Tests the reference source.
Namespace
Drupal\Tests\filefield_sources\FunctionalCode
public function testReferenceSourceEnabled() {
// Create test file.
$file = $this
->createPermanentFileEntity();
$this
->enableSources([
'reference' => TRUE,
]);
// Upload a file by 'Reference' source.
$this
->uploadFileByReferenceSource($file
->id(), $file
->getFilename(), 0);
// We can only refer one file on single value field.
$this
->assertNoFieldByXPath('//input[@type="submit"]', t('Select'), t('After uploading a file, "Select" button is no longer displayed.'));
// Remove uploaded file.
$this
->removeFile($file
->getFileName(), 0);
// Can select file again.
$this
->assertFieldByXpath('//input[@type="submit"]', t('Select'), 'After clicking the "Remove" button, the "Select" button is displayed.');
}