You are here

protected function MigrateTestBase::mockFailure in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/migrate/tests/src/Kernel/MigrateTestBase.php \Drupal\Tests\migrate\Kernel\MigrateTestBase::mockFailure()
  2. 10 core/modules/migrate/tests/src/Kernel/MigrateTestBase.php \Drupal\Tests\migrate\Kernel\MigrateTestBase::mockFailure()

Records a failure in the map table of a specific migration.

This is done in order to test scenarios which require a failed row.

Parameters

string|\Drupal\migrate\Plugin\MigrationInterface $migration: The migration entity, or its ID.

array $row: The raw source row which "failed".

int $status: (optional) The failure status. Should be one of the MigrateIdMapInterface::STATUS_* constants. Defaults to MigrateIdMapInterface::STATUS_FAILED.

7 calls to MigrateTestBase::mockFailure()
MigrateRollbackTest::testRollback in core/modules/migrate/tests/src/Kernel/MigrateRollbackTest.php
Tests rolling back configuration and content entities.
MigrateTermNodeTest::testSkipNonExistentNode in core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateTermNodeTest.php
Tests that term associations are ignored when they belong to nodes which were not migrated.
MigrateUploadEntityDisplayTest::testSkipNonExistentNodeType in core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityDisplayTest.php
Tests that entity displays are ignored appropriately.
MigrateUploadEntityFormDisplayTest::testSkipNonExistentNodeType in core/modules/file/tests/src/Kernel/Migrate/d6/MigrateUploadEntityFormDisplayTest.php
Tests that entity displays are ignored appropriately.
MigrateVocabularyEntityDisplayTest::testSkipNonExistentNodeType in core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateVocabularyEntityDisplayTest.php
Tests that vocabulary displays are ignored appropriately.

... See full list

File

core/modules/migrate/tests/src/Kernel/MigrateTestBase.php, line 241

Class

MigrateTestBase
Creates abstract base class for migration tests.

Namespace

Drupal\Tests\migrate\Kernel

Code

protected function mockFailure($migration, array $row, $status = MigrateIdMapInterface::STATUS_FAILED) {
  if (is_string($migration)) {
    $migration = $this
      ->getMigration($migration);
  }

  /** @var \Drupal\migrate\Plugin\MigrationInterface $migration */
  $destination = array_map(function () {
    return NULL;
  }, $migration
    ->getDestinationPlugin()
    ->getIds());
  $row = new Row($row, $migration
    ->getSourcePlugin()
    ->getIds());
  $migration
    ->getIdMap()
    ->saveIdMapping($row, $destination, $status);
}