public function MigrateNodeCompleteTest::testRollbackNodeComplete in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/tests/src/Kernel/Migrate/d7/MigrateNodeCompleteTest.php \Drupal\Tests\node\Kernel\Migrate\d7\MigrateNodeCompleteTest::testRollbackNodeComplete()
Tests rollback of the complete node migration.
File
- core/
modules/ node/ tests/ src/ Kernel/ Migrate/ d7/ MigrateNodeCompleteTest.php, line 154
Class
- MigrateNodeCompleteTest
- Test class for a complete node migration for Drupal 7.
Namespace
Drupal\Tests\node\Kernel\Migrate\d7Code
public function testRollbackNodeComplete() {
$db = \Drupal::database();
$node_types = [
'article',
'blog',
'book',
'forum',
'page',
'test_content_type',
];
foreach ($node_types as $node_type) {
// Execute the rollback.
$this->migration = $this
->getMigration("d7_node_complete:{$node_type}");
(new MigrateExecutable($this->migration, $this))
->rollback();
// Assert there are no nodes of node_type.
$count = $db
->select('node_field_data')
->condition('type', $node_type)
->countQuery()
->execute()
->fetchField();
$this
->assertSame($count, '0', "There are {$count} nodes of type {$node_type}");
}
}