public function NodeImportTestCase::nodeImportCreateFile in Node import 6
Create a file with the specified data.
Parameters
$data: Twodimensional array.
$file_options: Array with record separator, etc.
Return value
String. Path to file (in temporary directory).
1 call to NodeImportTestCase::nodeImportCreateFile()
- NodeImportNode::testBasicNode in tests/
supported/ node.test - Test import of basic node.
File
- tests/
NodeImportTestCase.php, line 68 - DrupalWebTestCase wrapper with some extra functions to ease the development of node_import tests.
Class
- NodeImportTestCase
- @file DrupalWebTestCase wrapper with some extra functions to ease the development of node_import tests.
Code
public function nodeImportCreateFile($data, $file_options = array()) {
module_load_include('inc', 'node_import');
$path = file_create_filename($this
->randomName() . '.csv', file_directory_temp());
$fp = fopen($path, 'w');
foreach ($data as $row) {
$s = node_import_write_to_string($row, $file_options);
fputs($fp, $s);
}
fclose($fp);
return $path;
}