l10n_server-2.x-dev/l10n_migrate/tests/src/Kernel/MigrateL10nServerStatusFlagTest.php

l10n_migrate/tests/src/Kernel/MigrateL10nServerStatusFlagTest.php
<?php

namespace Drupal\Tests\l10n_migrate\Kernel;

/**
 * Test l10n_server_status_flag migration.
 *
 * @group l10n_migrate
 */
class MigrateL10nServerStatusFlagTest extends MigrateL10nTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'node',
    'l10n_migrate',
    'l10n_server',
    'migrate',
    'migrate_plus',
    'text',
    'taxonomy',
  ];

  /**
   * The entity type.
   */
  const ENTITY_TYPE = 'l10n_server_status_flag';

  /**
   * The entity class.
   */
  const ENTITY_CLASS = 'Drupal\l10n_server\Entity\L10nServerStatusFlag';

  /**
   * The database fields in Drupal 7.
   */
  const DATABASE_FIELDS_D7 = [
    'sid',
    'language',
    'has_suggestion',
    'has_translation',
  ];

  /**
   * The database fields in Drupal 10.
   */
  const DATABASE_FIELDS_D10 = [
    'sid',
    'language',
    'has_suggestion',
    'has_translation',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp(): void {
    parent::setUp();
    $this->executeMigrations([static::ENTITY_TYPE]);
  }

  /**
   * {@inheritdoc}
   */
  protected function assertEntityAttributesValid(): void {
    $datasets = static::expectedDataTable();
    $entities = $this->entityStorage->loadMultiple();
    foreach ($entities as $entity) {
      $dataset = array_shift($datasets);
      $this->assertSame($dataset['sid'], $entity->getStringId());
      $this->assertSame($dataset['language'], $entity->getLanguage());
      $this->assertSame((bool) $dataset['has_suggestion'], $entity->hasSuggestionString());
      $this->assertSame((bool) $dataset['has_translation'], $entity->hasTranslationString());
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function expectedDataTable(): array {
    return [
      0 => [
        'sid' => 20,
        'language' => 'de',
        'has_suggestion' => 0,
        'has_translation' => 1,
      ],
    ];
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc