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

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

namespace Drupal\Tests\l10n_migrate\Kernel;

/**
 * Test l10n_server_line migration.
 *
 * @group l10n_migrate
 */
class MigrateL10nServerLineTest extends MigrateL10nTestBase {

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

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

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

  /**
   * The database fields in Drupal 7.
   */
  const DATABASE_FIELDS_D7 = [
    'fid',
    'lineno',
    'type',
    'sid',
    'pid',
    'rid',
  ];

  /**
   * The database fields in Drupal 10.
   */
  const DATABASE_FIELDS_D10 = [
    'fid',
    'lineno',
    'type',
    'sid',
    'pid',
    'rid',
  ];

  /**
   * {@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['fid'], $entity->getFileId());
      $this->assertSame($dataset['lineno'], $entity->getLineNumber());
      // @todo Fix type id is string, should be integer.
      $this->assertSame($dataset['type'], (int) $entity->getType());
      $this->assertSame($dataset['sid'], $entity->getStringId());
      $this->assertSame($dataset['pid'], $entity->getProjectId());
      $this->assertSame($dataset['rid'], $entity->getReleaseId());
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function expectedDataTable(): array {
    return [
      0 => [
        'fid' => 42649999,
        'lineno' => 0,
        'type' => 2,
        'sid' => 10834,
        'pid' => 68002,
        'rid' => 541099,
      ],
    ];
  }

}

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

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