public function FileFieldSourcesTestBase::uploadFileByImceSource in FileField Sources 8
Upload file by 'Imce' source.
Parameters
string $uri: File uri.
string $filename: File name.
int $delta: Delta in multiple values field.
3 calls to FileFieldSourcesTestBase::uploadFileByImceSource()
- EmptyValuesTest::testAllSourcesEnabled in tests/
src/ Functional/ EmptyValuesTest.php - Tests all sources enabled.
- ImceSourceTest::testImceSourceEnabled in tests/
src/ Functional/ ImceSourceTest.php - Tests imce source enabled.
- MultipleValuesTest::uploadFiles in tests/
src/ Functional/ MultipleValuesTest.php - Upload files.
File
- tests/
src/ Functional/ FileFieldSourcesTestBase.php, line 350
Class
- FileFieldSourcesTestBase
- Base class for File Field Sources test cases.
Namespace
Drupal\Tests\filefield_sources\FunctionalCode
public function uploadFileByImceSource($uri = '', $filename = '', $delta = 0) {
$scheme = parse_url($uri, PHP_URL_SCHEME);
$imce_path = str_replace("{$scheme}://", '', $uri);
// Can't be used drupalPostForm here because the field type is hidden
// and drupalPostForm don't see those, let's set the values manually.
$field_name = $this->fieldName . '[' . $delta . '][filefield_imce][imce_paths]';
$this
->getSession()
->getPage()
->find('css', 'input[name="' . $field_name . '"]')
->setValue($imce_path);
$this
->getSession()
->getPage()
->pressButton($this->fieldName . '_' . $delta . '_imce_select');
if ($filename) {
$this
->assertFileUploaded($filename, $delta);
}
else {
$this
->assertFileNotUploaded($delta);
}
}