You are here

protected function StubTestTrait::createStub in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/migrate_drupal/src/Tests/StubTestTrait.php \Drupal\migrate_drupal\Tests\StubTestTrait::createStub()

Create a stub of the given entity type.

Parameters

string $entity_type_id: The entity type we are stubbing.

Return value

int ID of the created entity.

4 calls to StubTestTrait::createStub()
MigrateAggregatorStubTest::testItemStub in core/modules/aggregator/src/Tests/Migrate/MigrateAggregatorStubTest.php
Tests creation of aggregator feed items.
MigrateBlockContentStubTest::testStubFailure in core/modules/block_content/src/Tests/Migrate/MigrateBlockContentStubTest.php
Tests creation of block content stubs with no block_content_type available.
MigrateCommentStubTest::testStub in core/modules/comment/src/Tests/Migrate/MigrateCommentStubTest.php
Tests creation of comment stubs.
StubTestTrait::performStubTest in core/modules/migrate_drupal/src/Tests/StubTestTrait.php
Test that creating a stub of the given entity type results in a valid entity.

File

core/modules/migrate_drupal/src/Tests/StubTestTrait.php, line 46
Contains \Drupal\migrate_drupal\Tests\StubTestTrait.

Class

StubTestTrait
Provides common functionality for testing stubbing.

Namespace

Drupal\migrate_drupal\Tests

Code

protected function createStub($entity_type_id) {

  // Create a dummy migration to pass to the destination plugin.
  $config = [
    'id' => 'dummy',
    'migration_tags' => [
      'Stub test',
    ],
    'source' => [
      'plugin' => 'empty',
    ],
    'process' => [],
    'destination' => [
      'plugin' => 'entity:' . $entity_type_id,
    ],
  ];
  $migration = Migration::create($config);
  $destination_plugin = $migration
    ->getDestinationPlugin(TRUE);
  $stub_row = new Row([], [], TRUE);
  $destination_ids = $destination_plugin
    ->import($stub_row);
  return reset($destination_ids);
}