protected function FileDownloadLinkMediaTestTrait::createTestNode in File Download Link 8
Helper function to create node that can be used for testing.
Return value
Drupal\node\Entity\Node An node to be used for testing.
2 calls to FileDownloadLinkMediaTestTrait::createTestNode()
- FileDownloadLinkMediaTest::setUp in tests/
src/ Kernel/ FileDownloadLinkMediaTest.php - FileDownloadLinkMediaTokenTest::setUp in tests/
src/ Kernel/ FileDownloadLinkMediaTokenTest.php
File
- tests/
src/ Kernel/ FileDownloadLinkMediaTestTrait.php, line 64
Class
- FileDownloadLinkMediaTestTrait
- Trait for testing file_download_link_media formatter.
Namespace
Drupal\Tests\file_download_link\KernelCode
protected function createTestNode() {
$node_type = NodeType::create([
'type' => 'test_node',
'name' => 'Test Node',
]);
$node_type
->save();
// Our entity will have an image field and a file field.
$field_storage = FieldStorageConfig::create([
'field_name' => 'field_media',
'entity_type' => 'node',
'type' => 'entity_reference',
'settings' => [
'target_type' => 'media',
],
]);
$field_storage
->save();
$instance = FieldConfig::create([
'field_storage' => $field_storage,
'bundle' => 'test_node',
'label' => 'Media',
]);
$instance
->save();
$node = Node::create([
'type' => 'test_node',
'title' => 'Test Entity',
]);
$node
->set('field_media', $this->media
->id());
$node
->set('status', 1);
$node
->save();
return $node;
}