Skip to content
Snippets Groups Projects
Commit 8477f6b7 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2554321 by phenaproxima, mikeryan, quietone, neclimdul, benjy: Clean up Migrate's test suite

parent 07c8d58c
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing
with 158 additions and 286 deletions
......@@ -20,11 +20,9 @@ class MigrateActionConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('action');
public static $modules = ['action'];
/**
* {@inheritdoc}
......
......@@ -20,11 +20,9 @@ class MigrateAggregatorConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('aggregator');
public static $modules = ['aggregator'];
/**
* {@inheritdoc}
......
......@@ -17,7 +17,10 @@
*/
class MigrateAggregatorFeedTest extends MigrateDrupal6TestBase {
static $modules = array('aggregator');
/**
* {@inheritdoc}
*/
public static $modules = ['aggregator'];
/**
* {@inheritdoc}
......
......@@ -17,7 +17,10 @@
*/
class MigrateAggregatorItemTest extends MigrateDrupal6TestBase {
static $modules = array('aggregator');
/**
* {@inheritdoc}
*/
public static $modules = ['aggregator'];
/**
* {@inheritdoc}
......@@ -26,26 +29,7 @@ protected function setUp() {
parent::setUp();
$this->installEntitySchema('aggregator_feed');
$this->installEntitySchema('aggregator_item');
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_aggregator_feed' => array(
array(array(5), array(5)),
),
);
$this->prepareMigrations($id_mappings);
$entity = entity_create('aggregator_feed', array(
'fid' => 5,
'title' => 'Drupal Core',
'url' => 'https://groups.drupal.org/not_used/167169',
'refresh' => 900,
'checked' => 1389919932,
'description' => 'Drupal Core Group feed',
));
$entity->enforceIsNew();
$entity->save();
$this->executeMigration('d6_aggregator_item');
$this->executeMigrations(['d6_aggregator_feed', 'd6_aggregator_item']);
}
/**
......
......@@ -18,50 +18,24 @@
class MigrateBlockTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
static $modules = array(
public static $modules = [
'block',
'views',
'comment',
'menu_ui',
'block_content',
'node',
);
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['block_content']);
$this->installEntitySchema('block_content');
$entities = array(
entity_create('menu', array('id' => 'primary-links')),
entity_create('menu', array('id' => 'secondary-links')),
entity_create('block_content', array('id' => 1, 'type' => 'basic', 'info' => $this->randomMachineName(8))),
entity_create('block_content', array('id' => 2, 'type' => 'basic', 'info' => $this->randomMachineName(8))),
);
foreach ($entities as $entity) {
$entity->enforceIsNew(TRUE);
$entity->save();
}
$this->prepareMigrations(array(
'd6_custom_block' => array(
array(array(1), array(1)),
array(array(2), array(2)),
),
'menu' => array(
array(array('menu1'), array('menu')),
),
'd6_user_role' => array(
array(array(2), array('authenticated')),
array(array(3), array('migrate_test_role_1')),
),
));
// Set Bartik and Seven as the default public and admin theme.
$config = $this->config('system.theme');
$config->set('default', 'bartik');
......@@ -69,9 +43,17 @@ protected function setUp() {
$config->save();
// Install one of D8's test themes.
\Drupal::service('theme_handler')->install(array('test_theme'));
$this->executeMigration('d6_block');
\Drupal::service('theme_handler')->install(['test_theme']);
$this->executeMigrations([
'd6_filter_format',
'block_content_type',
'block_content_body_field',
'd6_custom_block',
'menu',
'd6_user_role',
'd6_block',
]);
}
/**
......
......@@ -18,10 +18,8 @@
*/
class MigrateBlockTest extends MigrateDrupal7TestBase {
/**
* Modules to enable.
*
* @var array
/**
* {@inheritdoc}
*/
static $modules = [
'block',
......@@ -52,12 +50,14 @@ protected function setUp() {
// Install one of D8's test themes.
\Drupal::service('theme_handler')->install(['bartik']);
$this->executeMigration('d7_filter_format');
$this->executeMigration('d7_user_role');
$this->executeMigration('block_content_type');
$this->executeMigration('block_content_body_field');
$this->executeMigration('d7_custom_block');
$this->executeMigration('d7_block');
$this->executeMigrations([
'd7_filter_format',
'd7_user_role',
'block_content_type',
'block_content_body_field',
'd7_custom_block',
'd7_block',
]);
}
/**
......
......@@ -29,8 +29,10 @@ protected function setUp() {
parent::setUp();
$this->installConfig(['block_content']);
$this->installEntitySchema('block_content');
$this->executeMigration('block_content_type');
$this->executeMigration('block_content_body_field');
$this->executeMigrations([
'block_content_type',
'block_content_body_field',
]);
}
/**
......
......@@ -17,25 +17,25 @@
*/
class MigrateBlockContentTest extends MigrateDrupal6TestBase {
static $modules = array('block', 'block_content', 'filter', 'text');
/**
* {@inheritdoc}
*/
public static $modules = ['block', 'block_content'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(array('block_content'));
$this->installConfig(['block_content']);
$this->installEntitySchema('block_content');
$this->executeMigration('block_content_type');
$this->executeMigration('block_content_body_field');
$this->prepareMigrations(array(
'd6_filter_format' => array(
array(array(2), array('full_html'))
)
));
$this->executeMigration('d6_custom_block');
$this->executeMigrations([
'd6_filter_format',
'block_content_type',
'block_content_body_field',
'd6_custom_block',
]);
}
/**
......
......@@ -32,10 +32,12 @@ protected function setUp() {
$this->installConfig(static::$modules);
$this->installEntitySchema('block_content');
$this->executeMigration('d7_filter_format');
$this->executeMigration('block_content_type');
$this->executeMigration('block_content_body_field');
$this->executeMigration('d7_custom_block');
$this->executeMigrations([
'd7_filter_format',
'block_content_type',
'block_content_body_field',
'd7_custom_block',
]);
}
/**
......
......@@ -20,11 +20,9 @@ class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
use SchemaCheckTestTrait;
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('book', 'system', 'node', 'field', 'text', 'entity_reference');
public static $modules = ['book'];
/**
* {@inheritdoc}
......
......@@ -17,39 +17,19 @@
*/
class MigrateBookTest extends MigrateDrupal6TestBase {
public static $modules = array('book', 'system', 'node', 'field', 'text', 'entity_reference', 'user');
/**
* {@inheritdoc}
*/
public static $modules = ['book'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installSchema('book', array('book'));
$this->installSchema('node', array('node_access'));
// Create a default bogus mapping for all variants of d6_node.
$id_mappings = array(
'd6_node:*' => array(
array(
array(0),
array(0),
),
),
);
for ($i = 4; $i <= 8; $i++) {
$entity = entity_create('node', array(
'type' => 'story',
'title' => "Node $i",
'nid' => $i,
'status' => TRUE,
));
$entity->enforceIsNew();
$entity->save();
$id_mappings['d6_node__story'][] = array(array($i), array($i));
}
$this->prepareMigrations($id_mappings);
$this->installSchema('book', ['book']);
$this->installSchema('node', ['node_access']);
$this->migrateContent();
$this->executeMigration('d6_book');
}
......
......@@ -19,10 +19,16 @@ class MigrateCommentTest extends MigrateDrupal6TestBase {
use CommentTestTrait;
// Directly testing that comments' entity_id is populated upon importing is
// not straightforward, but RDF module serves as an implicit test -
// its hook_comment_storage_load() references a stubbed comment.
static $modules = ['node', 'comment', 'text', 'filter', 'rdf'];
/**
* {@inheritdoc}
*/
public static $modules = [
'comment',
// Directly testing that a stub comment's entity_id is populated upon
// importing is not straightforward, but RDF module serves as an implicit
// test - its hook_comment_storage_load() references a stubbed comment.
'rdf',
];
/**
* {@inheritdoc}
......@@ -34,38 +40,20 @@ protected function setUp() {
$this->installEntitySchema('comment');
$this->installSchema('comment', ['comment_entity_statistics']);
$this->installSchema('system', ['router']);
$this->installConfig(['node', 'comment']);
$this->installConfig(['comment']);
// The entity.node.canonical route must exist when the RDF hook is called.
$this->container->get('router.builder')->rebuild();
entity_create('node_type', array('type' => 'page'))->save();
entity_create('node_type', array('type' => 'story'))->save();
$this->addDefaultCommentField('node', 'story');
$this->container->get('entity.manager')->getStorage('comment_type')->create(array(
'id' => 'comment_no_subject',
'label' => 'comment_no_subject',
'target_entity_type_id' => 'node',
))->save();
\Drupal::service('comment.manager')->addBodyField('comment_no_subject');
$node = entity_create('node', array(
'type' => 'story',
'nid' => 1,
'title' => $this->randomString(),
));
$node->enforceIsNew();
$node->save();
$id_mappings = array(
'd6_filter_format' => array(array(array(1), array('filtered_html'))),
'd6_node:*' => array(array(array(1), array(1))),
'd6_user' => array(array(array(0), array(0))),
'd6_comment_type' => array(array(array('comment'), array('comment_no_subject'))),
'd6_comment_entity_display' => array(array(array('story'), array('node', 'story', 'default', 'comment'))),
'd6_comment_entity_form_display' => array(array(array('story'), array('node', 'story', 'default', 'comment'))),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_comment');
$this->migrateContent();
$this->executeMigrations([
'd6_comment_type',
'd6_comment_field',
'd6_comment_field_instance',
'd6_comment_entity_display',
'd6_comment_entity_form_display',
'd6_comment',
]);
}
/**
......
......@@ -17,7 +17,10 @@
*/
class MigrateCommentTypeTest extends MigrateDrupal6TestBase {
static $modules = array('node', 'comment', 'text', 'filter');
/**
* {@inheritdoc}
*/
public static $modules = ['comment'];
/**
* {@inheritdoc}
......
......@@ -15,57 +15,22 @@
abstract class MigrateCommentVariableDisplayBase extends MigrateDrupal6TestBase {
/**
* The ID of migration to run.
*
* This constant needs to be set in the concrete class in order for the test
* to work.
*/
const MIGRATION = '';
/**
* Modules to enable.
*
* @var array
*/
static $modules = array('comment', 'node');
/**
* The node types being tested.
*
* @var array
* {@inheritdoc}
*/
protected $types = array('page', 'story', 'article');
public static $modules = ['comment'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'comment',
'type' => 'comment',
'translatable' => '0',
))->save();
foreach ($this->types as $type) {
entity_create('node_type', array('type' => $type))->save();
entity_create('field_config', array(
'label' => 'Comments',
'description' => '',
'field_name' => 'comment',
'entity_type' => 'node',
'bundle' => $type,
'required' => 1,
))->save();
}
$id_mappings = array(
'd6_comment_field_instance' => array(
array(array('page'), array('node', 'comment', 'page')),
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration(static::MIGRATION);
$this->installConfig(['comment']);
$this->migrateContentTypes();
$this->executeMigrations([
'd6_comment_type',
'd6_comment_field',
'd6_comment_field_instance',
]);
}
}
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
/**
* Upgrade comment variables to entity.display.node.*.default.yml.
*
......@@ -15,21 +17,19 @@
class MigrateCommentVariableEntityDisplayTest extends MigrateCommentVariableDisplayBase {
/**
* The migration to run.
* {@inheritdoc}
*/
const MIGRATION = 'd6_comment_entity_display';
/**
* The node types being used.
*/
protected $types = array('page', 'story', 'article');
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_comment_entity_display');
}
/**
* Tests comment variables migrated into an entity display.
*/
public function testCommentEntityDisplay() {
foreach ($this->types as $type) {
$component = entity_get_display('node', $type, 'default')->getComponent('comment');
foreach (['page', 'story', 'article'] as $type) {
$component = EntityViewDisplay::load('node.' . $type . '.default')->getComponent('comment');
$this->assertIdentical('hidden', $component['label']);
$this->assertIdentical('comment_default', $component['type']);
$this->assertIdentical(20, $component['weight']);
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Tests\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
......@@ -17,43 +18,31 @@
class MigrateCommentVariableEntityFormDisplaySubjectTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('comment', 'node');
public static $modules = ['comment'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
foreach (['comment', 'comment_no_subject'] as $comment_type) {
entity_create('comment_type', array(
'id' => $comment_type,
'target_entity_type_id' => 'node',
))
->save();
}
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_comment_type' => array(
array(array('comment'), array('comment_no_subject')),
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_comment_entity_form_display_subject');
$this->installConfig(['comment']);
$this->executeMigrations([
'd6_comment_type',
'd6_comment_entity_form_display_subject',
]);
}
/**
* Tests comment subject variable migrated into an entity display.
*/
public function testCommentEntityFormDisplay() {
$component = entity_get_form_display('comment', 'comment', 'default')
$component = EntityFormDisplay::load('comment.comment.default')
->getComponent('subject');
$this->assertIdentical('string_textfield', $component['type']);
$this->assertIdentical(10, $component['weight']);
$component = entity_get_form_display('comment', 'comment_no_subject', 'default')
$component = EntityFormDisplay::load('comment.comment_no_subject.default')
->getComponent('subject');
$this->assertNull($component);
}
......
......@@ -7,6 +7,8 @@
namespace Drupal\comment\Tests\Migrate\d6;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
/**
* Upgrade comment variables to core.entity_form_display.node.*.default.yml.
*
......@@ -15,16 +17,20 @@
class MigrateCommentVariableEntityFormDisplayTest extends MigrateCommentVariableDisplayBase {
/**
* The migration to run.
* {@inheritdoc}
*/
const MIGRATION = 'd6_comment_entity_form_display';
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_comment_entity_form_display');
}
/**
* Tests comment variables migrated into an entity display.
*/
public function testCommentEntityFormDisplay() {
foreach ($this->types as $type) {
$component = entity_get_form_display('node', $type, 'default')->getComponent('comment');
foreach (['page', 'article', 'story'] as $type) {
$component = EntityFormDisplay::load('node.' . $type . '.default')
->getComponent('comment');
$this->assertIdentical('comment_default', $component['type']);
$this->assertIdentical(20, $component['weight']);
}
......
......@@ -17,31 +17,19 @@
*/
class MigrateCommentVariableFieldTest extends MigrateDrupal6TestBase {
static $modules = array('comment', 'node');
/**
* {@inheritdoc}
*/
public static $modules = ['comment'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
foreach (array('page', 'story', 'test') as $type) {
entity_create('node_type', array('type' => $type))->save();
}
foreach (['comment', 'comment_no_subject'] as $comment_type) {
entity_create('comment_type', array(
'id' => $comment_type,
'target_entity_type_id' => 'node',
))
->save();
}
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_comment_type' => array(
array(array('comment'), array('comment_no_subject')),
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_comment_field');
$this->installConfig(['comment']);
$this->migrateContentTypes();
$this->executeMigrations(['d6_comment_type', 'd6_comment_field']);
}
/**
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Tests\Migrate\d6;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
use Drupal\node\Entity\Node;
/**
* Upgrade comment variables to field.instance.node.*.comment.yml.
......@@ -16,47 +17,30 @@
*/
class MigrateCommentVariableInstanceTest extends MigrateDrupal6TestBase {
static $modules = array('comment', 'node');
/**
* {@inheritdoc}
*/
public static $modules = ['comment'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Add some id mappings for the dependant migrations.
$id_mappings = array(
'd6_comment_field' => array(
array(array('page'), array('node', 'page')),
),
'd6_node_type' => array(
array(array('page'), array('page')),
),
);
$this->prepareMigrations($id_mappings);
foreach (array('page', 'story', 'article') as $type) {
entity_create('node_type', array('type' => $type))->save();
}
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'comment',
'type' => 'comment',
'translatable' => '0',
))->save();
entity_create('field_storage_config', array(
'entity_type' => 'node',
'field_name' => 'comment_no_subject',
'type' => 'comment',
'translatable' => '0',
))->save();
$this->executeMigration('d6_comment_field_instance');
$this->installConfig(['comment']);
$this->migrateContentTypes();
$this->executeMigrations([
'd6_comment_type',
'd6_comment_field',
'd6_comment_field_instance',
]);
}
/**
* Test the migrated field instance values.
*/
public function testCommentFieldInstance() {
$node = entity_create('node', array('type' => 'page'));
$node = Node::create(['type' => 'page']);
$this->assertIdentical(0, $node->comment->status);
$this->assertIdentical('comment', $node->comment->getFieldDefinition()->getName());
$settings = $node->comment->getFieldDefinition()->getSettings();
......@@ -66,7 +50,7 @@ public function testCommentFieldInstance() {
$this->assertIdentical(FALSE, $settings['form_location']);
$this->assertIdentical(1, $settings['preview']);
$node = entity_create('node', array('type' => 'story'));
$node = Node::create(['type' => 'story']);
$this->assertIdentical(2, $node->comment_no_subject->status);
$this->assertIdentical('comment_no_subject', $node->comment_no_subject->getFieldDefinition()->getName());
$settings = $node->comment_no_subject->getFieldDefinition()->getSettings();
......
......@@ -25,11 +25,13 @@ class MigrateCommentEntityDisplayTest extends MigrateDrupal7TestBase {
protected function setUp() {
parent::setUp();
$this->installConfig(static::$modules);
$this->executeMigration('d7_node_type');
$this->executeMigration('d7_comment_type');
$this->executeMigration('d7_comment_field');
$this->executeMigration('d7_comment_field_instance');
$this->executeMigration('d7_comment_entity_display');
$this->executeMigrations([
'd7_node_type',
'd7_comment_type',
'd7_comment_field',
'd7_comment_field_instance',
'd7_comment_entity_display',
]);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment