You are here

protected function MigrateFieldFormatterSettingsTest::setUp in Zircon Profile 8

Same name in this branch
  1. 8 core/modules/field/src/Tests/Migrate/d6/MigrateFieldFormatterSettingsTest.php \Drupal\field\Tests\Migrate\d6\MigrateFieldFormatterSettingsTest::setUp()
  2. 8 core/modules/field/src/Tests/Migrate/d7/MigrateFieldFormatterSettingsTest.php \Drupal\field\Tests\Migrate\d7\MigrateFieldFormatterSettingsTest::setUp()
Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/Migrate/d7/MigrateFieldFormatterSettingsTest.php \Drupal\field\Tests\Migrate\d7\MigrateFieldFormatterSettingsTest::setUp()

Performs setup tasks before each individual test method is run.

Overrides MigrateDrupal7TestBase::setUp

File

core/modules/field/src/Tests/Migrate/d7/MigrateFieldFormatterSettingsTest.php, line 39
Contains \Drupal\field\Tests\Migrate\d7\MigrateFieldFormatterSettingsTest.

Class

MigrateFieldFormatterSettingsTest
Tests migration of D7 field formatter settings.

Namespace

Drupal\field\Tests\Migrate\d7

Code

protected function setUp() {
  parent::setUp();
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('comment');
  $this
    ->installEntitySchema('taxonomy_term');
  CommentType::create([
    'id' => 'comment_node_page',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  CommentType::create([
    'id' => 'comment_node_article',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  CommentType::create([
    'id' => 'comment_node_blog',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  CommentType::create([
    'id' => 'comment_node_book',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  CommentType::create([
    'id' => 'comment_node_forum',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  CommentType::create([
    'id' => 'comment_node_test_content_type',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  NodeType::create([
    'type' => 'page',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  NodeType::create([
    'type' => 'article',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  NodeType::create([
    'type' => 'blog',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  NodeType::create([
    'type' => 'book',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  NodeType::create([
    'type' => 'forum',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();
  NodeType::create([
    'type' => 'test_content_type',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();

  // Give one unfortunate field instance invalid display settings to ensure
  // that the migration provides an empty array as a default (thus avoiding
  // an "unsupported operand types" fatal).
  Database::getConnection('default', 'migrate')
    ->update('field_config_instance')
    ->fields(array(
    'data' => serialize(array(
      'label' => 'Body',
      'widget' => array(
        'type' => 'text_textarea_with_summary',
        'settings' => array(
          'rows' => 20,
          'summary_rows' => 5,
        ),
        'weight' => -4,
        'module' => 'text',
      ),
      'settings' => array(
        'display_summary' => true,
        'text_processing' => 1,
        'user_register_form' => false,
      ),
      'display' => array(
        'default' => array(
          'label' => 'hidden',
          'type' => 'text_default',
          'settings' => array(),
          'module' => 'text',
          'weight' => 0,
        ),
        'teaser' => array(
          'label' => 'hidden',
          'type' => 'text_summary_or_trimmed',
          // settings is always expected to be an array. Making it NULL
          // causes a fatal.
          'settings' => NULL,
          'module' => 'text',
          'weight' => 0,
        ),
      ),
      'required' => false,
      'description' => '',
    )),
  ))
    ->condition('entity_type', 'node')
    ->condition('bundle', 'article')
    ->condition('field_name', 'body')
    ->execute();
  $this
    ->executeMigrations([
    'd7_field',
    'd7_field_instance',
    'd7_view_modes',
    'd7_field_formatter_settings',
  ]);
}