function MigrateSourceTest::testPreRollback

@covers ::preRollback

File

core/modules/migrate/tests/src/Unit/MigrateSourceTest.php, line 455

Class

MigrateSourceTest
@coversDefaultClass \Drupal\migrate\Plugin\migrate\source\SourcePluginBase @group migrate

Namespace

Drupal\Tests\migrate\Unit

Code

public function testPreRollback() : void {
    $this->migrationConfiguration['id'] = 'test_migration';
    $plugin_id = 'test_migration';
    $migration = $this->getMigration();
    // Verify that preRollback() sets the high water mark to NULL.
    $key_value = $this->createMock(KeyValueStoreInterface::class);
    $key_value->expects($this->once())
        ->method('set')
        ->with($plugin_id, NULL);
    $key_value_factory = $this->createMock(KeyValueFactoryInterface::class);
    $key_value_factory->expects($this->once())
        ->method('get')
        ->with('migrate:high_water')
        ->willReturn($key_value);
    $container = new ContainerBuilder();
    $container->set('keyvalue', $key_value_factory);
    \Drupal::setContainer($container);
    $source = new StubSourceGeneratorPlugin([], $plugin_id, [], $migration);
    $source->preRollback(new MigrateRollbackEvent($migration));
}

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