Commit ac584f1f authored by catch's avatar catch

Issue #3125763 by quietone, heddn, dww, benjifisher, Lal_, Neslee Canil Pinto,...

Issue #3125763 by quietone, heddn, dww, benjifisher, Lal_, Neslee Canil Pinto, alexpott, mikelutz: Test coverage for hidden dependency on migrate_drupal from node module when only migrate.module is enabled
parent a9e15efb
name: 'Migrate No Migrate Drupal Test'
type: module
description: Provides fixture for testing without migrate_drupal.
package: Testing
version: VERSION
- drupal:migrate
- drupal:node
path: '/migrate_no_migrate_drupal_test/execute'
_controller: '\Drupal\migrate_no_migrate_drupal_test\Controller\ExecuteMigration::execute'
_title: 'Execute'
_access: 'TRUE'
id: node_migration_no_migrate_drupal
label: Node Migration No Migrate Drupal
plugin: embedded_data
id: 1
nid: 1
title: Node 1
id: 2
nid: 2
title: Node 2
type: integer
nid: nid
title: title
default_bundle: no_migrate_drupal
plugin: entity:node
namespace Drupal\migrate_no_migrate_drupal_test\Controller;
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Core\Controller\ControllerBase;
use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\Plugin\MigrationInterface;
* Custom controller to execute the test migrations.
* This controller class is required for the proper functional testing of
* migration dependencies. Otherwise, the migration directly executed from the
* functional test would use the functional test's class map and autoloader. The
* functional test has all the classes available to it but the controller
* does not.
class ExecuteMigration extends ControllerBase {
* Run the node_migration_no_migrate_drupal test migration.
* @return array
* A renderable array.
public function execute() {
$migration_plugin_manager = \Drupal::service('plugin.manager.migration');
$definitions = $migration_plugin_manager->getDefinitions();
if ($definitions['node_migration_no_migrate_drupal']['label'] !== 'Node Migration No Migrate Drupal') {
throw new InvalidPluginDefinitionException('node_migration_no_migrate_drupal');
$migrations = $migration_plugin_manager->createInstances('');
$result = (new MigrateExecutable($migrations['node_migration_no_migrate_drupal']))->import();
if ($result !== MigrationInterface::RESULT_COMPLETED) {
throw new \RuntimeException('Migration failed');
return [
'#type' => 'markup',
'#markup' => 'Migration was successful.',
namespace Drupal\Tests\migrate\Functional;
use Drupal\node\Entity\Node;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\node\Traits\ContentTypeCreationTrait;
* Execute migration.
* This is intentionally a Functional test instead of a Kernel test because
* Kernel tests have proven to not catch all edge cases that are encountered
* via a Functional test.
* @group migrate
class MigrateNoMigrateDrupalTest extends BrowserTestBase {
use ContentTypeCreationTrait;
* {@inheritdoc}
protected $defaultTheme = 'stark';
* {@inheritdoc}
protected static $modules = [
* {@inheritdoc}
protected function setUp() {
// Ensures that code from the migrate_drupal module can not be autoloaded
// while testing on DrupalCI.
$this->writeSettings(['settings' => ['deployment_identifier' => (object) ['value' => 'force-new-apcu-key', 'required' => TRUE]]]);
$this->createContentType(['type' => 'no_migrate_drupal']);
* Tests execution of a migration.
public function testExecutionNoMigrateDrupal() {
$this->assertSession()->pageTextContains('Migration was successful.');
$node_1 = Node::load(1);
$node_2 = Node::load(2);
$this->assertEquals('Node 1', $node_1->label());
$this->assertEquals('Node 2', $node_2->label());
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