3 namespace Drupal\Tests\migrate_drupal_ui\Functional\d7;
5 use Drupal\node\Entity\Node;
6 use Drupal\Tests\migrate_drupal_ui\Functional\MigrateUpgradeExecuteTestBase;
7 use Drupal\user\Entity\User;
10 * Tests Drupal 7 upgrade using the migrate UI.
12 * The test method is provided by the MigrateUpgradeTestBase class.
14 * @group migrate_drupal_ui
16 class MigrateUpgrade7Test extends MigrateUpgradeExecuteTestBase {
23 public static $modules = [
27 'content_translation',
35 'migration_provider_test',
36 // Required for translation migrations.
37 'migrate_drupal_multilingual',
43 protected function setUp() {
45 $this->loadFixture(drupal_get_path('module', 'migrate_drupal') . '/tests/fixtures/drupal7.php');
51 protected function getSourceBasePath() {
52 return __DIR__ . '/files';
58 protected function getEntityCounts() {
60 'aggregator_item' => 11,
61 'aggregator_feed' => 1,
64 'block_content_type' => 1,
66 // The 'standard' profile provides the 'comment' comment type, and the
67 // migration creates 6 comment types, one per node type.
69 // Module 'language' comes with 'en', 'und', 'zxx'. Migration adds 'is'
71 'configurable_language' => 5,
75 'field_storage_config' => 50,
79 'language_content_settings' => 6,
89 'taxonomy_term' => 18,
90 'taxonomy_vocabulary' => 4,
94 'menu_link_content' => 12,
97 'entity_form_display' => 17,
98 'entity_form_mode' => 1,
99 'entity_view_display' => 28,
100 'entity_view_mode' => 14,
101 'base_field_override' => 9,
108 protected function getEntityCountsIncremental() {
109 $counts = $this->getEntityCounts();
110 $counts['block_content'] = 2;
111 $counts['comment'] = 4;
113 $counts['menu_link_content'] = 13;
115 $counts['taxonomy_term'] = 19;
123 protected function getAvailablePaths() {
160 // Include modules that do not have an upgrade path and are enabled in the
161 // source database, defined in the $noUpgradePath property
162 // in MigrateUpgradeForm.
180 protected function getMissingPaths() {
186 // These modules are in the missing path list because they are installed
187 // on the source site but they are not installed on the destination site.
195 * Executes all steps of migrations upgrade.
197 public function testMigrateUpgradeExecute() {
198 parent::testMigrateUpgradeExecute();
200 // Ensure migrated users can log in.
201 $user = User::load(2);
202 $user->passRaw = 'a password';
203 $this->drupalLogin($user);
204 $this->assertFollowUpMigrationResults();
208 * Tests that follow-up migrations have been run successfully.
210 protected function assertFollowUpMigrationResults() {
211 $node = Node::load(2);
212 $this->assertSame('4', $node->get('field_reference')->target_id);
213 $this->assertSame('4', $node->get('field_reference_2')->target_id);
214 $translation = $node->getTranslation('is');
215 $this->assertSame('4', $translation->get('field_reference')->target_id);
216 $this->assertSame('4', $translation->get('field_reference_2')->target_id);
218 $node = Node::load(4);
219 $this->assertSame('2', $node->get('field_reference')->target_id);
220 $this->assertSame('2', $node->get('field_reference_2')->target_id);
221 $translation = $node->getTranslation('en');
222 $this->assertSame('2', $translation->get('field_reference')->target_id);
223 $this->assertSame('2', $translation->get('field_reference_2')->target_id);