public function MigrateTableTest::testTableRollback in Migrate Plus 8.3
Same name and namespace in other branches
- 8.4 tests/src/Kernel/MigrateTableTest.php \Drupal\Tests\migrate_plus\Kernel\MigrateTableTest::testTableRollback()
File
- tests/
src/ Kernel/ MigrateTableTest.php, line 110
Class
- MigrateTableTest
- Tests migration destination table.
Namespace
Drupal\Tests\migrate_plus\KernelCode
public function testTableRollback() {
$this
->testTableDestination();
/** @var MigrationInterface $migration */
$migration = \Drupal::service('plugin.manager.migration')
->createStubMigration($this
->getTableDestinationMigration());
$executable = new MigrateExecutable($migration, $this);
$executable
->import();
$values = $this->connection
->select(static::TABLE_NAME)
->fields(static::TABLE_NAME)
->execute()
->fetchAllAssoc('data');
$this
->assertEquals('dummy value', $values['dummy value']->data);
$this
->assertEquals(3, count($values));
// Now rollback.
$executable
->rollback();
$values = $this->connection
->select(static::TABLE_NAME)
->fields(static::TABLE_NAME)
->execute()
->fetchAllAssoc('data');
$this
->assertEquals(0, count($values));
}