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

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

namespace Drupal\Tests\l10n_migrate\Kernel;

/**
 * Test l10n_server_string migration.
 *
 * @group l10n_migrate
 */
class MigrateL10nServerStringTest extends MigrateL10nTestBase {

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

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

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

  /**
   * The database fields in Drupal 7.
   */
  const DATABASE_FIELDS_D7 = [
    'sid',
    'value',
    'context',
    'hashkey',
  ];

  /**
   * The database fields in Drupal 10.
   */
  const DATABASE_FIELDS_D10 = [
    'sid',
    'value',
    'context',
    'hashkey',
  ];

  /**
   * {@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);
      // @todo Fix type id is string, should be integer.
      $this->assertSame($dataset['sid'], (int) $entity->id());
      $this->assertSame($dataset['value'], $entity->getValue());
      $this->assertSame($dataset['context'], $entity->getContext());
      $this->assertSame($dataset['hashkey'], $entity->getHashkey());
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function expectedDataTable(): array {
    return [
      0 => [
        'sid' => 20842,
        'value' => '@site is currently under maintenance. We should be back shortly. Thank you for your patience.',
        'context' => 'none',
        'hashkey' => 'df8842de0a61a8e2f5e9be85d32f3139',
      ],
    ];
  }

}

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

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