RollbackViewModesTest.php in Drupal 8
File
core/modules/field/tests/src/Kernel/Migrate/d7/RollbackViewModesTest.php
View source
<?php
namespace Drupal\Tests\field\Kernel\Migrate\d7;
use Drupal\Core\Entity\Entity\EntityViewMode;
use Drupal\migrate\MigrateExecutable;
class RollbackViewModesTest extends MigrateViewModesTest {
public static $modules = [
'text',
];
public function testMigration() {
parent::testMigration();
$this
->executeRollback('d7_view_modes');
$view_mode_ids = [
'comment.full',
'node.teaser',
'node.full',
'user.full',
];
foreach ($view_mode_ids as $view_mode_id) {
$this
->assertNull(EntityViewMode::load($view_mode_id));
}
}
protected function executeRollback($migration) {
if (is_string($migration)) {
$this->migration = $this
->getMigration($migration);
}
else {
$this->migration = $migration;
}
(new MigrateExecutable($this->migration, $this))
->rollback();
}
}