You are here

protected function FeedsCommonTrait::createNodeWithFeedsItem in Feeds 8.3

Creates a new node with a feeds item field.

Parameters

\Drupal\feeds\FeedInterface $feed: The feed with which the node was imported.

array $settings: (optional) An associative array of settings for the node.

Return value

\Drupal\node\NodeInterface The created node entity.

12 calls to FeedsCommonTrait::createNodeWithFeedsItem()
EntityProcessorBaseTest::testCleanWithDeleteAction in tests/src/Kernel/Feeds/Processor/EntityProcessorBaseTest.php
@covers ::clean
EntityProcessorBaseTest::testCleanWithKeepNonExistent in tests/src/Kernel/Feeds/Processor/EntityProcessorBaseTest.php
@covers ::clean
EntityProcessorBaseTest::testCleanWithUnpublishAction in tests/src/Kernel/Feeds/Processor/EntityProcessorBaseTest.php
@covers ::clean
EntityProcessorBaseTest::testGetImportedItemIds in tests/src/Kernel/Feeds/Processor/EntityProcessorBaseTest.php
@covers ::getImportedItemIds
FeedsItemGuidFormatterTest::testFeedsItemGuidFormatter in tests/src/Functional/Plugin/Field/FieldFormatter/FeedsItemGuidFormatterTest.php
Test the feeds item guid formatter.

... See full list

File

tests/src/Traits/FeedsCommonTrait.php, line 49

Class

FeedsCommonTrait
Provides methods useful for Kernel and Functional Feeds tests.

Namespace

Drupal\Tests\feeds\Traits

Code

protected function createNodeWithFeedsItem(FeedInterface $feed, array $settings = []) {
  $settings += [
    'title' => $this
      ->randomMachineName(8),
    'type' => 'article',
    'uid' => 0,
    'feeds_item' => [
      'target_id' => $feed
        ->id(),
      'imported' => 0,
      'guid' => 1,
      'hash' => static::randomString(),
    ],
  ];
  $node = Node::create($settings);
  $node
    ->save();
  return $node;
}