public static function MockData::createFile in GatherContent 8.4
Same name and namespace in other branches
- 8.5 tests/modules/gathercontent_test/src/MockData.php \Drupal\gathercontent_test\MockData::createFile()
Create a file for every file element in item.
1 call to MockData::createFile()
- ContentProcessorTest::testCreateNode in tests/
src/ Kernel/ ContentProcessorTest.php - Data provider for createNodeTest.
File
- tests/
modules/ gathercontent_test/ src/ MockData.php, line 165
Class
- MockData
- A class for getting static test data.
Namespace
Drupal\gathercontent_testCode
public static function createFile(Item $item) {
$fileElements = array_filter(reset($item->config)->elements, function ($element) {
return $element instanceof ElementFiles;
});
$files = [];
foreach ($fileElements as $element) {
$file = new File();
$file->id = static::getUniqueInt();
$file->userId = static::getUniqueInt();
$file->itemId = $item->id;
$file->field = $element->id;
$file->url = static::$drupalRoot . '/' . drupal_get_path('module', 'gathercontent_test') . '/images/test.png';
$file->fileName = 'test.jpg';
$file->size = 60892;
$file->type = 'field';
$file->createdAt = '2017-08-18 15:48:10';
$file->updatedAt = '2017-08-18 15:48:10';
$files[$file->id] = $file;
}
return $files;
}