l10n_server-2.x-dev/l10n_migrate/tests/src/Kernel/MigrateL10nServerGroupTest.php
l10n_migrate/tests/src/Kernel/MigrateL10nServerGroupTest.php
<?php namespace Drupal\Tests\l10n_migrate\Kernel; /** * Test l10n_server_group migration. * * @group l10n_migrate */ class MigrateL10nServerGroupTest extends MigrateL10nTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'group', 'node', 'flexible_permissions', 'l10n_migrate', 'l10n_packager', 'l10n_server', 'language', 'locale', 'migrate', 'migrate_plus', 'text', 'taxonomy', 'variationcache', ]; /** * The entity type. */ const ENTITY_TYPE = 'group'; /** * The entity class. */ const ENTITY_CLASS = 'Drupal\group\Entity\Group'; /** * The database fields in Drupal 7. */ const DATABASE_FIELDS_D7 = [ 'nid', 'vid', 'type', 'language', 'title', 'uid', 'status', 'created', 'changed', 'comment', 'promote', 'sticky', 'tnid', 'translate', ]; /** * The database fields in Drupal 10. */ const DATABASE_FIELDS_D10 = [ 'id', 'revision_id', 'type', 'langcode', 'status', 'uid', 'label', 'created', 'changed', 'default_langcode', 'revision_translation_affected', ]; /** * {@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['nid'], $entity->id()); $this->assertSame($dataset['title'], $entity->label()); $this->assertSame($dataset['created'], $entity->getCreatedTime()); $this->assertSame($dataset['changed'], $entity->getChangedTime()); } } /** * {@inheritdoc} */ public static function expectedDataTable(): array { return [ 0 => [ 'nid' => '158', 'vid' => '22718', 'type' => 'l10n_group', 'language' => 'en', 'title' => 'Hungarian team', 'uid' => '168279', 'status' => '1', 'created' => '1253794384', 'changed' => '1439317088', 'comment' => '0', 'promote' => '0', 'sticky' => '0', 'tnid' => '0', 'translate' => '0', ], 1 => [ 'nid' => '978', 'vid' => '83138', 'type' => 'l10n_group', 'language' => 'en', 'title' => 'German team', 'uid' => '3938', 'status' => '1', 'created' => '1266764260', 'changed' => '1608577056', 'comment' => '1', 'promote' => '0', 'sticky' => '0', 'tnid' => '0', 'translate' => '0', ], 2 => [ 'nid' => '78', 'vid' => '83173', 'type' => 'l10n_group', 'language' => 'en', 'title' => 'French team', 'uid' => '372', 'status' => '1', 'created' => '1251900992', 'changed' => '1645452938', 'comment' => '1', 'promote' => '1', 'sticky' => '1', 'tnid' => '0', 'translate' => '0', ], 3 => [ 'nid' => '144', 'vid' => '82574', 'type' => 'l10n_group', 'language' => 'en', 'title' => 'Catalan team - Equip català', 'uid' => '862', 'status' => '1', 'created' => '1253536589', 'changed' => '1476886577', 'comment' => '1', 'promote' => '0', 'sticky' => '0', 'tnid' => '0', 'translate' => '0', ], 4 => [ 'nid' => '1753', 'vid' => '6193', 'type' => 'l10n_group', 'language' => 'en', 'title' => 'Esperanto team', 'uid' => '120', 'status' => '1', 'created' => '1276098281', 'changed' => '1439317088', 'comment' => '0', 'promote' => '0', 'sticky' => '0', 'tnid' => '0', 'translate' => '0', ], ]; } }