function DrupalTestBrowser::addPostFiles
Same name in other branches
- 9 core/tests/Drupal/Tests/DrupalTestBrowser.php \Drupal\Tests\DrupalTestBrowser::addPostFiles()
- 10 core/tests/Drupal/Tests/DrupalTestBrowser.php \Drupal\Tests\DrupalTestBrowser::addPostFiles()
Adds files to the $multipart array.
Parameters
array $files: The files.
array $multipart: A reference to the multipart array to add the files to.
string $array_name: Internal parameter used by recursive calls.
1 call to DrupalTestBrowser::addPostFiles()
- DrupalTestBrowser::doRequest in core/
tests/ Drupal/ Tests/ DrupalTestBrowser.php
File
-
core/
tests/ Drupal/ Tests/ DrupalTestBrowser.php, line 164
Class
- DrupalTestBrowser
- Enables a BrowserKitDriver mink driver to use a Guzzle client.
Namespace
Drupal\TestsCode
protected function addPostFiles(array $files, array &$multipart, $array_name = '') {
if (empty($files)) {
return;
}
foreach ($files as $name => $info) {
if (!empty($array_name)) {
$name = $array_name . '[' . $name . ']';
}
$file = [
'name' => $name,
];
if (\is_array($info)) {
if (isset($info['tmp_name'])) {
if ($info['tmp_name'] !== '') {
$file['contents'] = fopen($info['tmp_name'], 'r');
if (isset($info['name'])) {
$file['filename'] = $info['name'];
}
}
else {
continue;
}
}
else {
$this->addPostFiles($info, $multipart, $name);
continue;
}
}
else {
$file['contents'] = fopen($info, 'r');
}
$multipart[] = $file;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.