Same name and namespace in other branches
  1. 8.9.x core/modules/field/tests/src/Kernel/Migrate/d7/RollbackFieldInstanceTest.php \Drupal\Tests\field\Kernel\Migrate\d7\RollbackFieldInstanceTest
  2. 9 core/modules/field/tests/src/Kernel/Migrate/d7/RollbackFieldInstanceTest.php \Drupal\Tests\field\Kernel\Migrate\d7\RollbackFieldInstanceTest

Migrates and rolls back Drupal 7 fields.

@group field

Hierarchy

Expanded class hierarchy of RollbackFieldInstanceTest

File

core/modules/field/tests/src/Kernel/Migrate/d7/RollbackFieldInstanceTest.php, line 15

Namespace

Drupal\Tests\field\Kernel\Migrate\d7
View source
class RollbackFieldInstanceTest extends MigrateFieldInstanceTest {

  /**
   * Tests migrating D7 fields to field_storage_config entities, then rolling back.
   */
  public function testFieldInstances() {

    // Test that the field instances have migrated (prior to rollback).
    parent::testFieldInstances();
    $this
      ->executeRollback('d7_field_instance');
    $this
      ->executeRollback('d7_field');

    // Check that field instances have been rolled back.
    $field_instance_ids = [
      'comment.comment_node_page.comment_body',
      'node.page.body',
      'comment.comment_node_article.comment_body',
      'node.article.body',
      'node.article.field_tags',
      'node.article.field_image',
      'comment.comment_node_blog.comment_body',
      'node.blog.body',
      'comment.comment_node_book.comment_body',
      'node.book.body',
      'node.forum.taxonomy_forums',
      'comment.comment_forum.comment_body',
      'node.forum.body',
      'comment.comment_node_test_content_type.comment_body',
      'node.test_content_type.field_boolean',
      'node.test_content_type.field_email',
      'node.test_content_type.field_phone',
      'node.test_content_type.field_date',
      'node.test_content_type.field_date_with_end_time',
      'node.test_content_type.field_file',
      'node.test_content_type.field_float',
      'node.test_content_type.field_images',
      'node.test_content_type.field_integer',
      'node.test_content_type.field_link',
      'node.test_content_type.field_text_list',
      'node.test_content_type.field_integer_list',
      'node.test_content_type.field_long_text',
      'node.test_content_type.field_term_reference',
      'node.test_content_type.field_text',
      'comment.comment_node_test_content_type.field_integer',
      'user.user.field_file',
    ];
    foreach ($field_instance_ids as $field_instance_id) {
      $this
        ->assertNull(FieldConfig::load($field_instance_id));
    }
  }

  /**
   * Executes a single rollback.
   *
   * @param string|\Drupal\migrate\Plugin\MigrationInterface $migration
   *   The migration to rollback, or its ID.
   */
  protected function executeRollback($migration) {
    if (is_string($migration)) {
      $this->migration = $this
        ->getMigration($migration);
    }
    else {
      $this->migration = $migration;
    }
    (new MigrateExecutable($this->migration, $this))
      ->rollback();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MigrateDrupal7TestBase::getFixtureFilePath protected function Gets the path to the fixture file. 8
MigrateDrupal7TestBase::migrateCommentTypes protected function Migrates comment types.
MigrateDrupal7TestBase::migrateContent protected function Executes all content migrations.
MigrateDrupal7TestBase::migrateContentTypes protected function Migrates node types.
MigrateDrupal7TestBase::migrateFields protected function Executes all field migrations.
MigrateDrupal7TestBase::migrateTaxonomyTerms protected function Executes all taxonomy term migrations.
MigrateDrupal7TestBase::migrateUsers protected function Executes all user migrations.
MigrateDrupalTestBase::loadFixture protected function Loads a database fixture into the source database connection.
MigrateFieldInstanceTest::$modules protected static property Modules to enable. Overrides MigrateDrupalTestBase::$modules
MigrateFieldInstanceTest::assertEntity protected function Asserts various aspects of a field config entity.
MigrateFieldInstanceTest::assertEntityReferenceFields protected function Asserts the settings of an entity reference field config entity.
MigrateFieldInstanceTest::assertLinkFields protected function Asserts the settings of a link field config entity.
MigrateFieldInstanceTest::setUp protected function Overrides MigrateDrupal7TestBase::setUp
MigrateTestBase::$collectMessages protected property TRUE to collect messages instead of displaying them.
MigrateTestBase::$logger protected property A logger prophecy object. 2
MigrateTestBase::$migrateMessages protected property A two dimensional array of messages.
MigrateTestBase::$migration protected property The primary migration being tested. 1
MigrateTestBase::$sourceDatabase protected property The source database connection.
MigrateTestBase::cleanupMigrateConnection private function Cleans up the test migrate connection.
MigrateTestBase::createMigrationConnection private function Changes the database connection to the prefixed one.
MigrateTestBase::display public function Displays a migrate message. Overrides MigrateMessageInterface::display
MigrateTestBase::executeMigration protected function Executes a single migration.
MigrateTestBase::executeMigrations protected function Executes a set of migrations in dependency order.
MigrateTestBase::getMigration protected function Gets the migration plugin.
MigrateTestBase::mockFailure protected function Records a failure in the map table of a specific migration.
MigrateTestBase::prepareMigration protected function Modify a migration's configuration before executing it.
MigrateTestBase::prepareMigrations protected function Prepare any dependent migrations.
MigrateTestBase::setTestLogger protected function Injects the test logger into the container.
MigrateTestBase::startCollectingMessages public function Start collecting messages and erase previous messages.
MigrateTestBase::stopCollectingMessages public function Stop collecting messages.
MigrateTestBase::tearDown protected function
NodeMigrateTypeTestTrait::$tableName public property The migrate_map table name.
NodeMigrateTypeTestTrait::getTableName protected function Gets the migrate_map table name.
NodeMigrateTypeTestTrait::makeNodeMigrateMapTable protected function Create a node migrate_map table.
NodeMigrateTypeTestTrait::nodeMigrateMapTableCount protected function Gets the numbers of complete and classic node migrate_map tables.
NodeMigrateTypeTestTrait::removeNodeMigrateMapTable protected function Remove the node migrate map table.
RollbackFieldInstanceTest::executeRollback protected function Executes a single rollback.
RollbackFieldInstanceTest::testFieldInstances public function Tests migrating D7 fields to field_storage_config entities, then rolling back. Overrides MigrateFieldInstanceTest::testFieldInstances