Unverified Commit 82c63a2a authored by alexpott's avatar alexpott

Issue #3192900 by quietone, Matroskeen: Combine some migration kernel tests

parent f7dd26aa
......@@ -123,12 +123,8 @@ public function testMigration() {
$node = $comment->getCommentedEntity();
$this->assertInstanceOf(NodeInterface::class, $node);
$this->assertSame('1', $node->id());
}
/**
* Tests the migration of comment entity translations.
*/
public function testCommentEntityTranslations() {
// Tests the migration of comment entity translations.
$manager = $this->container->get('content_translation.manager');
// Get the comment and its translations.
......
......@@ -59,12 +59,8 @@ public function testUserMail() {
$config = \Drupal::service('language_manager')->getLanguageConfigOverride('zu', 'user.mail');
$this->assertSame('zu - An administrator created an account for you at [site:name]', $config->get('register_admin_created.subject'));
$this->assertSame("zu - [user:name],\r\n\r\nA site administrator at [site:name] has created an account for you. You may now log in to [site:login-url] using the following username and password:\r\n\r\nusername: [user:name]\r\npassword: \r\n\r\nYou may also log in by clicking on this link or copying and pasting it in your browser:\r\n\r\n[user:one-time-login-url]\r\n\r\nThis is a one-time login, so it can be used only once.\r\n\r\nAfter logging in, you will be redirected to [user:edit-url] so you can change your password.\r\n\r\n\r\n-- [site:name] team", $config->get('register_admin_created.body'));
}
/**
* Tests migration of i18n user variables to user.settings.yml.
*/
public function testUserSettings() {
// Tests migration of i18n user variables to user.settings.yml.
$config = \Drupal::service('language_manager')->getLanguageConfigOverride('fr', 'user.settings');
$this->assertSame(1, $config->get('notify.status_blocked'));
$this->assertSame(0, $config->get('notify.status_activated'));
......
......@@ -51,13 +51,8 @@ public function testLanguageContent() {
$this->assertTrue($config->isDefaultConfiguration());
$this->assertFalse($config->isLanguageAlterable());
$this->assertSame($config->getDefaultLangcode(), 'site_default');
}
/**
* Tests migration of content language settings when there is no language lock.
*/
public function testLanguageContentWithNoLanguageLock() {
// Assert that a we can assign a language.
// Assert that a we can assign a language when there is no language lock.
$config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'employee');
$this->assertSame($config->getDefaultLangcode(), 'current_interface');
$this->assertTrue($config->isLanguageAlterable());
......
......@@ -250,12 +250,7 @@ public function testNode() {
$node = $node->getTranslation('is');
$this->assertSame($value, $node->field_text_plain->value);
}
/**
* Test node entity translations migration from Drupal 7 to 8.
*/
public function testNodeEntityTranslations() {
// Test node entity translations migration from Drupal 7 to 8.
$manager = $this->container->get('content_translation.manager');
// Get the node and its translations.
......
......@@ -122,14 +122,9 @@ public function testUrlAlias() {
'langcode' => 'und',
];
$this->assertPath(8, $conditions, $path_alias);
}
/**
* Test the URL alias migration with translated nodes.
*/
public function testUrlAliasWithTranslatedNodes() {
// Test the URL alias migration with translated nodes.
// Alias for the 'The Real McCoy' node in English.
$path_alias = $this->loadPathAliasByConditions(['alias' => '/the-real-mccoy']);
$this->assertSame('/node/10', $path_alias->getPath());
$this->assertSame('en', $path_alias->get('langcode')->value);
......
......@@ -62,12 +62,8 @@ public function testTermNode() {
$this->assertCount(2, $node->field_vocabulary_2_i_1_);
$this->assertSame('2', $node->field_vocabulary_2_i_1_[0]->target_id);
$this->assertSame('3', $node->field_vocabulary_2_i_1_[1]->target_id);
}
/**
* Tests the Drupal 6 term-node association to Drupal 8 node revisions.
*/
public function testTermNodeRevision() {
// Tests the Drupal 6 term-node association to Drupal 8 node revisions.
$this->executeMigrations(['d6_term_node_revision']);
$node = \Drupal::entityTypeManager()->getStorage('node')->loadRevision(2001);
......
......@@ -154,49 +154,8 @@ public function testTaxonomyTerms() {
// Fixed.
$this->assertEntity(24, 'fr', 'FR - Crewman', 'vocabfixed', NULL, NULL, '0', []);
}
/**
* Retrieves the parent term IDs for a given term.
*
* @param $tid
* ID of the term to check.
*
* @return array
* List of parent term IDs.
*/
protected function getParentIDs($tid) {
return array_keys(\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($tid));
}
/**
* Assert that a term is present in the tree storage, with the right parents.
*
* @param string $vid
* Vocabulary ID.
* @param int $tid
* ID of the term to check.
* @param array $parent_ids
* The expected parent term IDs.
*/
protected function assertHierarchy($vid, $tid, array $parent_ids) {
if (!isset($this->treeData[$vid])) {
$tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
$this->treeData[$vid] = [];
foreach ($tree as $item) {
$this->treeData[$vid][$item->tid] = $item;
}
}
$this->assertArrayHasKey($tid, $this->treeData[$vid], "Term $tid exists in taxonomy tree");
$term = $this->treeData[$vid][$tid];
$this->assertEquals($parent_ids, array_filter($term->parents), "Term $tid has correct parents in taxonomy tree");
}
/**
* Tests the migration of taxonomy term entity translations.
*/
public function testTaxonomyTermEntityTranslations() {
// Tests the migration of taxonomy term entity translations.
$manager = $this->container->get('content_translation.manager');
// Get the term and its translations.
......@@ -245,4 +204,41 @@ public function testTaxonomyTermEntityTranslations() {
$this->assertSame($term->parent->terget_id, $term_is->parent->terget_id);
}
/**
* Retrieves the parent term IDs for a given term.
*
* @param $tid
* ID of the term to check.
*
* @return array
* List of parent term IDs.
*/
protected function getParentIDs($tid) {
return array_keys(\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($tid));
}
/**
* Assert that a term is present in the tree storage, with the right parents.
*
* @param string $vid
* Vocabulary ID.
* @param int $tid
* ID of the term to check.
* @param array $parent_ids
* The expected parent term IDs.
*/
protected function assertHierarchy($vid, $tid, array $parent_ids) {
if (!isset($this->treeData[$vid])) {
$tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);
$this->treeData[$vid] = [];
foreach ($tree as $item) {
$this->treeData[$vid][$item->tid] = $item;
}
}
$this->assertArrayHasKey($tid, $this->treeData[$vid], "Term $tid exists in taxonomy tree");
$term = $this->treeData[$vid][$tid];
$this->assertEquals($parent_ids, array_filter($term->parents), "Term $tid has correct parents in taxonomy tree");
}
}
......@@ -46,12 +46,8 @@ public function testUserMail() {
$this->assertSame('Account details for [user:name] at [site:name] (blocked)', $config->get('status_blocked.subject'));
$this->assertSame("[user:name],\n\nYour account on [site:name] has been blocked.", $config->get('status_blocked.body'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'user.mail', $config->get());
}
/**
* Tests migration of user variables to user.settings.yml.
*/
public function testUserSettings() {
// Tests migration of user variables to user.settings.yml.
$config = $this->config('user.settings');
$this->assertTrue($config->get('notify.status_blocked'));
$this->assertFalse($config->get('notify.status_activated'));
......
......@@ -48,6 +48,15 @@ public function testUserPictures() {
$this->assertSame('public://image-test.png', $file->getFileUri());
$this->assertSame('8', $file->getOwnerId());
$this->assertEmpty($files);
// Tests the D6 user pictures migration in combination with D6 file.
$this->setUpMigratedFiles();
$this->assertEntity(1, 'image-test.jpg', '1901', 'public://image-test.jpg', 'image/jpeg', '2');
$this->assertEntity(2, 'image-test.png', '125', 'public://image-test.png', 'image/png', '8');
$this->assertEntity(3, 'Image1.png', '39325', 'public://image-1.png', 'image/png', '1');
$this->assertEntity(4, 'Image2.jpg', '1831', 'public://image-2.jpg', 'image/jpeg', '1');
$this->assertEntity(5, 'Image-test.gif', '183', 'public://image-test.gif', 'image/jpeg', '1');
$this->assertEntity(6, 'html-1.txt', '24', 'public://html-1.txt', 'text/plain', '1');
}
/**
......@@ -77,17 +86,4 @@ protected function assertEntity($fid, $name, $size, $uri, $type, $uid) {
$this->assertSame($uid, $file->getOwnerId());
}
/**
* Tests the D6 user pictures migration in combination with D6 file.
*/
public function testUserPicturesWithD6File() {
$this->setUpMigratedFiles();
$this->assertEntity(1, 'image-test.jpg', '1901', 'public://image-test.jpg', 'image/jpeg', '2');
$this->assertEntity(2, 'image-test.png', '125', 'public://image-test.png', 'image/png', '8');
$this->assertEntity(3, 'Image1.png', '39325', 'public://image-1.png', 'image/png', '1');
$this->assertEntity(4, 'Image2.jpg', '1831', 'public://image-2.jpg', 'image/jpeg', '1');
$this->assertEntity(5, 'Image-test.gif', '183', 'public://image-test.gif', 'image/jpeg', '1');
$this->assertEntity(6, 'html-1.txt', '24', 'public://html-1.txt', 'text/plain', '1');
}
}
......@@ -217,12 +217,8 @@ public function testUser() {
$user = User::load($source->uid);
$this->assertEquals($rehash, $user->getPassword());
}
}
/**
* Tests the Drupal 7 user entity translations to Drupal 8 migration.
*/
public function testUserEntityTranslations() {
// Tests the Drupal 7 user entity translations to Drupal 8 migration.
$manager = $this->container->get('content_translation.manager');
// Get the user and its translations.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment