function MigrateTestBase::mockFailure
Same name in other branches
- 8.9.x core/modules/migrate/tests/src/Kernel/MigrateTestBase.php \Drupal\Tests\migrate\Kernel\MigrateTestBase::mockFailure()
- 10 core/modules/migrate/tests/src/Kernel/MigrateTestBase.php \Drupal\Tests\migrate\Kernel\MigrateTestBase::mockFailure()
- 11.x 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 relationships are ignored for un-migrated nodes.
- 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.
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ MigrateTestBase.php, line 239
Class
- MigrateTestBase
- Creates abstract base class for migration tests.
Namespace
Drupal\Tests\migrate\KernelCode
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.