View source
<?php
namespace Drupal\Tests\migrate_drupal_ui\Functional\d6;
use Drupal\node\Entity\Node;
use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeExecuteTestBase;
class Upgrade6Test extends MigrateUpgradeExecuteTestBase {
protected static $modules = [
'book',
'config_translation',
'content_translation',
'datetime_range',
'forum',
'language',
'migrate_drupal_ui',
'rdf',
'statistics',
'telephone',
'update',
];
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/drupal6.php');
\Drupal::service('module_installer')
->uninstall([
'rdf',
]);
}
protected function getSourceBasePath() {
return __DIR__ . '/files';
}
protected function getEntityCounts() {
return [
'block' => 36,
'block_content' => 2,
'block_content_type' => 1,
'comment' => 8,
'comment_type' => 14,
'contact_form' => 5,
'contact_message' => 0,
'configurable_language' => 5,
'editor' => 2,
'field_config' => 103,
'field_storage_config' => 71,
'file' => 7,
'filter_format' => 7,
'image_style' => 6,
'language_content_settings' => 15,
'node' => 18,
'node_type' => 14,
'search_page' => 2,
'shortcut' => 2,
'shortcut_set' => 1,
'action' => 33,
'menu' => 8,
'path_alias' => 8,
'taxonomy_term' => 15,
'taxonomy_vocabulary' => 7,
'tour' => 6,
'user' => 7,
'user_role' => 7,
'menu_link_content' => 10,
'view' => 14,
'date_format' => 12,
'entity_form_display' => 31,
'entity_form_mode' => 1,
'entity_view_display' => 58,
'entity_view_mode' => 12,
'base_field_override' => 41,
];
}
protected function getEntityCountsIncremental() {
$counts = $this
->getEntityCounts();
$counts['block_content'] = 3;
$counts['comment'] = 9;
$counts['file'] = 8;
$counts['menu_link_content'] = 11;
$counts['node'] = 19;
$counts['taxonomy_term'] = 16;
$counts['user'] = 8;
return $counts;
}
protected function getAvailablePaths() {
return [
'Block',
'Block translation',
'Book',
'CCK translation',
'Comment',
'Contact',
'Content',
'Content translation',
'Content type translation',
'Date',
'Email',
'FileField',
'Filter',
'Forum',
'ImageCache',
'ImageField',
'Internationalization',
'Locale',
'Menu',
'Menu translation',
'Node',
'Node Reference',
'Option Widgets',
'Path',
'Profile translation',
'Search',
'Statistics',
'String translation',
'Synchronize translations',
'System',
'Taxonomy',
'Taxonomy translation',
'Text',
'Update status',
'Upload',
'User',
'User Reference',
'Date API',
'Date Timezone',
'Event',
'ImageAPI',
'Number',
'PHP filter',
'Profile',
'Variable admin',
];
}
protected function getMissingPaths() {
return [
'Aggregator',
];
}
public function testUpgradeAndIncremental() {
$this
->doUpgradeAndIncremental();
$this
->assertUserLogIn(2, 'john.doe_pass');
$this
->assertFollowUpMigrationResults();
$this
->assertEmailsSent();
}
protected function assertFollowUpMigrationResults() : void {
$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);
}
}