function MigrateExecutableTest::providerTestRollback

Same name in other branches
  1. 9 core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::providerTestRollback()
  2. 11.x core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php \Drupal\Tests\migrate\Unit\MigrateExecutableTest::providerTestRollback()

Data provider for ::testRollback.

Return value

array The test cases.

File

core/modules/migrate/tests/src/Unit/MigrateExecutableTest.php, line 513

Class

MigrateExecutableTest
@coversDefaultClass \Drupal\migrate\MigrateExecutable @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public static function providerTestRollback() {
    return [
        'Rollback delete' => [
            'id_map_records' => [
                [
                    'source' => '1',
                    'destination' => '1',
                    'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
                ],
            ],
        ],
        'Rollback preserve' => [
            'id_map_records' => [
                [
                    'source' => '1',
                    'destination' => '1',
                    'rollback_action' => MigrateIdMapInterface::ROLLBACK_PRESERVE,
                ],
            ],
            'rollback_called' => FALSE,
        ],
        'Rolling back a failed row' => [
            'id_map_records' => [
                [
                    'source' => '1',
                    'destination' => NULL,
                    'source_row_status' => '2',
                    'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
                ],
            ],
            'rollback_called' => FALSE,
        ],
        'Rolling back with ID map having records with duplicated destination ID' => [
            'id_map_records' => [
                [
                    'source_1' => '1',
                    'source_2' => '1',
                    'destination' => '1',
                    'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
                ],
                [
                    'source_1' => '2',
                    'source_2' => '2',
                    'destination' => '2',
                    'rollback_action' => MigrateIdMapInterface::ROLLBACK_PRESERVE,
                ],
                [
                    'source_1' => '3',
                    'source_2' => '3',
                    'destination' => '1',
                    'rollback_action' => MigrateIdMapInterface::ROLLBACK_DELETE,
                ],
            ],
            'rollback_called' => TRUE,
            'source_id_keys' => [
                'source_1',
                'source_2',
            ],
        ],
        'Rollback NULL' => [
            'id_map_records' => [
                [
                    'source' => '1',
                    'destination' => '1',
                    'rollback_action' => NULL,
                ],
            ],
        ],
        'Rollback missing' => [
            'id_map_records' => [
                [
                    'source' => '1',
                    'destination' => '1',
                ],
            ],
        ],
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.