function MigrateExecutableTest::providerTestRollback

Same name in other branches
  1. 10 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 450

Class

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

Namespace

Drupal\Tests\migrate\Unit

Code

public 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.