l10n_server-2.x-dev/l10n_migrate/tests/src/Kernel/MigrateL10nServerReleaseTest.php
l10n_migrate/tests/src/Kernel/MigrateL10nServerReleaseTest.php
<?php namespace Drupal\Tests\l10n_migrate\Kernel; /** * Test l10n_server_release migration. * * @group l10n_migrate */ class MigrateL10nServerReleaseTest extends MigrateL10nTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'node', 'l10n_migrate', 'l10n_server', 'migrate', 'migrate_plus', 'text', 'taxonomy', ]; /** * The entity type. */ const ENTITY_TYPE = 'l10n_server_release'; /** * The entity class. */ const ENTITY_CLASS = 'Drupal\l10n_server\Entity\L10nServerRelease'; /** * The database fields in Drupal 7. */ const DATABASE_FIELDS_D7 = [ 'rid', 'pid', 'title', 'download_link', 'file_date', 'file_hash', 'last_parsed', 'weight', 'sid_count', ]; /** * The database fields in Drupal 10. */ const DATABASE_FIELDS_D10 = [ 'rid', 'pid', 'title', 'download_link', 'file_date', 'file_hash', 'last_parsed', 'weight', 'sid_count', ]; /** * {@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 id is string, should be integer. $this->assertSame($dataset['rid'], (int) $entity->id()); $this->assertSame($dataset['pid'], $entity->getProjectId()); $this->assertSame($dataset['title'], $entity->getVersion()); $this->assertSame($dataset['download_link'], $entity->getDownloadLink()); $this->assertSame($dataset['file_date'], $entity->getFileDate()); // @todo Fix file_hash is null, should be string. $this->assertSame($dataset['file_hash'], (string) $entity->getFileHash()); $this->assertSame($dataset['last_parsed'], $entity->getLastParsed()); $this->assertSame($dataset['weight'], $entity->getWeight()); $this->assertSame($dataset['sid_count'], $entity->getSourceStringCount()); } } /** * {@inheritdoc} */ public static function expectedDataTable(): array { return [ 0 => [ 'rid' => 541088, 'pid' => 2, 'title' => '10.0.0', 'download_link' => 'http://ftp.drupal.org/files/projects/drupal-10.0.0.tar.gz', 'file_date' => 1671125634, 'file_hash' => '', 'last_parsed' => 1671216724, 'weight' => 0, 'sid_count' => 10447, ], ]; } }