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 {
protected static $modules = [
'book',
'config_translation',
'content_translation',
'datetime_range',
'forum',
'language',
'migrate_drupal_ui',
'rdf',
'statistics',
'telephone',
];
protected $nodeStorage;
protected function setUp() : void {
parent::setUp();
$this->nodeStorage = $this->container
->get('entity_type.manager')
->getStorage('node');
$this->nodeStorage
->delete($this->nodeStorage
->loadMultiple());
$this
->loadFixture($this
->getModulePath('migrate_drupal') . '/tests/fixtures/drupal7.php');
\Drupal::service('module_installer')
->uninstall([
'rdf',
]);
}
protected function getSourceBasePath() {
return __DIR__ . '/files';
}
protected function getEntityCounts() {
return [
'block' => 27,
'block_content' => 1,
'block_content_type' => 1,
'comment' => 4,
'comment_type' => 9,
'configurable_language' => 5,
'contact_form' => 3,
'contact_message' => 0,
'editor' => 2,
'field_config' => 91,
'field_storage_config' => 70,
'file' => 3,
'filter_format' => 7,
'image_style' => 7,
'language_content_settings' => 24,
'node' => 7,
'node_type' => 8,
'search_page' => 2,
'shortcut' => 6,
'shortcut_set' => 2,
'action' => 27,
'menu' => 7,
'taxonomy_term' => 25,
'taxonomy_vocabulary' => 8,
'path_alias' => 8,
'tour' => 6,
'user' => 4,
'user_role' => 4,
'menu_link_content' => 12,
'view' => 14,
'date_format' => 12,
'entity_form_display' => 24,
'entity_form_mode' => 1,
'entity_view_display' => 34,
'entity_view_mode' => 12,
'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'] = 26;
$counts['user'] = 5;
return $counts;
}
protected function getAvailablePaths() {
return [
'Block languages',
'Block',
'Book',
'Chaos tools',
'Comment',
'Contact',
'Content translation',
'Database logging',
'Date',
'Email',
'Entity Reference',
'Entity Translation',
'Field SQL storage',
'Field translation',
'Field',
'File',
'Filter',
'Forum',
'Image',
'Internationalization',
'Locale',
'Link',
'List',
'Menu',
'Menu translation',
'Multiupload Filefield Widget',
'Multiupload Imagefield Widget',
'Node',
'Node Reference',
'Number',
'Options',
'Path',
'Phone',
'Search',
'Shortcut',
'Statistics',
'String translation',
'Synchronize translations',
'System',
'Taxonomy translation',
'Taxonomy',
'Telephone',
'Text',
'Title',
'User',
'User Reference',
'Variable translation',
'Blog',
'Contextual links',
'Date API',
'Entity API',
'Field UI',
'Help',
'PHP filter',
'Testing',
'Toolbar',
'Trigger',
];
}
protected function getMissingPaths() {
return [
'Aggregator',
'Color',
'RDF',
'References',
'Translation sets',
'Variable realm',
'Variable store',
'Variable',
'Syslog',
'Tracker',
'Update manager',
];
}
public function testUpgradeAndIncremental() {
$this
->doUpgradeAndIncremental();
$this
->assertUserLogIn(2, 'a password');
$this
->assertFollowUpMigrationResults();
$this
->assertEmailsSent();
}
protected function assertFollowUpMigrationResults() : void {
$node = Node::load(2);
$this
->assertSame('4', $node
->get('field_reference')->target_id);
$this
->assertSame('6', $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);
$user = User::load(2);
$this
->assertSame('2', $user
->get('field_reference')->target_id);
}
}