l10n_server-2.x-dev/l10n_migrate/tests/src/Kernel/MigrateL10nServerProjectTest.php
l10n_migrate/tests/src/Kernel/MigrateL10nServerProjectTest.php
<?php namespace Drupal\Tests\l10n_migrate\Kernel; /** * Test l10n_server_project migration. * * @group l10n_migrate */ class MigrateL10nServerProjectTest extends MigrateL10nTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'node', 'l10n_migrate', 'l10n_server', 'migrate', 'migrate_plus', 'text', 'taxonomy', ]; /** * The entity type. */ const ENTITY_TYPE = 'l10n_server_project'; /** * The entity class. */ const ENTITY_CLASS = 'Drupal\l10n_server\Entity\L10nServerProject'; /** * The database fields in Drupal 7. */ const DATABASE_FIELDS_D7 = [ 'pid', 'uri', 'title', 'home_link', 'last_parsed', 'connector_module', 'status', 'weight', ]; /** * The database fields in Drupal 10. */ const DATABASE_FIELDS_D10 = [ 'pid', 'uri', 'title', 'homepage', 'last_parsed', 'connector_module', 'status', 'weight', ]; /** * {@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['pid'], (int) $entity->id()); $this->assertSame($dataset['uri'], $entity->getUri()); $this->assertSame($dataset['title'], $entity->getTitle()); $this->assertSame($dataset['home_link'], $entity->getHomepage()); $this->assertSame($dataset['last_parsed'], $entity->getLastParsed()); $this->assertSame($dataset['connector_module'], $entity->getConnectorModule()); $this->assertSame($dataset['status'], $entity->getStatus()); $this->assertSame($dataset['weight'], $entity->getWeight()); } } /** * {@inheritdoc} */ public static function expectedDataTable(): array { return [ 0 => [ 'pid' => 2, 'uri' => 'drupal', 'title' => 'Drupal core', 'home_link' => 'http://drupal.org/project/drupal', 'last_parsed' => 1329767486, 'connector_module' => 'l10n_project_drupalorg', 'status' => 1, 'weight' => -939281, ], ]; } }