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

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

namespace Drupal\Tests\l10n_migrate\Kernel;

/**
 * Test l10n_server_file migration.
 *
 * @group l10n_migrate
 */
class MigrateL10nServerFileTest extends MigrateL10nTestBase {

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

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

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

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

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

  /**
   * {@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 entity id is string, should be integer.
      $this->assertSame($dataset['fid'], (int) $entity->id());
      $this->assertSame($dataset['pid'], $entity->getProjectId());
      $this->assertSame($dataset['rid'], $entity->getReleaseId());
      $this->assertSame($dataset['location'], $entity->getLocation());
      $this->assertSame($dataset['revision'], $entity->getRevision());
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function expectedDataTable(): array {
    return [
      0 => [
        'fid' => 42641506,
        'rid' => 541088,
        'location' => 'drupal-10.0.0/autoload.php',
        'revision' => 'drupal-10.0.0/autoload.php: n/a',
        'pid' => 2,
      ],
    ];
  }

}

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

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