Unverified Commit 677f9d42 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3103031 by quietone, Wim Leers: Add missing test of field option translations for booleans

parent a5876a27
Loading
Loading
Loading
Loading
+80 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\field\Kernel\Migrate\d7;

use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;

/**
 * Migrate field instance option translations.
 *
 * @group migrate_drupal_7
 */
class MigrateFieldInstanceOptionTranslationTest extends MigrateDrupal7TestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'comment',
    'config_translation',
    'datetime',
    'file',
    'image',
    'language',
    'link',
    'locale',
    'menu_ui',
    'node',
    'system',
    'taxonomy',
    'telephone',
    'text',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->installConfig(['node']);
    $this->executeMigration('language');
    $this->migrateFields();
    $this->executeMigrations([
      'd7_field_option_translation',
      'd7_field_instance_option_translation',
    ]);
  }

  /**
   * Migrate field instance option translations.
   */
  public function testFieldInstanceOptionTranslation() {
    $language_manager = $this->container->get('language_manager');

    /** @var \Drupal\language\Config\LanguageConfigOverride $config_translation */
    $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.node.test_content_type.field_boolean');
    $this->assertNull($config_translation->get('settings'));

    $config_translation = $language_manager->getLanguageConfigOverride('is', 'field.field.node.test_content_type.field_boolean');
    $option_translation = [
      'off_label' => 'is - Off',
      'on_label' => 'is - 1',
    ];
    $this->assertSame($option_translation, $config_translation->get('settings'));

    $config_translation = $language_manager->getLanguageConfigOverride('fr', 'field.field.node.article.field_checkbox');
    $option_translation = [
      'off_label' => 'fr - Stop',
      'on_label' => 'Go',
    ];
    $this->assertSame($option_translation, $config_translation->get('settings'));

    $config_translation = $language_manager->getLanguageConfigOverride('is', 'field.field.node.article.field_checkbox');
    $option_translation = [
      'off_label' => 'is - Stop',
      'on_label' => 'is - Go',
    ];
    $this->assertSame($option_translation, $config_translation->get('settings'));
  }

}
+241 −0
Original line number Diff line number Diff line
@@ -4311,6 +4311,21 @@
  'translatable' => '0',
  'deleted' => '0',
))
->values(array(
  'id' => '53',
  'field_name' => 'field_checkbox',
  'type' => 'list_boolean',
  'module' => 'list',
  'active' => '1',
  'storage_type' => 'field_sql_storage',
  'storage_module' => 'field_sql_storage',
  'storage_active' => '1',
  'locked' => '0',
  'data' => 'a:7:{s:12:"translatable";i:0;s:12:"entity_types";a:0:{}s:8:"settings";a:3:{s:14:"allowed_values";a:2:{i:0;s:4:"Stop";i:1;s:2:"Go";}s:23:"allowed_values_function";s:0:"";s:23:"entity_translation_sync";b:0;}s:7:"storage";a:5:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";s:7:"details";a:1:{s:3:"sql";a:2:{s:18:"FIELD_LOAD_CURRENT";a:1:{s:25:"field_data_field_checkbox";a:1:{s:5:"value";s:20:"field_checkbox_value";}}s:19:"FIELD_LOAD_REVISION";a:1:{s:29:"field_revision_field_checkbox";a:1:{s:5:"value";s:20:"field_checkbox_value";}}}}}s:12:"foreign keys";a:0:{}s:7:"indexes";a:1:{s:5:"value";a:1:{i:0;s:5:"value";}}s:2:"id";s:2:"53";}',
  'cardinality' => '1',
  'translatable' => '0',
  'deleted' => '0',
))
->execute();
$connection->schema()->createTable('field_config_instance', array(
  'fields' => array(
@@ -5072,6 +5087,15 @@
  'data' => 'a:7:{s:5:"label";s:10:"Chancellor";s:6:"widget";a:5:{s:6:"weight";s:1:"1";s:4:"type";s:14:"text_textfield";s:6:"module";s:4:"text";s:6:"active";i:1;s:8:"settings";a:1:{s:4:"size";s:2:"60";}}s:8:"settings";a:2:{s:15:"text_processing";s:1:"0";s:18:"user_register_form";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"text_default";s:8:"settings";a:0:{}s:6:"module";s:4:"text";s:6:"weight";i:0;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
  'deleted' => '0',
))
->values(array(
  'id' => '82',
  'field_id' => '53',
  'field_name' => 'field_checkbox',
  'entity_type' => 'node',
  'bundle' => 'article',
  'data' => 'a:7:{s:5:"label";s:8:"checkbox";s:6:"widget";a:5:{s:6:"weight";s:2:"25";s:4:"type";s:15:"options_buttons";s:6:"module";s:7:"options";s:6:"active";i:1;s:8:"settings";a:0:{}}s:8:"settings";a:2:{s:18:"user_register_form";b:0;s:23:"entity_translation_sync";b:0;}s:7:"display";a:1:{s:7:"default";a:5:{s:5:"label";s:5:"above";s:4:"type";s:12:"list_default";s:8:"settings";a:0:{}s:6:"module";s:4:"list";s:6:"weight";i:25;}}s:8:"required";i:0;s:11:"description";s:0:"";s:13:"default_value";N;}',
  'deleted' => '0',
))
->execute();
$connection->schema()->createTable('field_data_body', array(
  'fields' => array(
@@ -5217,6 +5241,88 @@
  'body_format' => 'filtered_html',
))
->execute();
$connection->schema()->createTable('field_data_field_checkbox', array(
  'fields' => array(
    'entity_type' => array(
      'type' => 'varchar',
      'not null' => TRUE,
      'length' => '128',
      'default' => '',
    ),
    'bundle' => array(
      'type' => 'varchar',
      'not null' => TRUE,
      'length' => '128',
      'default' => '',
    ),
    'deleted' => array(
      'type' => 'int',
      'not null' => TRUE,
      'size' => 'tiny',
      'default' => '0',
    ),
    'entity_id' => array(
      'type' => 'int',
      'not null' => TRUE,
      'size' => 'normal',
      'unsigned' => TRUE,
    ),
    'revision_id' => array(
      'type' => 'int',
      'not null' => FALSE,
      'size' => 'normal',
      'unsigned' => TRUE,
    ),
    'language' => array(
      'type' => 'varchar',
      'not null' => TRUE,
      'length' => '32',
      'default' => '',
    ),
    'delta' => array(
      'type' => 'int',
      'not null' => TRUE,
      'size' => 'normal',
      'unsigned' => TRUE,
    ),
    'field_checkbox_value' => array(
      'type' => 'int',
      'not null' => FALSE,
      'size' => 'normal',
    ),
  ),
  'primary key' => array(
    'entity_type',
    'entity_id',
    'deleted',
    'delta',
    'language',
  ),
  'indexes' => array(
    'entity_type' => array(
      'entity_type',
    ),
    'bundle' => array(
      'bundle',
    ),
    'deleted' => array(
      'deleted',
    ),
    'entity_id' => array(
      'entity_id',
    ),
    'revision_id' => array(
      'revision_id',
    ),
    'language' => array(
      'language',
    ),
    'field_checkbox_value' => array(
      'field_checkbox_value',
    ),
  ),
  'mysql_character_set' => 'utf8',
));
$connection->schema()->createTable('field_data_comment_body', array(
  'fields' => array(
    'entity_type' => array(
@@ -11217,6 +11323,89 @@
  'field_chancellor_format' => NULL,
))
->execute();
$connection->schema()->createTable('field_revision_field_checkbox', array(
  'fields' => array(
    'entity_type' => array(
      'type' => 'varchar',
      'not null' => TRUE,
      'length' => '128',
      'default' => '',
    ),
    'bundle' => array(
      'type' => 'varchar',
      'not null' => TRUE,
      'length' => '128',
      'default' => '',
    ),
    'deleted' => array(
      'type' => 'int',
      'not null' => TRUE,
      'size' => 'tiny',
      'default' => '0',
    ),
    'entity_id' => array(
      'type' => 'int',
      'not null' => TRUE,
      'size' => 'normal',
      'unsigned' => TRUE,
    ),
    'revision_id' => array(
      'type' => 'int',
      'not null' => TRUE,
      'size' => 'normal',
      'unsigned' => TRUE,
    ),
    'language' => array(
      'type' => 'varchar',
      'not null' => TRUE,
      'length' => '32',
      'default' => '',
    ),
    'delta' => array(
      'type' => 'int',
      'not null' => TRUE,
      'size' => 'normal',
      'unsigned' => TRUE,
    ),
    'field_checkbox_value' => array(
      'type' => 'int',
      'not null' => FALSE,
      'size' => 'normal',
    ),
  ),
  'primary key' => array(
    'entity_type',
    'entity_id',
    'revision_id',
    'deleted',
    'delta',
    'language',
  ),
  'indexes' => array(
    'entity_type' => array(
      'entity_type',
    ),
    'bundle' => array(
      'bundle',
    ),
    'deleted' => array(
      'deleted',
    ),
    'entity_id' => array(
      'entity_id',
    ),
    'revision_id' => array(
      'revision_id',
    ),
    'language' => array(
      'language',
    ),
    'field_checkbox_value' => array(
      'field_checkbox_value',
    ),
  ),
  'mysql_character_set' => 'utf8',
));
$connection->schema()->createTable('field_revision_field_color', array(
  'fields' => array(
    'entity_type' => array(
@@ -18306,6 +18495,26 @@
  'objectindex' => '0',
  'format' => '',
))
->values(array(
  'lid' => '797',
  'textgroup' => 'field',
  'context' => 'field_checkbox:#allowed_values:0',
  'objectid' => '#allowed_values',
  'type' => 'field_checkbox',
  'property' => '0',
  'objectindex' => '0',
  'format' => '',
))
->values(array(
  'lid' => '798',
  'textgroup' => 'field',
  'context' => 'field_checkbox:#allowed_values:1',
  'objectid' => '#allowed_values',
  'type' => 'field_checkbox',
  'property' => '1',
  'objectindex' => '0',
  'format' => '',
))
->values(array(
  'lid' => '194',
  'textgroup' => 'field',
@@ -19904,6 +20113,38 @@
  'plural' => '0',
  'i18n_status' => '0',
))
->values(array(
  'lid' => '797',
  'translation' => 'is - Stop',
  'language' => 'is',
  'plid' => '0',
  'plural' => '0',
  'i18n_status' => '0',
))
->values(array(
  'lid' => '798',
  'translation' => 'is - Go',
  'language' => 'is',
  'plid' => '0',
  'plural' => '0',
  'i18n_status' => '0',
))
->values(array(
  'lid' => '797',
  'translation' => 'fr - Stop',
  'language' => 'fr',
  'plid' => '0',
  'plural' => '0',
  'i18n_status' => '0',
))
->values(array(
  'lid' => '798',
  'translation' => 'Go',
  'language' => 'fr',
  'plid' => '0',
  'plural' => '0',
  'i18n_status' => '0',
))
->execute();
$connection->schema()->createTable('menu_custom', array(
  'fields' => array(
+2 −2
Original line number Diff line number Diff line
@@ -74,8 +74,8 @@ protected function getEntityCounts() {
      'contact_form' => 3,
      'contact_message' => 0,
      'editor' => 2,
      'field_config' => 76,
      'field_storage_config' => 58,
      'field_config' => 77,
      'field_storage_config' => 59,
      'file' => 3,
      'filter_format' => 7,
      'image_style' => 6,