View source
<?php
namespace Drupal\Tests\migrate_drupal_ui\Functional\d7;
use Drupal\node\Entity\Node;
use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeExecuteTestBase;
use Drupal\user\Entity\User;
class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
public static $modules = [
'file',
'language',
'config_translation',
'content_translation',
'migrate_drupal_ui',
'telephone',
'aggregator',
'book',
'forum',
'rdf',
'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/drupal7.php');
}
protected function getSourceBasePath() {
return __DIR__ . '/files';
}
protected function getEntityCounts() {
return [
'aggregator_item' => 11,
'aggregator_feed' => 1,
'block' => 25,
'block_content' => 1,
'block_content_type' => 1,
'comment' => 4,
'comment_type' => 8,
'configurable_language' => 5,
'contact_form' => 3,
'contact_message' => 0,
'editor' => 2,
'field_config' => 81,
'field_storage_config' => 62,
'file' => 3,
'filter_format' => 7,
'image_style' => 6,
'language_content_settings' => 20,
'node' => 7,
'node_type' => 7,
'rdf_mapping' => 8,
'search_page' => 2,
'shortcut' => 6,
'shortcut_set' => 2,
'action' => 19,
'menu' => 6,
'taxonomy_term' => 24,
'taxonomy_vocabulary' => 7,
'path_alias' => 8,
'tour' => 5,
'user' => 4,
'user_role' => 3,
'menu_link_content' => 12,
'view' => 16,
'date_format' => 11,
'entity_form_display' => 22,
'entity_form_mode' => 1,
'entity_view_display' => 33,
'entity_view_mode' => 14,
'base_field_override' => 4,
];
}
protected function getEntityCountsIncremental() {
$counts = $this
->getEntityCounts();
$counts['block_content'] = 2;
$counts['comment'] = 5;
$counts['file'] = 4;
$counts['menu_link_content'] = 13;
$counts['node'] = 8;
$counts['taxonomy_term'] = 25;
$counts['user'] = 5;
return $counts;
}
protected function getAvailablePaths() {
return [
'aggregator',
'block',
'book',
'color',
'comment',
'contact',
'ctools',
'date',
'dblog',
'email',
'entity_translation',
'entityreference',
'field',
'field_sql_storage',
'file',
'filter',
'forum',
'i18n_block',
'i18n_sync',
'i18n_variable',
'image',
'link',
'list',
'menu',
'node',
'number',
'options',
'path',
'phone',
'rdf',
'search',
'shortcut',
'statistics',
'system',
'taxonomy',
'text',
'title',
'user',
'blog',
'contextual',
'date_api',
'entity',
'field_ui',
'help',
'php',
'simpletest',
'toolbar',
'translation',
'trigger',
];
}
protected function getMissingPaths() {
return [
'i18n',
'i18n_field',
'i18n_string',
'i18n_taxonomy',
'i18n_translation',
'locale',
'variable',
'variable_realm',
'variable_store',
'syslog',
'tracker',
'update',
];
}
public function testMigrateUpgradeExecute() {
parent::testMigrateUpgradeExecute();
$user = User::load(2);
$user->passRaw = 'a password';
$this
->drupalLogin($user);
$this
->assertFollowUpMigrationResults();
}
protected function assertFollowUpMigrationResults() {
$node = Node::load(2);
$this
->assertSame('4', $node
->get('field_reference')->target_id);
$this
->assertSame('4', $node
->get('field_reference_2')->target_id);
$translation = $node
->getTranslation('is');
$this
->assertSame('4', $translation
->get('field_reference')->target_id);
$this
->assertSame('4', $translation
->get('field_reference_2')->target_id);
$node = Node::load(4);
$this
->assertSame('2', $node
->get('field_reference')->target_id);
$this
->assertSame('2', $node
->get('field_reference_2')->target_id);
$translation = $node
->getTranslation('en');
$this
->assertSame('2', $translation
->get('field_reference')->target_id);
$this
->assertSame('2', $translation
->get('field_reference_2')->target_id);
}
}