View source
<?php
namespace Drupal\Tests\migrate_drupal_ui\Functional\d6;
use Drupal\node\Entity\Node;
use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeExecuteTestBase;
use Drupal\user\Entity\User;
class Upgrade6Test extends MigrateUpgradeExecuteTestBase {
public static $modules = [
'language',
'content_translation',
'config_translation',
'migrate_drupal_ui',
'telephone',
'aggregator',
'book',
'forum',
'statistics',
'migration_provider_test',
];
protected $nodeStorage;
protected function setUp() {
parent::setUp();
$this->nodeStorage = $this->container
->get('entity_type.manager')
->getStorage('node');
$this->nodeStorage
->delete($this->nodeStorage
->loadMultiple());
$this
->loadFixture(drupal_get_path('module', 'migrate_drupal') . '/tests/fixtures/drupal6.php');
}
protected function getSourceBasePath() {
return __DIR__ . '/files';
}
protected function getEntityCounts() {
return [
'aggregator_item' => 1,
'aggregator_feed' => 2,
'block' => 34,
'block_content' => 2,
'block_content_type' => 1,
'comment' => 8,
'comment_type' => 13,
'contact_form' => 5,
'contact_message' => 0,
'configurable_language' => 5,
'editor' => 2,
'field_config' => 95,
'field_storage_config' => 66,
'file' => 7,
'filter_format' => 7,
'image_style' => 5,
'language_content_settings' => 15,
'node' => 18,
'node_type' => 13,
'rdf_mapping' => 7,
'search_page' => 2,
'shortcut' => 2,
'shortcut_set' => 1,
'action' => 25,
'menu' => 8,
'path_alias' => 8,
'taxonomy_term' => 15,
'taxonomy_vocabulary' => 7,
'tour' => 5,
'user' => 7,
'user_role' => 6,
'menu_link_content' => 10,
'view' => 16,
'date_format' => 11,
'entity_form_display' => 29,
'entity_form_mode' => 1,
'entity_view_display' => 58,
'entity_view_mode' => 14,
'base_field_override' => 38,
];
}
protected function getEntityCountsIncremental() {
$counts = $this
->getEntityCounts();
$counts['block_content'] = 3;
$counts['comment'] = 9;
$counts['entity_view_display'] = 58;
$counts['entity_view_mode'] = 14;
$counts['file'] = 8;
$counts['menu_link_content'] = 11;
$counts['node'] = 19;
$counts['taxonomy_term'] = 16;
$counts['user'] = 8;
$counts['view'] = 16;
return $counts;
}
protected function getAvailablePaths() {
return [
'aggregator',
'block',
'book',
'comment',
'contact',
'content',
'date',
'email',
'filefield',
'filter',
'forum',
'i18nblocks',
'i18ncontent',
'i18nmenu',
'i18nprofile',
'i18nsync',
'imagecache',
'imagefield',
'menu',
'node',
'nodereference',
'optionwidgets',
'path',
'search',
'statistics',
'system',
'taxonomy',
'text',
'translation',
'upload',
'user',
'userreference',
'date_api',
'date_timezone',
'event',
'imageapi',
'number',
'php',
'profile',
'variable_admin',
];
}
protected function getMissingPaths() {
return [
'i18n',
'i18ncck',
'i18nstrings',
'i18ntaxonomy',
'locale',
];
}
public function testMigrateUpgradeExecute() {
parent::testMigrateUpgradeExecute();
$user = User::load(2);
$user->passRaw = 'john.doe_pass';
$this
->drupalLogin($user);
$this
->assertFollowUpMigrationResults();
}
protected function assertFollowUpMigrationResults() {
$node = Node::load(10);
$this
->assertSame('12', $node
->get('field_reference')->target_id);
$this
->assertSame('12', $node
->get('field_reference_2')->target_id);
$translation = $node
->getTranslation('fr');
$this
->assertSame('12', $translation
->get('field_reference')->target_id);
$this
->assertSame('12', $translation
->get('field_reference_2')->target_id);
$node = Node::load(12)
->getTranslation('en');
$this
->assertSame('10', $node
->get('field_reference')->target_id);
$this
->assertSame('10', $node
->get('field_reference_2')->target_id);
$translation = $node
->getTranslation('fr');
$this
->assertSame('10', $translation
->get('field_reference')->target_id);
$this
->assertSame('10', $translation
->get('field_reference_2')->target_id);
}
}