public function TestSubContext::fileCreate in Panopoly 8.2
Same name and namespace in other branches
- 7 modules/panopoly/panopoly_test/behat/steps/panopoly_test.behat.inc \TestSubContext::fileCreate()
Create a managed Drupal file.
Parameters
string $source_path: A file object passed in with the URI already set.
string $destination: (Optional) The desired URI where the file will be uploaded.
Return value
object A single Drupal file object.
1 call to TestSubContext::fileCreate()
- TestSubContext::createManagedFile in modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc - Copies the provided file into the site's files directory.
File
- modules/
panopoly/ panopoly_test/ behat/ steps/ panopoly_test.behat.inc, line 486 - Provide Behat step-definitions for generic Panopoly tests.
Class
- TestSubContext
- Behat sub-context for Panopoly.
Code
public function fileCreate($source_path, $destination = NULL) {
$data = file_get_contents($source_path);
// Before working with files, we need to change our current directory to
// DRUPAL_ROOT so that the relative paths that define the stream wrappers
// (like public:// or temporary://) actually work.
$cwd = getcwd();
chdir(DRUPAL_ROOT);
if ($file = file_save_data($data, $destination)) {
$this->files[] = $file;
}
// Then change back.
chdir($cwd);
return $file;
}