public function FileFieldSourcesTestBase::uploadFileByReferenceSource in FileField Sources 8
Upload file by 'Reference' source.
Parameters
int $fid: File id.
string $filename: File name.
int $delta: Delta in multiple values field.
3 calls to FileFieldSourcesTestBase::uploadFileByReferenceSource()
- EmptyValuesTest::testAllSourcesEnabled in tests/
src/ Functional/ EmptyValuesTest.php - Tests all sources enabled.
- MultipleValuesTest::uploadFiles in tests/
src/ Functional/ MultipleValuesTest.php - Upload files.
- ReferenceSourceTest::testReferenceSourceEnabled in tests/
src/ Functional/ ReferenceSourceTest.php - Tests reference source enabled.
File
- tests/
src/ Functional/ FileFieldSourcesTestBase.php, line 298
Class
- FileFieldSourcesTestBase
- Base class for File Field Sources test cases.
Namespace
Drupal\Tests\filefield_sources\FunctionalCode
public function uploadFileByReferenceSource($fid = 0, $filename = '', $delta = 0) {
$name = $this->fieldName . '[' . $delta . '][filefield_reference][autocomplete]';
$value = $fid ? $filename . ' [fid:' . $fid . ']' : '';
$edit = [
$name => $value,
];
$this
->drupalPostForm(NULL, $edit, $this->fieldName . '_' . $delta . '_autocomplete_select');
if ($filename) {
$this
->assertFileUploaded($filename, $delta);
}
else {
$this
->assertFileNotUploaded($delta);
}
}